RTC Toolkit 6.0.0
Loading...
Searching...
No Matches
rtctk::componentFramework::test::FakeRepository Class Reference

Implementation of an in-memory fake repository for testing. More...

#include <rtctk/componentFramework/test/fakeRepository.hpp>

Inheritance diagram for rtctk::componentFramework::test::FakeRepository:
rtctk::componentFramework::RepositoryIf rtctk::componentFramework::test::FakePersistentRepoIf rtctk::componentFramework::test::FakeRepositorySubscriber rtctk::componentFramework::test::MockRepository rtctk::componentFramework::test::FakeOldbIf rtctk::componentFramework::test::FakeRuntimeRepoIf rtctk::componentFramework::test::MockRuntimeRepoIf rtctk::componentFramework::test::MockPersistentRepoIf

Classes

struct  Data
 

Public Member Functions

 FakeRepository ()
 
 ~FakeRepository () override=default
 
template<typename T>
Lut::TableEntries BindTypeHandlers ()
 
- Public Member Functions inherited from rtctk::componentFramework::RepositoryIf
 RepositoryIf ()=default
 
virtual ~RepositoryIf ()=default
 
BatchResponse SendRequest (const BatchRequest &request)
 
BatchResponse SendRequest (const BatchRequest &request) const
 
template<typename T>
void CreateDataPoint (const DataPointPath &path)
 Creates a new empty datapoint in the repository.
 
template<typename T>
void CreateDataPoint (const DataPointPath &path, const T &initial_value)
 Creates a new datapoint in the repository with an initial value.
 
void CreateDataPoint (const DataPointPath &path, const char *initial_value)
 
void DeleteDataPoint (const DataPointPath &path, bool recurse=false)
 Deletes a datapoint.
 
const std::type_info & GetDataPointType (const DataPointPath &path) const
 Fetches the type of the datapoint.
 
size_t GetDataPointSize (const DataPointPath &path) const
 Fetches the size of the datapoint's data.
 
RtcVectorUInt64 GetDataPointShape (const DataPointPath &path) const
 Fetches the shape of the datapoint's data.
 
bool DataPointExists (const DataPointPath &path) const
 Checks for the existence of a datapoint in the repository.
 
std::pair< PathList, PathListGetChildren (const DataPointPath &path, bool recurse=false) const
 Queries the child datapoints and paths for a given parent path.
 
template<typename T>
GetDataPoint (const DataPointPath &path) const
 Fetches a datapoint from the repository.
 
template<typename T>
std::optional< T > TryGetDataPoint (const DataPointPath &path) const
 Fetches a datapoint from the repository.
 
template<typename T>
void SetDataPoint (const DataPointPath &path, const T &value)
 Sets a datapoint in the repository.
 
void SetDataPoint (const DataPointPath &path, const char *value)
 
template<typename T>
void ReadDataPoint (const DataPointPath &path, T &buffer) const
 Reads a datapoint from the repository.
 
template<typename T>
void WriteDataPoint (const DataPointPath &path, const T &buffer)
 Writes a datapoint to the repository.
 
void WriteDataPoint (const DataPointPath &path, const char *buffer)
 
template<typename... T>
void WriteDataPoints (const T &... args)
 
template<typename... T>
void ReadDataPoints (T &... args) const
 

Protected Member Functions

template<typename T>
void CreateImpl (detail::CreateRequest< T > &req)
 
template<typename T>
void ReadImpl (detail::ReadRequest< T > &req)
 
template<typename T>
void WriteImpl (detail::WriteRequest< T > &req)
 
template<typename T>
void PartialReadImpl (detail::PartialReadRequest< T > &req)
 
template<typename T>
void PartialWriteImpl (detail::PartialWriteRequest< T > &req)
 
void ReadMetaDataImpl (detail::ReadMetaDataRequest &req)
 
void WriteMetaDataImpl (detail::WriteMetaDataRequest &req)
 
void DeleteImpl (detail::DeleteRequest &req)
 
void ExistsImpl (detail::ExistsRequest &req)
 
std::pair< PathList, PathListGetChildrenImpl (const DataPointPath &path)
 
std::pair< PathList, PathListGetChildrenRecursive (const DataPointPath &path)
 
void GetChildrenImpl (detail::GetChildrenRequest &req)
 
void CreateLinkImpl (detail::CreateSymlinkRequest &req)
 
void UpdateLinkImpl (detail::UpdateSymlinkRequest &req)
 
template<typename Request>
void InvokeCallback (const Request &req) const
 
template<typename T>
void ReadData (Data &data_node, const DataPointPath &path, gsl::span< T > &data, std::optional< std::reference_wrapper< MetaData > > &metadata, size_t offset)
 
template<typename T>
void WriteData (const DataPointPath &path, const gsl::span< const T > &data, const MetaData &metadata, std::optional< std::reference_wrapper< MetaData > >, size_t offset)
 
void ReadMetaData (const DataPointPath &path, MetaData &metadata, bool check_sequence_id=false)
 
