RTC Toolkit  0.1.0-alpha
Public Member Functions | List of all members
rtctk::componentFramework::FileRepository Class Reference

#include <fileRepository.hpp>

Inheritance diagram for rtctk::componentFramework::FileRepository:
rtctk::componentFramework::RepositoryIf MockOldb rtctk::componentFramework::FakeOldbAdapter rtctk::componentFramework::FakeRuntimeRepoAdapter

Public Member Functions

 FileRepository ()=delete
 
 FileRepository (const FileRepository &)=delete
 
FileRepositoryoperator= (const FileRepository &)=delete
 
 FileRepository (FileRepository &&)=default
 
FileRepositoryoperator= (FileRepository &&)=default
 
 FileRepository (const ::elt::mal::Uri &datauri, const int dirdepth)
 
virtual ~FileRepository ()
 
void CreateDataPoint (const DataPointPath &path, const std::string &type) override
 Creates a new datapoint in the repository with a specified type. More...
 
void DeleteDataPoint (const DataPointPath &path) override
 Deletes a datapoint. More...
 
std::string GetDataPointType (const DataPointPath &path) const override
 Fetches the type of the datapoint. More...
 
size_t GetDataPointSize (const DataPointPath &path) const override
 Fetches the size of the datapoint's data. More...
 
bool DataPointExists (const DataPointPath &path) const override
 Checks for the existence of a datapoint in the repository. More...
 
std::pair< StringList, StringListGetChildren (const DataPointPath &path) const override
 Queries the datapoints and child paths for a given path. More...
 
Response SendReadRequest (const Request &request) const override
 Sends a request to read data from the repository. More...
 
Response SendWriteRequest (const Request &request) override
 Sends a request to write data to the repository. More...
 
size_t get_fits_write_threshold () const
 
void set_fits_write_threshold (size_t value)
 
virtual void CreateDataPoint (const DataPointPath &path, const std::string &type)=0
 Creates a new datapoint in the repository with a specified type. More...
 
virtual void DeleteDataPoint (const DataPointPath &path)=0
 Deletes a datapoint. More...
 
virtual std::string GetDataPointType (const DataPointPath &path) const=0
 Fetches the type of the datapoint. More...
 
virtual size_t GetDataPointSize (const DataPointPath &path) const=0
 Fetches the size of the datapoint's data. More...
 
virtual bool DataPointExists (const DataPointPath &path) const=0
 Checks for the existence of a datapoint in the repository. More...
 
virtual std::pair< StringList, StringListGetChildren (const DataPointPath &path) const=0
 Queries the datapoints and child paths for a given path. More...
 
- Public Member Functions inherited from rtctk::componentFramework::RepositoryIf
virtual ~RepositoryIf ()
 
template<typename T >
void CreateDataPointV2 (const DataPointPath &path)
 Creates a new datapoint in the repository. More...
 
template<typename T >
void CreateDataPointV2 (const DataPointPath &path, const T default_value)
 Creates a new datapoint in the repository and sets a default value. More...
 
template<typename T >
GetDataPoint (const DataPointPath &path) const
 Fetches a datapoint from the repository. More...
 
template<typename T >
void SetDataPoint (const DataPointPath &path, const T value)
 Sets a datapoint in the repository. More...
 
template<typename T >
void ReadDataPoint (const DataPointPath &path, T &buffer) const
 Reads a datapoint from the repository. More...
 
template<typename T >
void WriteDataPoint (const DataPointPath &path, const T &buffer)
 Writes a datapoint to the repository. More...
 
void WriteDataPoint (const DataPointPath &path, const char *buffer)
 
template<>
void CreateDataPointV2 (const DataPointPath &path, const char *default_value)
 
template<>
void SetDataPoint (const DataPointPath &path, const char *value)
 

Additional Inherited Members

- Public Types inherited from rtctk::componentFramework::RepositoryIf
using StringList = std::vector< std::string >
 

Constructor & Destructor Documentation

◆ FileRepository() [1/4]

rtctk::componentFramework::FileRepository::FileRepository ( )
delete

◆ FileRepository() [2/4]

rtctk::componentFramework::FileRepository::FileRepository ( const FileRepository )
delete

◆ FileRepository() [3/4]

rtctk::componentFramework::FileRepository::FileRepository ( FileRepository &&  )
default

◆ FileRepository() [4/4]

rtctk::componentFramework::FileRepository::FileRepository ( const ::elt::mal::Uri &  datauri,
const int  dirdepth 
)
explicit

◆ ~FileRepository()

rtctk::componentFramework::FileRepository::~FileRepository ( )
virtual

Member Function Documentation

◆ CreateDataPoint() [1/2]

void rtctk::componentFramework::FileRepository::CreateDataPoint ( const DataPointPath path,
const std::string &  type 
)
overridevirtual

Creates a new datapoint in the repository with a specified type.

