RTC Toolkit 5.1.0
Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
rtctk::componentFramework::PopulateConfig Class Reference

A utility class used to populate the Runtime Configuration Repository. More...

#include <rtctk/componentFramework/populateConfig.hpp>

Classes

class  InvalidConfigException
 The InvalidConfigException is thrown when configuration errors are found in the Persistent Configuration Repository. More...
 
class  InvalidDataPointException
 The InvalidDataPointException is thrown when datapoints in the Persistent Configuration Repository are discovered to have invalid values. More...
 
class  RepositoryServiceException
 The RepositoryServiceException is thrown when unexpected problems arise accessing the underlying repository service. More...
 

Public Member Functions

 PopulateConfig ()=delete
 Do not allow construction with no arguments.
 
 PopulateConfig (const PopulateConfig &)=delete
 This class cannot be copy constructed.
 
PopulateConfigoperator= (const PopulateConfig &)=delete
 This class cannot be copy assigned.
 
 PopulateConfig (PopulateConfig &&)=default
 Objects of this class can be moved.
 
PopulateConfigoperator= (PopulateConfig &&)=default
 Objects of this class can be moved with the move assignment operator.
 
 PopulateConfig (PersistentRepoIf &source, RuntimeRepoIf &target)
 Constructs the utility class with references to the repositories that should be used.
 
bool IsDisablePopulateFlagSet (const std::string &rtc_supervisor)
 Checks if the disable_populate flag has been set for the RTC Supervisor.
 
bool IsDisableValidateFlagSet (const std::string &rtc_supervisor)
 Checks if the disable_validate flag has been set for the RTC Supervisor.
 
void ValidatePersistentRepository () const
 Perform various validation tests on the Persistent Configuration Repository.
 
void ClearConfig ()
 Wipes the contents of the Runtime Configuration Repository.
 
void PrePopulateConfig (const std::string &active_deployment_set)
 Performs a minimal, partial population of the Runtime Configuration Repository.
 
void PopulateRuntimeRepo (StopToken stop_token, const std::map< std::string, std::string > &requested_modes)
 Populates the Runtime Configuration Repository.
 
void CopyActiveDeploymentSet ()
 Copies the active Deployment Set to the Runtime Configuration Repository.
 
std::multimap< std::string, std::string > GetAvailableModes () const
 Returns available modes for the active deployment set.
 
std::map< std::string, std::string > GetDefaultModes () const
 Returns default modes for the active deployment set.
 
std::map< std::string, std::string > GetActiveModes ()
 Returns active modes for the active deployment set.
 
void ValidateRequestedModes (const std::map< std::string, std::string > &requested_modes) const
 Performs input validation for requested_modes.
 
void CopyRequestedModes (const std::map< std::string, std::string > &requested_modes)
 Apply requested modes by copying datapoints from source to target repository.
 
void CopyHierarchy (const DataPointPath &source, const DataPointPath &target)
 Copy a hierarchy of datapoints from the source to the target repository.
 
void CopyDataPoint (const DataPointPath &source, const DataPointPath &target)
 Copy a single datapoint from the source to the target repository.
 
void ValidateWriteBack (const std::vector< DataPointPath > &datapoints)
 Performs additional input validation for the WriteBack method.
 
void WriteBack (StopToken stop, const std::vector< DataPointPath > &datapoints)
 Performs the a writeback operation.
 

Detailed Description

A utility class used to populate the Runtime Configuration Repository.

This implements relevant logic to interpret the persistent configuration information stored in the Persistent Configuration Repository and copy only the datapoints relevant for the runtime configuration to the target Runtime Configuration Repository.

An important goal of this class is to consolidate all logic relevant for the mechanics of populating the Runtime Configuration Repository into one class, rather than distribute the logic across different components. Therefore only some of the the public methods provided are applicable to the RTC Supervisor for example, while others are applicable to the Deployment Daemon.

Thread Safety
thread-compatible – The copy methods require synchronisation.

Constructor & Destructor Documentation

◆ PopulateConfig() [1/4]

