RTC Toolkit 4.0.1
Loading...
Searching...
No Matches
populateConfig.hpp
Go to the documentation of this file.
1
13#ifndef RTCTK_COMPONENTFRAMEWORK_POPULATECONFIG_HPP
14#define RTCTK_COMPONENTFRAMEWORK_POPULATECONFIG_HPP
15
16#include <functional>
17#include <map>
18#include <optional>
19#include <typeindex>
20
26
28
48public:
54 public:
55 // using RtctkException::RtctkException;
56
62 explicit RepositoryServiceException(const std::string& repository);
63 };
64
70 public:
76 explicit InvalidConfigException(const std::vector<std::string>& errors);
77 };
78
84 public:
91 explicit InvalidDataPointException(const DataPointPath& path,
92 const std::string& explanation = "");
93 };
94
96 PopulateConfig() = delete;
97
100
103
106
109
124
155 bool IsDisablePopulateFlagSet(const std::string& rtc_supervisor);
156
184 bool IsDisableValidateFlagSet(const std::string& rtc_supervisor);
185
208 void ValidatePersistentRepository() const;
209
216 void ClearConfig();
217
228 void PrePopulateConfig(const std::string& active_deployment_set);
229
242 void PopulateRuntimeRepo(StopToken stop_token,
243 const std::map<std::string, std::string>& requested_modes);
244
279
285 std::multimap<std::string, std::string> GetAvailableModes() const;
286
294 std::map<std::string, std::string> GetDefaultModes() const;
295
303 std::map<std::string, std::string> GetActiveModes();
304
312 void ValidateRequestedModes(const std::map<std::string, std::string>& requested_modes) const;
313
321 void CopyRequestedModes(const std::map<std::string, std::string>& requested_modes);
322
336 void CopyHierarchy(const DataPointPath& source, const DataPointPath& target);
337
351 void CopyDataPoint(const DataPointPath& source, const DataPointPath& target);
352
365 void ValidateWriteBack(const std::vector<DataPointPath>& datapoints);
366
381 void WriteBack(StopToken stop, const std::vector<DataPointPath>& datapoints);
382
383private:
384 void SetActiveModes(const std::map<std::string, std::string>& active_modes);
385 DataPointPath GetActiveDeploymentPath() const;
386 void CopyDefaults(const DataPointPath& active_deployment_path);
387 void CopyModes(const DataPointPath& active_deployment_path);
388 void PopulateServerAliasCache(const DataPointPath& defaults_path);
389 void DeleteHierarchy(const DataPointPath& path);
390 void ComputeParameterMappings();
391 void WriteBackDataPoint(const DataPointPath& source, const DataPointPath& target);
392
393 log4cplus::Logger& m_logger;
394
396 PersistentRepoIf& m_persistent_repo;
397
399 RuntimeRepoIf& m_runtime_repo;
400
402 struct IoFunctionMapEntry {
403 using CopyFunction = std::function<void(const PersistentRepoIf&,
404 const DataPointPath&,
406 const DataPointPath&,
407 const std::string& server_alias)>;
408
409 using WriteBackFunction = std::function<void(
411
412 CopyFunction m_copy_function;
413 WriteBackFunction m_writeback_function;
414 };
415
416 using IoFunctionMap = std::map<std::type_index, IoFunctionMapEntry>;
417
422 template <typename T>
423 static auto MakeMapEntry();
424
426 static const IoFunctionMap S_IO_FUNCTIONS;
427
428 ServerAliasCache m_server_alias_cache;
429
430 std::map<DataPointPath, DataPointPath> m_psr_to_rtr_map;
431 std::map<DataPointPath, DataPointPath> m_rtr_to_psr_map;
432};
433
434} // namespace rtctk::componentFramework
435
436#endif // RTCTK_COMPONENTFRAMEWORK_POPULATECONFIG_HPP
This class provides a wrapper for a data point path.
Definition: dataPointPath.hpp:73
Base interface for all Persistent Configuration Repository adapters.
Definition: persistentRepoIf.hpp:25
The InvalidConfigException is thrown when configuration errors are found in the Persistent Configurat...
Definition: populateConfig.hpp:69
The InvalidDataPointException is thrown when datapoints in the Persistent Configuration Repository ar...
Definition: populateConfig.hpp:83
The RepositoryServiceException is thrown when unexpected problems arise accessing the underlying repo...
Definition: populateConfig.hpp:53
A utility class used to populate the Runtime Configuration Repository.
Definition: populateConfig.hpp:47
void CopyHierarchy(const DataPointPath &source, const DataPointPath &target)
Copy a hierarchy of datapoints from the source to the target repository.
Definition: populateConfig.cpp:856
PopulateConfig(const PopulateConfig &)=delete
This class cannot be copy constructed.
PopulateConfig()=delete
Do not allow construction with no arguments.
std::multimap< std::string, std::string > GetAvailableModes() const
Returns available modes for the active deployment set.
Definition: populateConfig.cpp:651
void PopulateRuntimeRepo(StopToken stop_token, const std::map< std::string, std::string > &requested_modes)
Populates the Runtime Configuration Repository.
Definition: populateConfig.cpp:590
void WriteBack(StopToken stop, const std::vector< DataPointPath > &datapoints)
Performs the a writeback operation.
Definition: populateConfig.cpp:946
void ValidateWriteBack(const std::vector< DataPointPath > &datapoints)
Performs additional input validation for the WriteBack method.
Definition: populateConfig.cpp:926
PopulateConfig & operator=(PopulateConfig &&)=default
Objects of this class can be moved with the move assignment operator.
void ValidatePersistentRepository() const
Perform various validation tests on the Persistent Configuration Repository.
Definition: populateConfig.cpp:529
PopulateConfig(PopulateConfig &&)=default
Objects of this class can be moved.
void ClearConfig()
Wipes the contents of the Runtime Configuration Repository.
Definition: populateConfig.cpp:562
PopulateConfig & operator=(const PopulateConfig &)=delete
This class cannot be copy assigned.
std::map< std::string, std::string > GetActiveModes()
Returns active modes for the active deployment set.
Definition: populateConfig.cpp:686
bool IsDisableValidateFlagSet(const std::string &rtc_supervisor)
Checks if the disable_validate flag has been set for the RTC Supervisor.
Definition: populateConfig.cpp:621
std::map< std::string, std::string > GetDefaultModes() const
Returns default modes for the active deployment set.
Definition: populateConfig.cpp:671
bool IsDisablePopulateFlagSet(const std::string &rtc_supervisor)
Checks if the disable_populate flag has been set for the RTC Supervisor.
Definition: populateConfig.cpp:605
void CopyActiveDeploymentSet()
Copies the active Deployment Set to the Runtime Configuration Repository.
Definition: populateConfig.cpp:637
void ValidateRequestedModes(const std::map< std::string, std::string > &requested_modes) const
Performs input validation for requested_modes.
Definition: populateConfig.cpp:724
void PrePopulateConfig(const std::string &active_deployment_set)
Performs a minimal, partial population of the Runtime Configuration Repository.
Definition: populateConfig.cpp:581
void CopyDataPoint(const DataPointPath &source, const DataPointPath &target)
Copy a single datapoint from the source to the target repository.
Definition: populateConfig.cpp:868
void CopyRequestedModes(const std::map< std::string, std::string > &requested_modes)
Apply requested modes by copying datapoints from source to target repository.
Definition: populateConfig.cpp:751
The RtctkException class is the base class for all Rtctk exceptions.
Definition: exceptions.hpp:237
RtctkException() noexcept
Definition: exceptions.cpp:113
Base interface for all Runtime Configuration Repository adapters.
Definition: runtimeRepoIf.hpp:28
A utility class used to lookup the Server Alias for a given Data Point Path.
Definition: serverAliasCache.hpp:30
Logging Support Library based on log4cplus.
Definition: commandReplier.cpp:22
rad::StopToken StopToken
Definition: stopToken.hpp:20
Header file for PersistentRepoIf, which defines the API for PersistentRepoAdapter.
Header file for RuntimeRepoIf, which defines the API for RuntimeRepoAdapters.
Header file for the server alias cache.
A simple Stop Token.