RTC Toolkit  2.0.0
Public Member Functions | Protected Member Functions | List of all members
rtctk::standaloneTools::ShmSubscriberBase Class Referenceabstract

Base class to implement all non-template methods that can be pre-compiled for the ShmSubscriber. More...

#include <shmSubscriber.hpp>

Inheritance diagram for rtctk::standaloneTools::ShmSubscriberBase:
rtctk::standaloneTools::ShmSubscriber< Topic, ConditionPolicy, ShmTraits >

Public Member Functions

 ShmSubscriberBase ()=default
 
virtual ~ShmSubscriberBase ()=default
 
int Run (int argc, char *argv[])
 Executes the shared memory subscriber program. More...
 

Protected Member Functions

virtual void Initialise ()=0
 Should perform any needed initialisation steps for the program. More...
 
virtual void Finalise ()=0
 Must cleanup any objects created in Initialise. More...
 
virtual bool ReadSample ()=0
 Should read a sample into internal buffers from the shared memory. More...
 
virtual void PrintSample ()=0
 Should print the contents of the read sample to console in a human readable format. More...
 
virtual const void * GetSampleData () const =0
 
virtual size_t GetSampleSize () const =0
 
const std::string & GetQueueName () const
 
const std::string & GetFilename () const
 
const int64_t GetSampleNumber () const
 
const int64_t PrintWihtLongFormat () const
 

Detailed Description

Base class to implement all non-template methods that can be pre-compiled for the ShmSubscriber.

Constructor & Destructor Documentation

◆ ShmSubscriberBase()

rtctk::standaloneTools::ShmSubscriberBase::ShmSubscriberBase ( )
default

◆ ~ShmSubscriberBase()

virtual rtctk::standaloneTools::ShmSubscriberBase::~ShmSubscriberBase ( )
virtualdefault

Member Function Documentation

◆ Finalise()

virtual void rtctk::standaloneTools::ShmSubscriberBase::Finalise ( )
protectedpure virtual

Must cleanup any objects created in Initialise.

This method is invoked at the end of Run, after existing the processing loop.

◆ GetFilename()

const std::string& rtctk::standaloneTools::ShmSubscriberBase::GetFilename ( ) const
inlineprotected
Returns
the output filename to use. If no filename was given on the command line then the returned value should be an empty string.

◆ GetQueueName()

const std::string& rtctk::standaloneTools::ShmSubscriberBase::GetQueueName ( ) const
inlineprotected
Returns
the parsed name of the queue to attach to.

◆ GetSampleData()

virtual const void* rtctk::standaloneTools::ShmSubscriberBase::GetSampleData ( ) const
protectedpure virtual
Returns
a pointer to the buffer containing the sample data that was read in ReadSample.

◆ GetSampleNumber()

const int64_t rtctk::standaloneTools::ShmSubscriberBase::GetSampleNumber ( ) const
inlineprotected
Returns
the number of the current sample, i.e. the sample count.

◆ GetSampleSize()

virtual size_t rtctk::standaloneTools::ShmSubscriberBase::GetSampleSize ( ) const
protectedpure virtual
Returns
the size of the buffer returned by GetSampleData in bytes.

◆ Initialise()

virtual void rtctk::standaloneTools::ShmSubscriberBase::Initialise ( )
protectedpure virtual

Should perform any needed initialisation steps for the program.

This method is invoked in Run at the beginning of execution, before starting to read from shared memory. The shared memory reader must be initialised here, including any other needed objects.

◆ PrintSample()

virtual void rtctk::standaloneTools::ShmSubscriberBase::PrintSample ( )
protectedpure virtual

Should print the contents of the read sample to console in a human readable format.

Child classes should override this method so that sample previously read into internal buffers by ReadSample should be printed when this method is called.

◆ PrintWihtLongFormat()

const int64_t rtctk::standaloneTools::ShmSubscriberBase::PrintWihtLongFormat ( ) const
inlineprotected
Returns
true if the printing of the sample should be in long format, and false if it should be in a short summary format.

◆ ReadSample()

virtual bool rtctk::standaloneTools::ShmSubscriberBase::ReadSample ( )
protectedpure virtual

Should read a sample into internal buffers from the shared memory.

Must be overridden by the child class to implement the code needed to read from the specific shared memory reader. This method should not block for long periods of time. If no sample was received for more than about a second then this should be considered a timeout and the method should return false, without filling any internal buffers with data.

Returns
true if a sample could be read and false if a timeout occurred.
Note
This method should throw and exception on hard failures, i.e. anything that is not a timeout.

◆ Run()

int rtctk::standaloneTools::ShmSubscriberBase::Run ( int  argc,
char *  argv[] 
)

Executes the shared memory subscriber program.

This method should be invoked from the main() entry-point function to parse the command line arguments and then enter a processing loop.

Returns
EXIT_SUCCESS if the maximum number of sample reads has been performed without failure or one of the SIGINT, SIGTERM or SIGHUP signals was received. EXIT_FAILURE is returned if an error occurred.

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