Parameters
[in]pathThe datapoint path that should be created.
[in]typeA string indicating the type of the new datapoint. Valid values are indicated below.

The following are the supported values for the type string:

  • RtcBool
  • RtcInt32
  • RtcInt64
  • RtcFloat
  • RtcDouble
  • RtcString
  • RtcVectorBool
  • RtcVectorInt32
  • RtcVectorInt64
  • RtcVectorFloat
  • RtcVectorDouble
  • RtcVectorString
  • RtcMatrixBool
  • RtcMatrixInt32
  • RtcMatrixInt64
  • RtcMatrixFloat
  • RtcMatrixDouble
  • RtcMatrixString

Implements rtctk::componentFramework::RepositoryIf.

◆ CreateDataPoint() [2/2]

virtual void rtctk::componentFramework::RepositoryIf::CreateDataPoint

Creates a new datapoint in the repository with a specified type.

Parameters
[in]pathThe datapoint path that should be created.
[in]typeA string indicating the type of the new datapoint. Valid values are indicated below.

The following are the supported values for the type string:

  • RtcBool
  • RtcInt32
  • RtcInt64
  • RtcFloat
  • RtcDouble
  • RtcString
  • RtcVectorBool
  • RtcVectorInt32
  • RtcVectorInt64
  • RtcVectorFloat
  • RtcVectorDouble
  • RtcVectorString
  • RtcMatrixBool
  • RtcMatrixInt32
  • RtcMatrixInt64
  • RtcMatrixFloat
  • RtcMatrixDouble
  • RtcMatrixString

◆ DataPointExists() [1/2]

bool rtctk::componentFramework::FileRepository::DataPointExists ( const DataPointPath path) const
overridevirtual

Checks for the existence of a datapoint in the repository.

Parameters
[in]pathThe datapoint path to check.
Returns
true if the datapoint path exists in the repository and false otherwise.

Implements rtctk::componentFramework::RepositoryIf.

◆ DataPointExists() [2/2]

virtual bool rtctk::componentFramework::RepositoryIf::DataPointExists

Checks for the existence of a datapoint in the repository.

Parameters
[in]pathThe datapoint path to check.
Returns
true if the datapoint path exists in the repository and false otherwise.

◆ DeleteDataPoint() [1/2]

void rtctk::componentFramework::FileRepository::DeleteDataPoint ( const DataPointPath path)
overridevirtual

Deletes a datapoint.

Parameters
[in]pathThe path of the datapoint to delete in the repository.

Implements rtctk::componentFramework::RepositoryIf.

◆ DeleteDataPoint() [2/2]

virtual void rtctk::componentFramework::RepositoryIf::DeleteDataPoint

Deletes a datapoint.

Parameters
[in]pathThe path of the datapoint to delete in the repository.

◆ get_fits_write_threshold()

size_t rtctk::componentFramework::FileRepository::get_fits_write_threshold ( ) const
inline
Returns
The number of matrix or vector elements above which numerical matrices and vectors are stored in FITS files rather than the YAML file.

◆ GetChildren() [1/2]

std::pair< FileRepository::StringList, FileRepository::StringList > rtctk::componentFramework::FileRepository::GetChildren ( const DataPointPath path) const
overridevirtual

Queries the datapoints and child paths for a given path.

This method will query all the available datapoints that are leaf nodes immediately below the given path and also the child paths, i.e. sub-folders when interpreting the repository as a hierarchical folder like structure. The set of immediate datapoint and child paths is returned as two separate lists.

If an error occurs when querying the the repository a std::runtime_error is thrown.

Parameters
[in]pathThe path in which to search for datapoints and child paths.
Returns
A std::pair or string lists, i.e. std::vector<std::string>, with the first list in the pair containing the datapoints found and the second list containing the child paths found. If no datapoints are found then the list for datapoints is empty. Similarly if not child paths are found then the child path list is empty.

Implements rtctk::componentFramework::RepositoryIf.

◆ GetChildren() [2/2]

virtual std::pair<StringList, StringList> rtctk::componentFramework::RepositoryIf::GetChildren

Queries the datapoints and child paths for a given path.

This method will query all the available datapoints that are leaf nodes immediately below the given path and also the child paths, i.e. sub-folders when interpreting the repository as a hierarchical folder like structure. The set of immediate datapoint and child paths is returned as two separate lists.

If an error occurs when querying the the repository a std::runtime_error is thrown.

Parameters
[in]pathThe path in which to search for datapoints and child paths.
Returns
A std::pair or string lists, i.e. std::vector<std::string>, with the first list in the pair containing the datapoints found and the second list containing the child paths found. If no datapoints are found then the list for datapoints is empty. Similarly if not child paths are found then the child path list is empty.

◆ GetDataPointSize() [1/2]

size_t rtctk::componentFramework::FileRepository::GetDataPointSize ( const DataPointPath path) const
overridevirtual