rtctk::componentFramework::PopulateConfig::PopulateConfig ( )
delete

Do not allow construction with no arguments.

◆ PopulateConfig() [2/4]

rtctk::componentFramework::PopulateConfig::PopulateConfig ( const PopulateConfig & )
delete

This class cannot be copy constructed.

◆ PopulateConfig() [3/4]

rtctk::componentFramework::PopulateConfig::PopulateConfig ( PopulateConfig && )
default

Objects of this class can be moved.

◆ PopulateConfig() [4/4]

rtctk::componentFramework::PopulateConfig::PopulateConfig ( PersistentRepoIf & source,
RuntimeRepoIf & target )

Constructs the utility class with references to the repositories that should be used.

The source and target repository must be specified. The source repository must be the Persistent Configuration Repository from which Deployment Set data will be read. The target repository must be the Runtime Configuration Repository to which the relevant runtime configuration datapoints will be copied.

Parameters
[in]sourceThe Persistent Configuration Repository that stores the Deployment Set information.
[in]targetThe Runtime Configuration Repository that will be updated with the runtime configuration.

Member Function Documentation

◆ ClearConfig()

void rtctk::componentFramework::PopulateConfig::ClearConfig ( )

Wipes the contents of the Runtime Configuration Repository.

This is used by the Deployment Daemon to clear the Runtime Configuration Repository before populating the configuration.

◆ CopyActiveDeploymentSet()

void rtctk::componentFramework::PopulateConfig::CopyActiveDeploymentSet ( )

Copies the active Deployment Set to the Runtime Configuration Repository.

This will populate the target Runtime Configuration Repository given in the constructor, by copying datapoints from the Persistent Configuration Repository for the active Deployment Set. The active Deployment Set is identified by the string stored in the datapoint /deployment/active_deployment. This must correspond to one of the sub-paths found in the root path /, i.e. one of the child folders of the root path.

All datapoints found under /{deployment}/defaults are copied to the root of the Runtime Configuration Repository, where {deployment} is the name of the active Deployment Set found in /deployment/active_deployment. The modes are then overlaid over the defaults, by effectively copying the datapoints found for each mode's option to the root of the Runtime Configuration Repository, instead of using the default datapoints. The modes for the active Deployment Set are searched for under the path /{deployment}/modes.

For each sub-path /{deployment}/modes/{name}, the default option is read from the string datapoint /{deployment}/modes/{name}/default_option. This should correspond to a sub-path under /{deployment}/modes/{name}. If the default option datapoint exists and is valid, all datapoints found under /{deployment}/modes/{name}/{option} are copied into the root of the Runtime Configuration Repository, where {option} is the value read from /{deployment}/modes/{name}/default_option. This will replace some of the default values initially loaded from /{deployment}/defaults with the mode specific ones.

Exceptions
InvalidConfigExceptionIf invalid configuration values are detected.
Thread Safety
thread-hostile – Due to multiple requests to the underlying repositories.
Exception Safety
basic

◆ CopyDataPoint()

void rtctk::componentFramework::PopulateConfig::CopyDataPoint ( const DataPointPath & source,
const DataPointPath & target )

Copy a single datapoint from the source to the target repository.

Copies a datapoint indicated by the source path from the source Persistent Configuration Repository, as set in the constructor, to the target path and target Runtime Configuration Repository.

Parameters
[in]sourceThe datapoint path in the Persistent Configuration Repository to copy from.
[in]targetThe datapoint path in the Runtime Configuration Repository to copy to.
Thread Safety
thread-hostile – Due to multiple requests to the underlying repositories.
Exception Safety
basic

◆ CopyHierarchy()

void rtctk::componentFramework::PopulateConfig::CopyHierarchy ( const DataPointPath & source,
const DataPointPath & target )

Copy a hierarchy of datapoints from the source to the target repository.

Copies an entire hierarchy of datapoints indicated by the source path from the source Persistent Configuration Repository, as set in the constructor, to the target path and target Runtime Configuration Repository.

