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

A file based OLDB adapter that simulates OLDB with a local YAML file. More...

#include <fakeOldbAdapter.hpp>

Inheritance diagram for rtctk::componentFramework::FakeOldbAdapter:
rtctk::componentFramework::FileRepository rtctk::componentFramework::OldbApiIf rtctk::componentFramework::RepositoryIf rtctk::componentFramework::RepositoryIf

Public Member Functions

 FakeOldbAdapter ()=delete
 Do not allow construction with no arguments. More...
 
 FakeOldbAdapter (const FakeOldbAdapter &)=delete
 This class cannot be copy constructed. More...
 
FakeOldbAdapteroperator= (const FakeOldbAdapter &)=delete
 This class cannot be copy assigned. More...
 
 FakeOldbAdapter (FakeOldbAdapter &&)=default
 The move constructor. More...
 
FakeOldbAdapteroperator= (FakeOldbAdapter &&)=default
 The move assignment operator. More...
 
 FakeOldbAdapter (const ::elt::mal::Uri &datauri)
 
virtual ~FakeOldbAdapter ()
 
- Public Member Functions inherited from rtctk::componentFramework::FileRepository
 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)
 
- Public Member Functions inherited from rtctk::componentFramework::OldbApiIf
virtual ~OldbApiIf ()
 

Additional Inherited Members

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

Detailed Description

A file based OLDB adapter that simulates OLDB with a local YAML file.

This class is used to simulate access to OLDB when it is not feasible to provide a full working OLDB and access it through OldbAdapter. Its use should be restricted to development and certain integration testing, since it is not written with scalability and performance in mind.

The data is stored to and read from a local YAML file, who's location is given as a file scheme URI. The YAML file format uses nested dictionaries to represent the hierarchical tree structure that corresponds to the datapoint paths. For example, if we have 3 datapoints, an integer with a path of "topdir/subdir/dp1", a floating point with a path of "topdir/subdir/dp2" and a string with a path of "topdir/dp3", this would correspond to the following YAML:

topdir:
subdir:
dp1:
type: RtcInt32
value: 123
dp2:
type: RtcFloat
value: 4.5
dp3:
type: RtcString
value: "somevalue"

As can be seen in the above example YAML, each datapoint has the fundamental data type stored under the type field and its value is found under the value field.

The allowed values for type are one of the following:

Note that vectors and matrices are both stored as lists in the YAML format. However, matrices will have the additional fields nrows and ncols set. For example:

topdir:
matrix_datapoint:
type: RtcMatrixFloat
nrows: 2
ncols: 3
value: [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]

File based locking is used to make all read/write methods synchronous between all processes and threads.

Constructor & Destructor Documentation

◆ FakeOldbAdapter() [1/4]

rtctk::componentFramework::FakeOldbAdapter::FakeOldbAdapter ( )
delete

Do not allow construction with no arguments.

◆ FakeOldbAdapter() [2/4]

rtctk::componentFramework::FakeOldbAdapter::FakeOldbAdapter ( const FakeOldbAdapter )
delete

This class cannot be copy constructed.

◆ FakeOldbAdapter() [3/4]

rtctk::componentFramework::FakeOldbAdapter::FakeOldbAdapter ( FakeOldbAdapter &&  )
default

The move constructor.

◆ FakeOldbAdapter() [4/4]

rtctk::componentFramework::FakeOldbAdapter::FakeOldbAdapter ( const ::elt::mal::Uri &  datauri)
explicit

Constructs a file based OLDB.

Parameters
[in]datauriThe URI to the YAML file that will store the datapoints. This only accepts file scheme URIs on the local file system.
Note
If the YAML file does not yet exist, it will only be created on the first call to RepositoryIf::CreateDataPoint or RepositoryIf::CreateDataPointV2.

◆ ~FakeOldbAdapter()

rtctk::componentFramework::FakeOldbAdapter::~FakeOldbAdapter ( )
virtual

Destroys the file based OLDB.

Note
The YAML file will not be deleted by destroying the FakeOldbAdapter object.

Member Function Documentation

◆ operator=() [1/2]

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

This class cannot be copy assigned.

◆ operator=() [2/2]

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

The move assignment operator.


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