void WriteMetaData (Data &data_node, const MetaData &metadata)
 
DataPointPath ResolvePath (const DataPointPath &path)
 
DataCreateNewDataNode (const DataPointPath &path)
 
virtual DataGetDataNode (const DataPointPath &path)
 
std::optional< std::reference_wrapper< FakeRepository::Data > > GetDataNodeNoThrow (const DataPointPath &path)
 
void CheckDataNodeExists (const DataPointPath &path)
 
virtual void InvokeRequestHandler (std::any &request)
 
BatchResponse ProcessRequests (const RequestList &requests) override
 
bool RequestsToFailContains (size_t index) const
 

Static Protected Member Functions

template<typename T>
static RequestDispatcher< FakeRepository >::TableEntries BindTypeHandlers ()
 

Protected Attributes

std::mutex m_mutex
 Mutex for synchronising access to m_data.
 
std::map< DataPointPath, Datam_data
 
DynamicThreadPool m_thread_pool {"repo_worker"}
 
Data m_requests_to_fail
 Stores a vector of integer indices indicating which requests to forcefully fail in a batch request.
 
Data m_requests_to_skip
 Stores a vector of integer indices indicating which requests to skip in a batch request.
 

Static Protected Attributes

static const RequestDispatcher< FakeRepositoryS_REQUEST_DISPATCHER
 

Additional Inherited Members

- Public Types inherited from rtctk::componentFramework::RepositoryIf
using PathList = std::vector<DataPointPath>
 
using Clock = taiclock::TaiClock
 
using Timestamp = Clock::time_point
 
using CallbackType = std::function<void(const DataPointPath&)>
 Signature of the callback functions that can be registered with the repository requests.
 
- Static Public Member Functions inherited from rtctk::componentFramework::RepositoryIf
static const std::type_info & StringToType (const std::string &arg)
 Converts an RTC datapoint type string to a type_info.
 
static std::string TypeToString (const std::type_info &arg)
 Converts a type_info to an RTC datapoint type string.
 
static std::any MakeAnyBuffer (const MetaData &metadata)
 Helper method to create an std::any buffer compatible with a specific datapoint.
 
- Protected Types inherited from rtctk::componentFramework::RepositoryIf
using RequestList = std::vector<std::any>
 

Detailed Description

Implementation of an in-memory fake repository for testing.

Constructor & Destructor Documentation

◆ FakeRepository()

rtctk::componentFramework::test::FakeRepository::FakeRepository ( )

◆ ~FakeRepository()

rtctk::componentFramework::test::FakeRepository::~FakeRepository ( )
overridedefault

Member Function Documentation

◆ BindTypeHandlers() [1/2]

template<typename T>
Lut::TableEntries rtctk::componentFramework::test::FakeRepository::BindTypeHandlers ( )

◆ BindTypeHandlers() [2/2]

template<typename T>
static RequestDispatcher< FakeRepository >::TableEntries rtctk::componentFramework::test::FakeRepository::BindTypeHandlers ( )
staticprotected

◆ CheckDataNodeExists()

void rtctk::componentFramework::test::FakeRepository::CheckDataNodeExists ( const DataPointPath & path)
protected

◆ CreateImpl()

template<typename T>
void rtctk::componentFramework::test::FakeRepository::CreateImpl ( detail::CreateRequest< T > & req)
protected

◆ CreateLinkImpl()

void rtctk::componentFramework::test::FakeRepository::CreateLinkImpl ( detail::CreateSymlinkRequest & req)
protected

◆ CreateNewDataNode()

FakeRepository::Data & rtctk::componentFramework::test::FakeRepository::CreateNewDataNode ( const DataPointPath & path)
protected

◆ DeleteImpl()

void rtctk::componentFramework::test::FakeRepository::DeleteImpl ( detail::DeleteRequest & req)
protected

◆ ExistsImpl()

void rtctk::componentFramework::test::FakeRepository::ExistsImpl ( detail::ExistsRequest & req)
protected

◆ GetChildrenImpl() [1/2]

auto rtctk::componentFramework::test::FakeRepository::GetChildrenImpl ( const DataPointPath & path)
protected

◆ GetChildrenImpl() [2/2]

void rtctk::componentFramework::test::FakeRepository::GetChildrenImpl ( detail::GetChildrenRequest & req)
protected

◆ GetChildrenRecursive()

auto rtctk::componentFramework::test::FakeRepository::GetChildrenRecursive ( const DataPointPath & path)
protected

◆ GetDataNode()

FakeRepository::Data & rtctk::componentFramework::test::FakeRepository::GetDataNode ( const DataPointPath & path)
protectedvirtual

◆ GetDataNodeNoThrow()

std::optional< std::reference_wrapper< FakeRepository::Data > > rtctk::componentFramework::test::FakeRepository::GetDataNodeNoThrow ( const DataPointPath & path)
protected

◆ InvokeCallback()

template<typename Request>
void rtctk::componentFramework::test::FakeRepository::InvokeCallback ( const Request & req) const
protected

