Alexandria 2.31.0
SDC-CH common library for the Euclid project
Loading...
Searching...
No Matches
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
23namespace Euclid {
24namespace FilePool {
25
26template <typename TFD>
27FileAccessor<TFD>::FileAccessor(TFD&& fd, ReleaseDescriptorCallback release_callback)
28 : m_fd(std::move(fd)), m_release_callback(release_callback) {}
29
30template <typename TFD>
31FileReadAccessor<TFD>::FileReadAccessor(TFD&& fd, ReleaseDescriptorCallback release_callback, SharedLock lock)
32 : FileAccessor<TFD>(std::move(fd), release_callback), m_shared_lock(std::move(lock)) {}
33
34template <typename TFD>
35FileReadAccessor<TFD>::~FileReadAccessor() {
36 FileAccessor<TFD>::m_release_callback(std::move(FileAccessor<TFD>::m_fd));
37}
38
39template <typename TFD>
40bool FileReadAccessor<TFD>::isReadOnly() const {
41 return true;
42}
43
44template <typename TFD>
45FileWriteAccessor<TFD>::FileWriteAccessor(TFD&& fd, ReleaseDescriptorCallback release_callback, UniqueLock lock)
46 : FileAccessor<TFD>(std::move(fd), release_callback), m_unique_lock(std::move(lock)) {}
47
48template <typename TFD>
49FileWriteAccessor<TFD>::~FileWriteAccessor<TFD>() {
50 FileAccessor<TFD>::m_release_callback(std::move(FileAccessor<TFD>::m_fd));
51}
52
53template <typename TFD>
54bool FileWriteAccessor<TFD>::isReadOnly() const {
55 return false;
56}
57
58} // namespace FilePool
59} // namespace Euclid
60
61#endif