Parameters
[in]sourceThe datapoint path in the Persistent Configuration Repository to copy from.
[in]targetThe datapoint path in the Runtime Configuration Repository to copy to.
Thread Safety
thread-hostile – Due to multiple requests to the underlying repositories.
Exception Safety
basic

◆ CopyRequestedModes()

void rtctk::componentFramework::PopulateConfig::CopyRequestedModes ( const std::map< std::string, std::string > & requested_modes)

Apply requested modes by copying datapoints from source to target repository.

as a side effect the Runtime Repository datapoint active_modes is read and written

Exceptions
RtctkExceptionIf requested modes could not be copied.

◆ GetActiveModes()

std::map< std::string, std::string > rtctk::componentFramework::PopulateConfig::GetActiveModes ( )

Returns active modes for the active deployment set.

Returns
map where keys are mode names and values are active mode option names.
Exceptions
RtctkExceptionIf active modes cannot be retrieved.

◆ GetAvailableModes()

std::multimap< std::string, std::string > rtctk::componentFramework::PopulateConfig::GetAvailableModes ( ) const

Returns available modes for the active deployment set.

Returns
multimap where keys are mode names and values are mode option names.

◆ GetDefaultModes()

std::map< std::string, std::string > rtctk::componentFramework::PopulateConfig::GetDefaultModes ( ) const

Returns default modes for the active deployment set.

Returns
map where keys are mode names and values are default mode option names.
Exceptions
RtctkExceptionIf default modes cannot be retrieved.

◆ IsDisablePopulateFlagSet()

bool rtctk::componentFramework::PopulateConfig::IsDisablePopulateFlagSet ( const std::string & rtc_supervisor)

Checks if the disable_populate flag has been set for the RTC Supervisor.

The disable_populate flag indicates if automated populating of the Runtime Configuration Repository should be suppressed by the given RTC Supervisor instance. This method will first look for the boolean datapoint /{rtc_supervisor}/static/disable_populate in the Runtime Configuration Repository, where {rtc_supervisor} is the name of the RTC Supervisor instance. If this datapoint exists, its value is returned. Otherwise the datapoint /{deployment}/defaults/{rtc_supervisor}/static/disable_populate is searched for in the active Deployment Set (indicated by the {deployment} placeholder) in the Persistent Configuration Repository. If the datapoint exists in the Persistent Configuration Repository instead, then that value is returned. However, if a datapoint cannot be found in either repository then a default value of false is returned.

This logic is part of PopulateConfig, since this class is responsible for identifying the configuration entries in the Persistent Configuration Repository for the active Deployment Set. Knowing the exact location of this flag for the active Deployment Set therefore requires similar logic.

Parameters
[in]rtc_supervisorThe name of the RTC Supervisor instance who's flag to check.
Returns
true if the flag was set and false if it was not or the datapoint for the flag does not exist in the repository.
Thread Safety
thread-safe
Exception Safety
strong

◆ IsDisableValidateFlagSet()

bool rtctk::componentFramework::PopulateConfig::IsDisableValidateFlagSet ( const std::string & rtc_supervisor)

Checks if the disable_validate flag has been set for the RTC Supervisor.

The disable_validate flag indicates if validation of the contents of the Persistent Configuration Repository should be suppressed by the given RTC Supervisor instance. This method will first look for the boolean datapoint /{rtc_supervisor}/static/disable_validate in the Runtime Configuration Repository, where {rtc_supervisor} is the name of the RTC Supervisor instance. If this datapoint exists, its value is returned. Otherwise the datapoint /{deployment}/defaults/{rtc_supervisor}/static/disable_validate is searched for in the active Deployment Set (indicated by the {deployment} placeholder) in the Persistent Configuration Repository. If the datapoint exists in the Persistent Configuration Repository instead, then that value is returned. However, if a datapoint cannot be found in either repository then a default value of false is returned.

Note that the logic and motivation for this method are similar to IsDisablePopulateFlagSet.