◆ InvokeRequestHandler()

void rtctk::componentFramework::test::FakeRepository::InvokeRequestHandler ( std::any & request)
protectedvirtual

◆ PartialReadImpl()

template<typename T>
void rtctk::componentFramework::test::FakeRepository::PartialReadImpl ( detail::PartialReadRequest< T > & req)
protected

◆ PartialWriteImpl()

template<typename T>
void rtctk::componentFramework::test::FakeRepository::PartialWriteImpl ( detail::PartialWriteRequest< T > & req)
protected

◆ ProcessRequests()

RepositoryIf::BatchResponse rtctk::componentFramework::test::FakeRepository::ProcessRequests ( const RequestList & requests)
overrideprotectedvirtual

◆ ReadData()

template<typename T>
void rtctk::componentFramework::test::FakeRepository::ReadData ( Data & data_node,
const DataPointPath & path,
gsl::span< T > & data,
std::optional< std::reference_wrapper< MetaData > > & metadata,
size_t offset )
protected

◆ ReadImpl()

template<typename T>
void rtctk::componentFramework::test::FakeRepository::ReadImpl ( detail::ReadRequest< T > & req)
protected

◆ ReadMetaData()

void rtctk::componentFramework::test::FakeRepository::ReadMetaData ( const DataPointPath & path,
MetaData & metadata,
bool check_sequence_id = false )
protected

◆ ReadMetaDataImpl()

void rtctk::componentFramework::test::FakeRepository::ReadMetaDataImpl ( detail::ReadMetaDataRequest & req)
protected

◆ RequestsToFailContains()

bool rtctk::componentFramework::test::FakeRepository::RequestsToFailContains ( size_t index) const
protected

◆ ResolvePath()

DataPointPath rtctk::componentFramework::test::FakeRepository::ResolvePath ( const DataPointPath & path)
protected

◆ UpdateLinkImpl()

void rtctk::componentFramework::test::FakeRepository::UpdateLinkImpl ( detail::UpdateSymlinkRequest & req)
protected

◆ WriteData()

template<typename T>
void rtctk::componentFramework::test::FakeRepository::WriteData ( const DataPointPath & path,
const gsl::span< const T > & data,
const MetaData & metadata,
std::optional< std::reference_wrapper< MetaData > > output_metadata,
size_t offset )
protected

◆ WriteImpl()

template<typename T>
void rtctk::componentFramework::test::FakeRepository::WriteImpl ( detail::WriteRequest< T > & req)
protected

◆ WriteMetaData()

void rtctk::componentFramework::test::FakeRepository::WriteMetaData ( Data & data_node,
const MetaData & metadata )
protected

◆ WriteMetaDataImpl()

void rtctk::componentFramework::test::FakeRepository::WriteMetaDataImpl ( detail::WriteMetaDataRequest & req)
protected

Member Data Documentation

◆ m_data

std::map<DataPointPath, Data> rtctk::componentFramework::test::FakeRepository::m_data
protected

◆ m_mutex

std::mutex rtctk::componentFramework::test::FakeRepository::m_mutex
mutableprotected

Mutex for synchronising access to m_data.

◆ m_requests_to_fail

Data rtctk::componentFramework::test::FakeRepository::m_requests_to_fail
protected

Stores a vector of integer indices indicating which requests to forcefully fail in a batch request.

This value is accessed by reading/writing to the path /__internal__/requests_to_fail.

◆ m_requests_to_skip

Data rtctk::componentFramework::test::FakeRepository::m_requests_to_skip
protected

Stores a vector of integer indices indicating which requests to skip in a batch request.

This value is accessed by reading/writing to the path /__internal__/requests_to_skip.

◆ m_thread_pool

DynamicThreadPool rtctk::componentFramework::test::FakeRepository::m_thread_pool {"repo_worker"}
protected

◆ S_REQUEST_DISPATCHER

const Lut rtctk::componentFramework::test::FakeRepository::S_REQUEST_DISPATCHER
staticprotected
Initial value:
static TableEntries Bind(void(FakeRepository::*method)(T &, Args...))
Definition requestDispatcher.hpp:66
void DeleteImpl(detail::DeleteRequest &req)
Definition fakeRepository.cpp:219
void WriteMetaDataImpl(detail::WriteMetaDataRequest &req)
Definition fakeRepository.cpp:208
void CreateLinkImpl(detail::CreateSymlinkRequest &req)
Definition fakeRepository.cpp:319
void UpdateLinkImpl(detail::UpdateSymlinkRequest &req)
Definition fakeRepository.cpp:332
void ExistsImpl(detail::ExistsRequest &req)
Definition fakeRepository.cpp:231
std::pair< PathList, PathList > GetChildrenImpl(const DataPointPath &path)
Definition fakeRepository.cpp:239
void ReadMetaDataImpl(detail::ReadMetaDataRequest &req)
Definition fakeRepository.cpp:200
static RequestDispatcher< FakeRepository >::TableEntries BindTypeHandlers()

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