RTC Toolkit  2.0.0
Classes | Public Member Functions | Static Public Member Functions | List of all members
rtctk::componentFramework::PathMapper Class Reference

Used to calculate URIs from datapoint paths. More...

#include <pathMapper.hpp>

Classes

struct  FilePathResult
 Result object returned by the PathToFile method. More...
 
struct  UriResult
 Result object returned by the PathToUri method. More...
 

Public Member Functions

 PathMapper (const elt::mal::Uri &baseuri, bool simple_layout=false)
 Constructs the mapper object with base URI and format flag. More...
 
const elt::mal::Uri & GetBaseUri () const
 
const std::filesystem::path & GetBasePath () const
 Get the base path for the repository. More...
 
bool GetSimpleLayout () const
 
void SetSimpleLayout (bool simple_layout)
 Sets the flag that indicates if the simple repository layout should be used. More...
 
UriResult PathToUri (const DataPointPath &path) const
 Maps a datapoint path to the corresponding URI. More...
 
FilePathResult PathToFile (const DataPointPath &path) const
 Maps a datapoint path to the corresponding local filesystem path. More...
 

Static Public Member Functions

static std::vector< std::string > SplitPathComponents (const DataPointPath &path)
 Splits the datapoint path into a list of individual path components. More...
 

Detailed Description

Used to calculate URIs from datapoint paths.

This class is used to map datapoint paths to full URIs that can be used with the CII configuration service by PersistentRepoAdapter.

Constructor & Destructor Documentation

◆ PathMapper()

rtctk::componentFramework::PathMapper::PathMapper ( const elt::mal::Uri &  baseuri,
bool  simple_layout = false 
)

Constructs the mapper object with base URI and format flag.

Parameters
[in]baseuriThe base URI of the repository being mapped.
[in]simple_layoutA boolean flag indicating if the repository is using a simple layout or not. The simple repository layout means that no deployment sets are present and the repository represents a 1-to-1 copy of the Runtime Configuration Repository.

Member Function Documentation

◆ GetBasePath()

const std::filesystem::path& rtctk::componentFramework::PathMapper::GetBasePath ( ) const
inline

Get the base path for the repository.

Returns
The path component (interpreted as a filesystem path) of the base URI originally given to the constructor.

◆ GetBaseUri()

const elt::mal::Uri& rtctk::componentFramework::PathMapper::GetBaseUri ( ) const
inline
Returns
The base URI originally given to the constructor.

◆ GetSimpleLayout()

bool rtctk::componentFramework::PathMapper::GetSimpleLayout ( ) const
inline
Returns
The flag indicating if the simple repository layout should be used.

◆ PathToFile()

PathMapper::FilePathResult rtctk::componentFramework::PathMapper::PathToFile ( const DataPointPath path) const

Maps a datapoint path to the corresponding local filesystem path.

This calculates what the local filesystem path for the YAML file should be that corresponds to the given datapoint path. The path component of the repository base URI is used for this calculation. This method is therefore only applicable to URIs with certain schemes, such as file:. Similarly to PathToUri, the ordered list of dictionary keys is also calculated and returned.

Parameters
[in]pathThe logical datapoint path to map.
Returns
A structure containing the YAML file path and the list of dictionary key names.

◆ PathToUri()

PathMapper::UriResult rtctk::componentFramework::PathMapper::PathToUri ( const DataPointPath path) const

Maps a datapoint path to the corresponding URI.

This calculates what the document URI should be that corresponds to the given datapoint path, taking into account the base URI. The dictionary keys that are needed to identify the datapoint within the document are also returned as an ordered list. These are used to recursively traverse the tree structure formed by the nested dictionaries to find the leaf node that corresponds to the actual datapoint value.

Parameters
[in]pathThe logical datapoint path to map.
Returns
A structure containing the calculated URI and the list of dictionary key names.

◆ SetSimpleLayout()

void rtctk::componentFramework::PathMapper::SetSimpleLayout ( bool  simple_layout)
inline

Sets the flag that indicates if the simple repository layout should be used.

The simple repository layout means that no deployment sets are present and the repository represents a 1-to-1 copy of the Runtime Configuration Repository.

Parameters
[in]simple_layoutThe flag boolean value.

◆ SplitPathComponents()

std::vector< std::string > rtctk::componentFramework::PathMapper::SplitPathComponents ( const DataPointPath path)
static

Splits the datapoint path into a list of individual path components.

The path is split on the '/' path separator character.

Parameters
[in]pathThe logical datapoint path to split.
Returns
An ordered list of the datapoint path components as strings.

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