Go to the documentation of this file.
11 #ifndef RTCTK_COMPONENTFRAMEWORK_RECORDINGUNIT_HPP
12 #define RTCTK_COMPONENTFRAMEWORK_RECORDINGUNIT_HPP
15 #include <boost/signals2.hpp>
18 #include <shared_mutex>
24 class ServiceContainer;
34 template <
class T,
class...
Args>
36 units.emplace_back(std::make_unique<T>(std::forward<Args>(args)...));
77 std::string
const& unit_id,
105 virtual void Prepare(
const std::filesystem::path& file_path) = 0;
114 virtual std::optional<std::filesystem::path>
Stop() = 0;
125 boost::signals2::connection
126 Connect(
const std::function<
void(std::string
const&,
State const&)>&
function);
149 void SetFailed(
const std::exception_ptr& exception);
179 std::mutex m_leader_mutex;
180 std::atomic<State> m_state;
181 std::exception_ptr m_exception =
nullptr;
182 std::shared_mutex m_exception_mutex;
183 std::vector<std::string> m_leaders;
184 std::map<std::string, State> m_leader_states;
185 bool m_first_leader_started =
false;
186 bool m_last_leader_finished =
false;
191 #endif // RTCTK_COMPONENTFRAMEWORK_RECORDINGUNIT_HPP
boost::signals2::connection Connect(const std::function< void(std::string const &, State const &)> &function)
Connect to State change signal.
Definition: recordingUnit.cpp:162
std::string m_unit_id
Definition: recordingUnit.hpp:172
virtual void Update()
Update dynamic settings.
Definition: recordingUnit.cpp:157
This Exception is raised when the state change requested is invalid.
Definition: recordingUnit.hpp:42
std::list< std::unique_ptr< RecordingUnit > > RecUnitListType
Definition: recordingUnit.hpp:26
void ConnectWithLeaders(RecUnitListType &units)
Definition: recordingUnit.cpp:51
boost::signals2::signal< void(std::string const &, State const &)> m_signal
Definition: recordingUnit.hpp:176
bool HasLastLeaderFinished()
This function is used to determine if this unit should stop recording when waiting for leaders.
Definition: recordingUnit.cpp:101
RtctkException() noexcept
Definition: exceptions.cpp:99
InvalidSetting(const std::string &message)
Definition: recordingUnit.hpp:55
std::string m_comp_id
Definition: recordingUnit.hpp:171
Definition: commandReplier.cpp:20
virtual std::optional< std::filesystem::path > Stop()=0
Stop the recording and wait for it's termination.
virtual ~RecordingUnit()=default
RepositoryIf & m_rtr
Definition: recordingUnit.hpp:173
std::optional< std::filesystem::path > m_file_path
Definition: recordingUnit.hpp:175
Definition: rtcComponent.hpp:38
The RtctkException class is the base class for all Rtctk exceptions.
Definition: exceptions.hpp:207
State GetState()
Get the current state of the Recording Unit.
Definition: recordingUnit.cpp:146
bool SetState(State state, State precondition)
Sets the new state, only goes to new state, if expected state matches.
Definition: recordingUnit.cpp:119
Abstract base class for all sources that can be recorded by the MetadataCollector and TelemetryRecord...
Definition: recordingUnit.hpp:65
Header file for RepositoryIf and related base classes.
bool HasLeaders()
Check if this unit is following any leaders.
Definition: recordingUnit.cpp:92
virtual void Start()=0
Start the recording.
Container class that holds services of any type.
Definition: serviceContainer.hpp:35
void CheckErrors()
Check for Errors, will rethrow errors thrown in the recorder.
Definition: recordingUnit.cpp:150
void SetFailed(const std::exception_ptr &exception)
Set the unit into failed state, with the given exception.
Definition: recordingUnit.cpp:134
Abstract interface providing basic read and write facilities to a repository.
Definition: repositoryIf.hpp:34
State
Definition: recordingUnit.hpp:67
This Exception is raised when a invalid setting was used in the runtime repo.
Definition: recordingUnit.hpp:52
bool HasFirstLeaderStarted()
This function is used to determine if this unit should start recording when waiting for leaders.
Definition: recordingUnit.cpp:96
std::string GetId()
Get the unit_it of this RecordingUnit.
Definition: recordingUnit.cpp:115
RepositoryIf & m_oldb
Definition: recordingUnit.hpp:174
InvalidStateChange(const std::string &message)
Definition: recordingUnit.hpp:45
void SetStopped()
Set the Unit state to STOPPED independent of the current State.
Definition: recordingUnit.cpp:141
void ResetLeaderStates()
Definition: recordingUnit.cpp:106
void AddRecUnit(RecUnitListType &units, Args &&... args)
Add a RecordingUnit to the RecordingUnit list of a TelemetryRecorder oder MetadataCollector.
Definition: recordingUnit.hpp:35
virtual void Prepare(const std::filesystem::path &file_path)=0
Prepare the recording.
std::function< RecUnitListType(std::string const &, ServiceContainer &)> RecUnitFactoryType
Definition: recordingUnit.hpp:27