RTC Toolkit 5.1.0
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
rtctk::componentFramework::RecordingUnit Class Referenceabstract

Abstract base class for all sources that can be recorded by the MetadataCollector and TelemetryRecorder. More...

#include <recordingUnit.hpp>

Inheritance diagram for rtctk::componentFramework::RecordingUnit:
rtctk::componentFramework::DataPointRecordingUnit< DpType > rtctk::componentFramework::DynamicDataPointRecordingUnit rtctk::componentFramework::EventRecordingUnit< OutputStage > rtctk::componentFramework::IpcqRecordingUnit< RecInfoType > rtctk::componentFramework::JsonEventRecordingUnit< OutputStage > rtctk::componentFramework::TypedEventRecordingUnit< EventType, OutputStage >

Public Types

enum class  State : uint8_t {
  STOPPED , PREPARING , IDLE , WAITING ,
  RUNNING , FINISHED , FAILED
}
 

Public Member Functions

 RecordingUnit (const std::string &comp_id, const std::string &unit_id, const std::string &unit_type, ServiceContainer &services)
 Create a new RecordingIngestion.
 
 RecordingUnit ()=delete
 
virtual ~RecordingUnit ()=default
 
void ConnectWithLeaders (RecUnitListType &units)
 
std::string GetId ()
 Get the unit_it of this RecordingUnit.
 
State GetState ()
 Get the current state of the Recording Unit.
 
virtual void CheckErrors ()
 Check for Errors, will rethrow errors thrown in the recorder.
 
virtual void Prepare (const std::filesystem::path &file_path)=0
 Prepare the recording.
 
virtual void Start ()=0
 Start the recording.
 
virtual std::vector< std::filesystem::path > Stop ()=0
 Stop the recording and wait for it's termination.
 
virtual void Update ()
 Update dynamic settings.
 
boost::signals2::connection Connect (const std::function< void(const std::string &, const State &)> &function)
 Connect to State change signal.
 

Public Attributes

const std::map< State, std::string > m_state_text
 

Protected Member Functions

bool SetState (State state, State precondition)
 Sets the new state, only goes to new state, if expected state matches.
 
void SetState (State state, State precondition, const std::string &error_message)
 Sets the new state, only goes to new state, if expected state matches.
 
void SetFailed (const std::exception_ptr &exception)
 Set the unit into failed state, with the given exception.
 
void SetStopped ()
 Set the Unit state to STOPPED independent of the current State.
 
bool HasLeaders ()
 Check if this unit is following any leaders.
 
bool HasFirstLeaderStarted ()
 This function is used to determine if this unit should start recording when waiting for leaders.
 
bool HasLastLeaderFinished ()
 This function is used to determine if this unit should stop recording when waiting for leaders.
 
void ResetLeaderStates ()
 

Protected Attributes

std::string m_comp_id
 
std::string m_unit_id
 
RuntimeRepoIfm_rtr
 
OldbIfm_oldb
 
ComponentMetricsIfm_metrics
 
std::optional< std::filesystem::path > m_file_path
 
boost::signals2::signal< void(const std::string &, const State &) m_signal )
 

Detailed Description

Abstract base class for all sources that can be recorded by the MetadataCollector and TelemetryRecorder.

Member Enumeration Documentation

◆ State

Enumerator
STOPPED 
PREPARING 
IDLE 
WAITING 
RUNNING 
FINISHED 
FAILED 

Constructor & Destructor Documentation

◆ RecordingUnit() [1/2]

rtctk::componentFramework::RecordingUnit::RecordingUnit ( const std::string & comp_id,
const std::string & unit_id,
const std::string & unit_type,
ServiceContainer & services )

Create a new RecordingIngestion.

Parameters
comp_idname of the component
unit_idthe id of the recording unit
unit_typetype of the recording unit as a string
servicesrequired services

◆ RecordingUnit() [2/2]

rtctk::componentFramework::RecordingUnit::RecordingUnit ( )
delete

◆ ~RecordingUnit()

virtual rtctk::componentFramework::RecordingUnit::~RecordingUnit ( )
virtualdefault

Member Function Documentation

◆ CheckErrors()

void rtctk::componentFramework::RecordingUnit::CheckErrors ( )
virtual

