Alexandria  2.22.0
Please provide a description of the project.
FileAccessor.icpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2021 Euclid Science Ground Segment
3  *
4  * This library is free software; you can redistribute it and/or modify it under
5  * the terms of the GNU Lesser General Public License as published by the Free
6  * Software Foundation; either version 3.0 of the License, or (at your option)
7  * any later version.
8  *
9  * This library is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12  * details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with this library; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 #ifndef FILEACCESSOR_IMPL
20 #error "This file should not be included directly! Use FileAccessor.h instead"
21 #else
22 
23 namespace Euclid {
24 namespace FilePool {
25 
26 template <typename TFD>
27 FileAccessor<TFD>::FileAccessor(TFD&& fd, ReleaseDescriptorCallback release_callback)
28  : m_fd(std::move(fd)), m_release_callback(release_callback) {}
29 
30 template <typename TFD>
31 FileReadAccessor<TFD>::FileReadAccessor(TFD&& fd, ReleaseDescriptorCallback release_callback, SharedLock lock)
32  : FileAccessor<TFD>(std::move(fd), release_callback), m_shared_lock(std::move(lock)) {}
33 
34 template <typename TFD>
35 FileReadAccessor<TFD>::~FileReadAccessor() {
36  FileAccessor<TFD>::m_release_callback(std::move(FileAccessor<TFD>::m_fd));
37 }
38 
39 template <typename TFD>
40 bool FileReadAccessor<TFD>::isReadOnly() const {
41  return true;
42 }
43 
44 template <typename TFD>
45 FileWriteAccessor<TFD>::FileWriteAccessor(TFD&& fd, ReleaseDescriptorCallback release_callback, UniqueLock lock)
46  : FileAccessor<TFD>(std::move(fd), release_callback), m_unique_lock(std::move(lock)) {}
47 
48 template <typename TFD>
49 FileWriteAccessor<TFD>::~FileWriteAccessor<TFD>() {
50  FileAccessor<TFD>::m_release_callback(std::move(FileAccessor<TFD>::m_fd));
51 }
52 
53 template <typename TFD>
54 bool FileWriteAccessor<TFD>::isReadOnly() const {
55  return false;
56 }
57 
58 } // namespace FilePool
59 } // namespace Euclid
60 
61 #endif