13#ifndef RTCTK_COMPONENTFRAMEWORK_FILEREPOSITORY_HPP
14#define RTCTK_COMPONENTFRAMEWORK_FILEREPOSITORY_HPP
21#include <boost/filesystem.hpp>
22#include <mal/utility/Uri.hpp>
93 explicit FileRepository(
const elt::mal::Uri& datauri,
const int dirdepth);
115 std::scoped_lock lck(m_mutex);
116 return m_fits_write_threshold;
130 std::scoped_lock lck(m_mutex);
131 m_fits_write_threshold = value;
175 template <
typename R,
typename F>
176 Response ProcessRequest(
const R& request, F selector)
const;
186 template <
typename T>
187 void ReadData(
const DataPointPath& path, T& buffer,
const std::string& typestr)
const;
197 template <
typename T>
198 void WriteData(
const DataPointPath& path,
const T& buffer,
const std::string& typestr)
const;
201 struct IoFunctionMapEntry {
204 using WriteFunction =
207 ReadFunction m_read_function;
208 WriteFunction m_write_function;
212 using IoFunctionMap = std::map<std::type_index, IoFunctionMapEntry>;
222 template <
typename T>
223 static auto MakeMapEntry(
const std::string& typestr);
231 mutable std::mutex m_mutex;
232 boost::filesystem::path m_datapath;
233 std::string m_defaultfile;
235 size_t m_fits_write_threshold;
238 static const IoFunctionMap S_IO_FUNCTIONS;
This class provides a wrapper for a data point path.
Definition: dataPointPath.hpp:73
Definition: fileRepository.hpp:60
Implements a file based repository that stores datapoints in local YAML and FITS files.
Definition: fileRepository.hpp:88
size_t GetDataPointSize(const DataPointPath &path) const override
Fetches the size of the datapoint's data.
Definition: fileRepository.cpp:1009
FileRepository(const FileRepository &)=delete
const std::type_info & GetDataPointType(const DataPointPath &path) const override
Fetches the type of the datapoint.
Definition: fileRepository.cpp:973
void SetFitsWriteThreshold(size_t value)
Sets the threshold for storing numerical matrices and vectors in FITS files rather than the YAML file...
Definition: fileRepository.hpp:129
size_t GetFitsWriteThreshold() const
Definition: fileRepository.hpp:114
std::pair< PathList, PathList > GetChildren(const DataPointPath &path) const override
Queries the datapoints and child paths for a given path.
Definition: fileRepository.cpp:1191
FileRepository & operator=(const FileRepository &)=delete
bool DataPointExists(const DataPointPath &path) const override
Checks for the existence of a datapoint in the repository.
Definition: fileRepository.cpp:1103
std::string GetServerAlias(const DataPointPath &path) const
Fetches the server alias string encoded for a datapoint.
Definition: fileRepository.cpp:1259
virtual ~FileRepository() noexcept=default
Response SendReadRequest(const ReadRequest &request) const override
Sends a request to read data from the repository.
Definition: fileRepository.cpp:1232
Response SendWriteRequest(const WriteRequest &request) override
Sends a request to write data to the repository.
Definition: fileRepository.cpp:1236
void SetServerAlias(const DataPointPath &path, const std::string &server_alias)
Encodes the server alias string for a datapoint.
Definition: fileRepository.cpp:1273
void CreateDataPoint(const DataPointPath &path, const std::type_info &type) override
Creates a new datapoint in the repository with a specified type.
Definition: fileRepository.cpp:871
void DeleteDataPoint(const DataPointPath &path) override
Deletes a datapoint.
Definition: fileRepository.cpp:929
Definition: fileRepository.hpp:51
Definition: fileRepository.hpp:33
A request object to pass information about datapoints that should be read from the repository.
Definition: repositoryIf.hpp:49
An object used to wait for a request to complete.
Definition: repositoryIf.hpp:197
A request object to pass information about datapoints that should be written to the repository.
Definition: repositoryIf.hpp:122
Abstract interface providing basic read and write facilities to a repository.
Definition: repositoryIf.hpp:38
std::vector< DataPointPath > PathList
Definition: repositoryIf.hpp:40
The RtctkException class is the base class for all Rtctk exceptions.
Definition: exceptions.hpp:237
Provides macros and utilities for exception handling.
Definition: commandReplier.cpp:22
Header file for RepositoryIf and related base classes.