Parameters
[in]rtc_supervisorThe name of the RTC Supervisor instance who's flag to check.
Returns
true if the flag was set and false if it was not or the datapoint for the flag does not exist in the repository.
Thread Safety
thread-safe
Exception Safety
strong

◆ operator=() [1/2]

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

This class cannot be copy assigned.

◆ operator=() [2/2]

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

Objects of this class can be moved with the move assignment operator.

◆ PopulateRuntimeRepo()

void rtctk::componentFramework::PopulateConfig::PopulateRuntimeRepo ( StopToken stop_token,
const std::map< std::string, std::string > & requested_modes )

Populates the Runtime Configuration Repository.

Loads the configuration datapoints for all SRTC components from the Persistent Configuration Repository into the Runtime Configuration Repository.

Parameters
[in]stop_tokenA stop token to be able to abort this long-running operation
[in]requested_modesA map of requested modes with keys being the mode names and values being the mode option names. For mode names that are not present in this map the configured default options will be chosen.

◆ PrePopulateConfig()

void rtctk::componentFramework::PopulateConfig::PrePopulateConfig ( const std::string & active_deployment_set)

Performs a minimal, partial population of the Runtime Configuration Repository.

This is used by the Deployment Daemon to enable the RTC Supervisor to do the full population later during system initialisation. A bootstrap operation, so to speak. The /deployment/active_deployment datapoint is written to the Runtime Configuration Repository to be used by the CopyActiveDeploymentSet method later.

Parameters
[in]active_deployment_setIdentifier of the active Deployment Set.

◆ ValidatePersistentRepository()

void rtctk::componentFramework::PopulateConfig::ValidatePersistentRepository ( ) const

Perform various validation tests on the Persistent Configuration Repository.

The configuration stored in the Persistent Configuration Repository is checked for the following properties:

  • If the /default_deployment datapoint is given it must refer to an existing deployment set.
  • Every option in a particular mode must use the same set of datapoints as every other option in the same mode.
  • Every datapoint applicable to a mode must have a data point in the deployment set's defaults.
  • No two modes should use overlapping datapoints.
  • Modes should only refer to dynamic datapoints.
  • Every mode must have a default_option datapoint that refers to an existing option of the mode.
  • The datapoint types used in a mode's options must be the same as the corresponding datapoint defined under the deployment set's defaults folder.
Exceptions
InvalidConfigExceptionIf any of the tests fail, a subclass of this exception is thrown to indicate that the configuration is not valid.
RepositoryServiceExceptionIn case of errors accessing the Persistent Configuration Repository.

◆ ValidateRequestedModes()

void rtctk::componentFramework::PopulateConfig::ValidateRequestedModes ( const std::map< std::string, std::string > & requested_modes) const

Performs input validation for requested_modes.

has no side-effects

Exceptions
RtctkExceptionIf provided modes are invalid.

◆ ValidateWriteBack()

void rtctk::componentFramework::PopulateConfig::ValidateWriteBack ( const std::vector< DataPointPath > & datapoints)

Performs additional input validation for the WriteBack method.

This method performs checks beyond the minimal sanity checks performed by the WriteBack method to avoid corruption. For example, the provided datapoint paths are checked that they actually map to a datapoint from the Persistent Configuration Repository, given the current active deployment and modes.

Parameters
[in]datapointsThe list of datapoints to validate.
Exceptions
RtctkExceptionIf the provided datapoints are invalid.

◆ WriteBack()

void rtctk::componentFramework::PopulateConfig::WriteBack ( StopToken stop,
const std::vector< DataPointPath > & datapoints )

Performs the a writeback operation.

For each provided datapoint, this will copy the datapoint from the Runtime Configuration Repository back to the corresponding location in the Persistent Configuration Repository that the datapoint was originally populated from. The writeback takes into account the current active deployment and modes.

Parameters
[in]stopStop Token used to check if operation should be aborted
[in]datapointsThe list of datapoints to be written back, if the list is empty, all datapoints will be written back.
Exceptions
RtctkExceptionIf writeback could not be performed.

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