Check for Errors, will rethrow errors thrown in the recorder.

Reimplemented in rtctk::componentFramework::DynamicDataPointRecordingUnit.

◆ Connect()

boost::signals2::connection rtctk::componentFramework::RecordingUnit::Connect ( const std::function< void(const std::string &, const State &)> & function)

Connect to State change signal.

Parameters
functioncallback that should be called
Returns
boost signals2 connection for the callback

◆ ConnectWithLeaders()

void rtctk::componentFramework::RecordingUnit::ConnectWithLeaders ( RecUnitListType & units)

◆ GetId()

std::string rtctk::componentFramework::RecordingUnit::GetId ( )

Get the unit_it of this RecordingUnit.

◆ GetState()

RecordingUnit::State rtctk::componentFramework::RecordingUnit::GetState ( )

Get the current state of the Recording Unit.

◆ HasFirstLeaderStarted()

bool rtctk::componentFramework::RecordingUnit::HasFirstLeaderStarted ( )
protected

This function is used to determine if this unit should start recording when waiting for leaders.

Returns
true when one leader has started recording

◆ HasLastLeaderFinished()

bool rtctk::componentFramework::RecordingUnit::HasLastLeaderFinished ( )
protected

This function is used to determine if this unit should stop recording when waiting for leaders.

Returns
true when all leaders have stopped recording

◆ HasLeaders()

bool rtctk::componentFramework::RecordingUnit::HasLeaders ( )
protected

Check if this unit is following any leaders.

Returns
true if the unit has at least one leader

◆ Prepare()

virtual void rtctk::componentFramework::RecordingUnit::Prepare ( const std::filesystem::path & file_path)
pure virtual

◆ ResetLeaderStates()

void rtctk::componentFramework::RecordingUnit::ResetLeaderStates ( )
protected

◆ SetFailed()

void rtctk::componentFramework::RecordingUnit::SetFailed ( const std::exception_ptr & exception)
protected

Set the unit into failed state, with the given exception.

◆ SetState() [1/2]

bool rtctk::componentFramework::RecordingUnit::SetState ( RecordingUnit::State state,
RecordingUnit::State precondition )
protected

Sets the new state, only goes to new state, if expected state matches.

Parameters
statenew state
preconditionthe state before the transition
Returns
true if change was successful, false otherwise (meaning the precondition was not met)

◆ SetState() [2/2]

void rtctk::componentFramework::RecordingUnit::SetState ( RecordingUnit::State state,
RecordingUnit::State precondition,
const std::string & error_message )
protected

Sets the new state, only goes to new state, if expected state matches.

Parameters
statenew state
preconditionexpected state
error_messagemessage of InvalidStateChange if state change invalid (meaning the precondition was not met)
Exceptions
InvalidStateChangewhen state change

◆ SetStopped()

void rtctk::componentFramework::RecordingUnit::SetStopped ( )
protected

Set the Unit state to STOPPED independent of the current State.

◆ Start()

virtual void rtctk::componentFramework::RecordingUnit::Start ( )
pure virtual

◆ Stop()

virtual std::vector< std::filesystem::path > rtctk::componentFramework::RecordingUnit::Stop ( )
pure virtual

◆ Update()

void rtctk::componentFramework::RecordingUnit::Update ( )
virtual

Member Data Documentation

◆ m_comp_id

std::string rtctk::componentFramework::RecordingUnit::m_comp_id
protected

◆ m_file_path

std::optional<std::filesystem::path> rtctk::componentFramework::RecordingUnit::m_file_path
protected

◆ m_metrics

ComponentMetricsIf& rtctk::componentFramework::RecordingUnit::m_metrics
protected

◆ m_oldb

OldbIf& rtctk::componentFramework::RecordingUnit::m_oldb
protected

◆ m_rtr

RuntimeRepoIf& rtctk::componentFramework::RecordingUnit::m_rtr
protected

◆ m_signal

boost::signals2::signal<void(const std::string&, const State&) rtctk::componentFramework::RecordingUnit::m_signal)
protected

◆ m_state_text

const std::map<State, std::string> rtctk::componentFramework::RecordingUnit::m_state_text

◆ m_unit_id

std::string rtctk::componentFramework::RecordingUnit::m_unit_id
protected

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