Fetches the size of the datapoint's data.

This method will return one of the following values depending on the category of the datapoint's type:

Scalars
Will always return 1 for scalars such as RtcBool, RtcInt32, RtcInt64, RtcFloat, and RtcDouble.
Strings
Will return the length of the string, i.e. the number of characters in the string.
Vectors
Will return the number of elements in the vector.
Matrices
Will return the total number of elements in the matrix, i.e. the number of rows times the number of columns.
Returns
The number of elements in the datapoint's data.

Implements rtctk::componentFramework::RepositoryIf.

◆ GetDataPointSize() [2/2]

virtual size_t rtctk::componentFramework::RepositoryIf::GetDataPointSize

Fetches the size of the datapoint's data.

This method will return one of the following values depending on the category of the datapoint's type:

Scalars
Will always return 1 for scalars such as RtcBool, RtcInt32, RtcInt64, RtcFloat, and RtcDouble.
Strings
Will return the length of the string, i.e. the number of characters in the string.
Vectors
Will return the number of elements in the vector.
Matrices
Will return the total number of elements in the matrix, i.e. the number of rows times the number of columns.
Returns
The number of elements in the datapoint's data.

◆ GetDataPointType() [1/2]

std::string rtctk::componentFramework::FileRepository::GetDataPointType ( const DataPointPath path) const
overridevirtual

Fetches the type of the datapoint.

This will return the type used when the datapoint was created with the CreateDataPoint method. If the CreateDataPointV2 method was used instead then this returns the type string that was inferred by that method.

Returns
The type of the datapoint as a string, i.e. the type as is encoded in the underlying YAML file.

Implements rtctk::componentFramework::RepositoryIf.

◆ GetDataPointType() [2/2]

virtual std::string rtctk::componentFramework::RepositoryIf::GetDataPointType

Fetches the type of the datapoint.

This will return the type used when the datapoint was created with the CreateDataPoint method. If the CreateDataPointV2 method was used instead then this returns the type string that was inferred by that method.

Returns
The type of the datapoint as a string, i.e. the type as is encoded in the underlying YAML file.

◆ operator=() [1/2]

FileRepository& rtctk::componentFramework::FileRepository::operator= ( const FileRepository )
delete

◆ operator=() [2/2]

FileRepository& rtctk::componentFramework::FileRepository::operator= ( FileRepository &&  )
default

◆ SendReadRequest()

Response rtctk::componentFramework::FileRepository::SendReadRequest ( const Request request) const
overridevirtual

Sends a request to read data from the repository.

This method allows non-blocking and asynchronous reading of datapoints form the repository. The method returns immediately, allowing other work to be done in the calling thread while the read request is completed in the background. If any callback handlers were registered in request, they will be called as soon as the data is available for the respective datapoint.

Note
The buffers for the datapoints added to request must not be accessed until the Wait method of the response object returns successfully, i.e. without a timeout.

If an error occurs then a std::runtime_error is thrown.

Note
This method is not transactional or fully atomic. If an error occurs while reading the datapoints, some or all of the datapoint buffers registered with the read request may be left unmodified. It is however guaranteed that any particular datapoint buffer is either updated completely or not modified at all.
Parameters
[in]requestThe request object that contains all the datapoints to read.
Returns
A response object that must be used to synchronise with the completion of the read request.

Implements rtctk::componentFramework::RepositoryIf.

◆ SendWriteRequest()

Response rtctk::componentFramework::FileRepository::SendWriteRequest ( const Request request)
overridevirtual

Sends a request to write data to the repository.

This method allows non-blocking writing of datapoints to the repository. The method returns immediately, allowing other work to be done in the calling thread while the write request is completed in the background. If any callback handlers were registered in request, they will be called as soon as the respective datapoint's data has been sent and the buffer will no longer be accessed by the API, i.e. the caller can modify or release the buffer from that point on.

Note
The buffers for the datapoints added to request must not be modified or released until the Wait method of the response object returns successfully, i.e. without a timeout.

If an error occurs then a std::runtime_error is thrown.

Note
This method is not transactional or fully atomic. If an error occurs while writing the datapoints, only some of the datapoints registered with the write request may be actually updated in the repository. It is however guaranteed that any particular datapoint is either updated completely in the repository or not at all.
Parameters
[in]requestThe request object that contains all the datapoints to write.
Returns
A response object that must be used to synchronise with the completion of the write request.

Implements rtctk::componentFramework::RepositoryIf.

◆ set_fits_write_threshold()

void rtctk::componentFramework::FileRepository::set_fits_write_threshold ( size_t  value)
inline

Sets the threshold for storing numerical matrices and vectors in FITS files rather than the YAML file.

Parameters
[in]valueThe minimum number of elements a matrix/vector must have to store it to a FITS files. If this is set to zero then matrices and vectors are always stored in FITS files.

The documentation for this class was generated from the following files: