RTC Toolkit 5.1.0
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | List of all members
rtctk::standaloneTools::ShmPub< TopicType, WriterType > Class Template Referenceabstract

ShmPub parent class. More...

#include <rtctk/standaloneTools/shmPub.hpp>

Public Member Functions

 ShmPub (int argc, char *argv[])
 
virtual ~ShmPub ()=default
 
int Run ()
 Entry point for running the ShmPub.
 
virtual std::vector< TopicType > ReadFits (std::string filename)=0
 Reads in data from a FITS file.
 
virtual std::vector< TopicType > GenData (int num_frames)=0
 Generates data to be circulated.
 
virtual void AdjustSample (TopicType &sample) const
 Adjust the contents of a data sample just before publishing to shared memory.
 

Protected Member Functions

std::string GetQueueName () const
 Returns the shared memory queue name argument set on the command line.
 
size_t GetQueueSize () const
 Returns the shared memory queue size argument set on the command line.
 
int GetSampleDelay () const
 Returns the sample delay argument set on the command line.
 
int GetNuma () const
 Returns the NUMA node argument set on the command line.
 
bool GetRepeatMode () const
 Returns the repeat mode flag set on the command line.
 

Detailed Description

template<class TopicType, class WriterType = ipcq::Writer<TopicType>>
class rtctk::standaloneTools::ShmPub< TopicType, WriterType >

ShmPub parent class.

Note
Child classes must inherited from this class and must overload functions ReadFits(std::string) and GenData(int).
Template Parameters
TopicTypethe queue topic.
WriterTypethe type of ipcq writer to be used defaults to ipcq::Writer<TopicType>
  Allowed options:
  -h [ --help ]                         produce help message
  -f [ --fits-file ] arg                fits input file: if not provided the
                                          app will generate data
  -q [ --queue-name ] arg (=default_shm_queue)
                                          shm queue name
  -s [ --queue-size ] arg (=1000)       size of the queue
  -d [ --sample-delay ] arg (=10)       inter-sample delay in ms
  -n [ --numa-node ] arg                numa node for shm queue
  -p [ --print-every ] arg (=0)         when to print to screen the number of
                                          sample written
  -g [ --gen-frames ] arg (=100)        Number of frames to generate
  -s [ --sample-id-increment ] (=1)     sample_id increment (applicable in repeat mode)
  -r [ --repeat-mode ]                  Repeat output when all samples are written

Constructor & Destructor Documentation

◆ ShmPub()

template<class TopicType , class WriterType = ipcq::Writer<TopicType>>
rtctk::standaloneTools::ShmPub< TopicType, WriterType >::ShmPub ( int argc,
char * argv[] )
inline

◆ ~ShmPub()

template<class TopicType , class WriterType = ipcq::Writer<TopicType>>
virtual rtctk::standaloneTools::ShmPub< TopicType, WriterType >::~ShmPub ( )
virtualdefault

Member Function Documentation

◆ AdjustSample()

template<class TopicType , class WriterType = ipcq::Writer<TopicType>>
virtual void rtctk::standaloneTools::ShmPub< TopicType, WriterType >::AdjustSample ( TopicType & sample) const
inlinevirtual

Adjust the contents of a data sample just before publishing to shared memory.

This method is called for every sample just before writing it to shared memory. By default it does nothing. But it gives an opportunity to override this in a class inheriting from ShmPub to adjust the data in some programmatic way. For example, to update timestamps in the sample payload.

Note
One should not recreate or update the whole contents of the sample inside this method. The intention is to only update a select few fields, e.g. timestamps.
Parameters
[in,out]sampleThe sample data to update.

◆ GenData()

template<class TopicType , class WriterType = ipcq::Writer<TopicType>>
virtual std::vector< TopicType > rtctk::standaloneTools::ShmPub< TopicType, WriterType >::GenData ( int num_frames)
pure virtual

Generates data to be circulated.

This is a pure virtual function that must be overloaded by a child class in user code. The user code must allocate the necessary vector of the appropriate size (typically num_frames), fill the vector with generated data, and then return the vector.

If an exception is thrown from this method the process will terminate early with an error message.

Parameters
num_framesThe number of frames for which to generate data.
Returns
A vector of data points of type TopicType, i.e. std::vector<TopicType>. The size of the vector should typically be equal to num_frames.

Implemented in ExampleShmPubScao, and ExamplePixelsShmPub.

◆ GetNuma()

template<class TopicType , class WriterType = ipcq::Writer<TopicType>>
int rtctk::standaloneTools::ShmPub< TopicType, WriterType >::GetNuma ( ) const
inlineprotected

Returns the NUMA node argument set on the command line.

◆ GetQueueName()

template<class TopicType , class WriterType = ipcq::Writer<TopicType>>
std::string rtctk::standaloneTools::ShmPub< TopicType, WriterType >::GetQueueName ( ) const
inlineprotected

Returns the shared memory queue name argument set on the command line.

◆ GetQueueSize()

template<class TopicType , class WriterType = ipcq::Writer<TopicType>>
size_t rtctk::standaloneTools::ShmPub< TopicType, WriterType >::GetQueueSize ( ) const
inlineprotected

Returns the shared memory queue size argument set on the command line.

◆ GetRepeatMode()

template<class TopicType , class WriterType = ipcq::Writer<TopicType>>
bool rtctk::standaloneTools::ShmPub< TopicType, WriterType >::GetRepeatMode ( ) const
inlineprotected

Returns the repeat mode flag set on the command line.

◆ GetSampleDelay()

template<class TopicType , class WriterType = ipcq::Writer<TopicType>>
int rtctk::standaloneTools::ShmPub< TopicType, WriterType >::GetSampleDelay ( ) const
inlineprotected

Returns the sample delay argument set on the command line.

◆ ReadFits()

template<class TopicType , class WriterType = ipcq::Writer<TopicType>>
virtual std::vector< TopicType > rtctk::standaloneTools::ShmPub< TopicType, WriterType >::ReadFits ( std::string filename)
pure virtual

Reads in data from a FITS file.

This is a pure virtual function that must be overloaded by a child class in user code. The user code must allocate the necessary vector of the appropriate size, perform all FITS file access and handling, and return the filled vector containing the data.

If an exception is thrown from this method the process will terminate early with an error message.

Parameters
filenameThe name of the FITS file to read from.
Returns
A vector of data points of type TopicType, i.e. std::vector<TopicType>.

Implemented in ExampleShmPubScao, and ExamplePixelsShmPub.

◆ Run()

template<class TopicType , class WriterType = ipcq::Writer<TopicType>>
int rtctk::standaloneTools::ShmPub< TopicType, WriterType >::Run ( )
inline

Entry point for running the ShmPub.

Calls the required function for creating or loading data to be circulated by the shm writer. then call the main loop WriteToShm

Returns
0 on successful exit.
1 if an exception is caught.

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