Privacy
An open-source, flexible 3D physical simulation framework
mars::data_broker::DataBrokerInterface Class Referenceabstract

The interface every DataBroker should implement. More...

#include <DataBrokerInterface.h>

Public Member Functions

 DataBrokerInterface (lib_manager::LibManager *theManager)
 Constructor takes no arguments. More...
 
virtual ~DataBrokerInterface ()
 
virtual int getLibVersion () const
 
virtual const std::string getLibName () const
 
 CREATE_MODULE_INFO ()
 
virtual bool createTimer (const std::string &timerName)=0
 creates a new timer with the given name More...
 
virtual bool stepTimer (const std::string &timerName, long step=1)=0
 advances the timer timerName by step More...
 
virtual bool registerTimedReceiver (ReceiverInterface *receiver, const std::string &groupName, const std::string &dataName, const std::string &timerName, int updatePeriod, int callbackParam=0)=0
 registers a receiver for a group/data with a timer More...
 
virtual bool unregisterTimedReceiver (ReceiverInterface *receiver, const std::string &groupName, const std::string &dataName, const std::string &timerName)=0
 unregister a receiver from receiving callbacks from a timer for certain group/data More...
 
virtual bool registerTimedProducer (ProducerInterface *producer, const std::string &groupName, const std::string &dataName, const std::string &timerName, int updatePeriod, int callbackParam=0)=0
 
virtual bool unregisterTimedProducer (ProducerInterface *producer, const std::string &groupName, const std::string &dataName, const std::string &timerName)=0
 
virtual bool createTrigger (const std::string &triggerName)=0
 create a new trigger with the given name More...
 
virtual bool trigger (const std::string &triggerName)=0
 triggers the trigger triggerName More...
 
virtual bool registerTriggeredReceiver (ReceiverInterface *receiver, const std::string &groupName, const std::string &dataName, const std::string &triggerName, int callbackParam=0)=0
 registers a receiver for a group/data with a trigger More...
 
virtual bool unregisterTriggeredReceiver (ReceiverInterface *receiver, const std::string &groupName, const std::string &dataName, const std::string &triggerName)=0
 register a receiver from receiving callbacks from a trigger for certain group/data More...
 
virtual bool registerSyncReceiver (ReceiverInterface *receiver, const std::string &groupName, const std::string &dataName, int callbackParam=0)=0
 register a receiver to receive a synchronous callback for a certain stream More...
 
virtual bool unregisterSyncReceiver (ReceiverInterface *receiver, const std::string &groupName, const std::string &dataName)=0
 unregister a receiver from receiving callbacks for certain group/data More...
 
virtual bool registerAsyncReceiver (ReceiverInterface *receiver, const std::string &groupName, const std::string &dataName, int callbackParam=0)=0
 register a receiver to receive a asynchronous callback for a certain stream More...
 
virtual bool unregisterAsyncReceiver (ReceiverInterface *receiver, const std::string &groupName, const std::string &dataName)=0
 unregister a receiver from receiving callbacks for certain group/data More...
 
virtual unsigned long pushData (const std::string &groupName, const std::string &dataName, const DataPackage &dataPackage, const ReceiverInterface *producer, PackageFlag flags)=0
 pushes a DataPackage into the DataBroker More...
 
virtual unsigned long pushData (unsigned long id, const DataPackage &dataPackage, const ReceiverInterface *producer=NULL)=0
 pushes a DataPackage into the DataBroker More...
 
virtual unsigned long getDataID (const std::string &groupName, const std::string &dataName) const =0
 get the unique dataId assosiated with a given groupName and dataName More...
 
virtual const DataInfo getDataInfo (const std::string &groupName, const std::string &dataName) const =0
 get the DataInfo assosiated with a certain DataPackage More...
 
virtual const DataPackage getDataPackage (unsigned long dataId) const =0
 get the DataPackage with a given dataId More...
 
virtual const std::vector< DataInfogetDataList (PackageFlag flag=DATA_PACKAGE_NO_FLAG) const =0
 get a list of all DataInfo items currently in the DataBroker More...
 
virtual void connectDataItems (const std::string &fromGroupName, const std::string &fromDataName, const std::string &fromItemName, const std::string &toGroupName, const std::string &toDataName, const std::string &toItemName)=0
 
virtual void disconnectDataItems (const std::string &fromGroupName, const std::string &fromDataName, const std::string &fromItemName, const std::string &toGroupName, const std::string &toDataName, const std::string &toItemName)=0
 
virtual void disconnectDataItems (const std::string &toGroupName, const std::string &toDataName, const std::string &toItemName)=0
 
virtual void pushMessage (MessageType messageType, const std::string &format, va_list args)=0
 
virtual void pushMessage (MessageType messageType, const std::string &format,...)=0
 
virtual void pushFatal (const std::string &format,...)=0
 
virtual void pushError (const std::string &format,...)=0
 
virtual void pushWarning (const std::string &format,...)=0
 
virtual void pushInfo (const std::string &format,...)=0
 
virtual void pushDebug (const std::string &format,...)=0
 
- Public Member Functions inherited from lib_manager::LibInterface
 LibInterface (LibManager *theManager)
 
virtual ~LibInterface (void)
 
ModuleInfo getModuleInfo () const
 
virtual void newLibLoaded (const std::string &libName)
 
virtual void createModuleInfo (void)
 

Additional Inherited Members

- Protected Attributes inherited from lib_manager::LibInterface
LibManagerlibManager
 
ModuleInfo moduleInfo
 

Detailed Description

The interface every DataBroker should implement.

Definition at line 105 of file DataBrokerInterface.h.

Constructor & Destructor Documentation

◆ DataBrokerInterface()

mars::data_broker::DataBrokerInterface::DataBrokerInterface ( lib_manager::LibManager theManager)
inline

Constructor takes no arguments.

Definition at line 111 of file DataBrokerInterface.h.

◆ ~DataBrokerInterface()

virtual mars::data_broker::DataBrokerInterface::~DataBrokerInterface ( )
inlinevirtual

Definition at line 114 of file DataBrokerInterface.h.

Member Function Documentation

◆ connectDataItems()

virtual void mars::data_broker::DataBrokerInterface::connectDataItems ( const std::string &  fromGroupName,
const std::string &  fromDataName,
const std::string &  fromItemName,
const std::string &  toGroupName,
const std::string &  toDataName,
const std::string &  toItemName 
)
pure virtual

◆ CREATE_MODULE_INFO()

mars::data_broker::DataBrokerInterface::CREATE_MODULE_INFO ( )

◆ createTimer()

virtual bool mars::data_broker::DataBrokerInterface::createTimer ( const std::string &  timerName)
pure virtual

creates a new timer with the given name

Parameters
timerNamethe name of the new timer
Returns
false if a timer with the given name already exists. true otherwise.
See also
stepTimer, registerTimedReceiver, unregisterTimedReceiver, ReceiverInterface

Implemented in mars::data_broker::DataBroker.

◆ createTrigger()

virtual bool mars::data_broker::DataBrokerInterface::createTrigger ( const std::string &  triggerName)
pure virtual

create a new trigger with the given name

Parameters
triggerNamethe name of the new trigger
Returns
false if a trigger with the given name already exists. true otherwise.
See also
trigger, registerTriggeredReceiver, unregisterTriggeredReceiver, ReceiverInterface

Implemented in mars::data_broker::DataBroker.

◆ disconnectDataItems() [1/2]

virtual void mars::data_broker::DataBrokerInterface::disconnectDataItems ( const std::string &  fromGroupName,
const std::string &  fromDataName,
const std::string &  fromItemName,
const std::string &  toGroupName,
const std::string &  toDataName,
const std::string &  toItemName 
)
pure virtual

◆ disconnectDataItems() [2/2]

virtual void mars::data_broker::DataBrokerInterface::disconnectDataItems ( const std::string &  toGroupName,
const std::string &  toDataName,
const std::string &  toItemName 
)
pure virtual

◆ getDataID()

virtual unsigned long mars::data_broker::DataBrokerInterface::getDataID ( const std::string &  groupName,
const std::string &  dataName 
) const
pure virtual

get the unique dataId assosiated with a given groupName and dataName

Parameters
groupNameThe DataInfo::groupName of the DataPackage.
dataNameThe DataInfo::dataName of the DataPackage.
Returns
The DataInfo::dataId of the DataPackage with the given groupName and dataName. If no such package exists this method returns 0.

Implemented in mars::data_broker::DataBroker.

◆ getDataInfo()

virtual const DataInfo mars::data_broker::DataBrokerInterface::getDataInfo ( const std::string &  groupName,
const std::string &  dataName 
) const
pure virtual

get the DataInfo assosiated with a certain DataPackage

Parameters
groupNameThe DataInfo::groupName of the DataPackage
dataNameThe DataInfo::dataName of the DataPackage
Returns
A copy of the DataInfo of the DataPackage with the given groupName and dataName. If no such package exists this method returns and DataInfo object with dataId set to 0 and empty strings as groupName and dataName.

Implemented in mars::data_broker::DataBroker.

◆ getDataList()

virtual const std::vector<DataInfo> mars::data_broker::DataBrokerInterface::getDataList ( PackageFlag  flag = DATA_PACKAGE_NO_FLAG) const
pure virtual

get a list of all DataInfo items currently in the DataBroker

Parameters
flagA bitmask to filter out what kind of DataPackages we are interested in.

Implemented in mars::data_broker::DataBroker.

◆ getDataPackage()

virtual const DataPackage mars::data_broker::DataBrokerInterface::getDataPackage ( unsigned long  dataId) const
pure virtual

get the DataPackage with a given dataId

Parameters
dataIdThe unique DataInfo::dataId of the DataPackage to return.
Returns
A copy of the DataPackage with the given dataId.

Implemented in mars::data_broker::DataBroker.

◆ getLibName()

virtual const std::string mars::data_broker::DataBrokerInterface::getLibName ( ) const
inlinevirtual

Implements lib_manager::LibInterface.

Definition at line 119 of file DataBrokerInterface.h.

◆ getLibVersion()

virtual int mars::data_broker::DataBrokerInterface::getLibVersion ( ) const
inlinevirtual

Implements lib_manager::LibInterface.

Definition at line 117 of file DataBrokerInterface.h.

◆ pushData() [1/2]

virtual unsigned long mars::data_broker::DataBrokerInterface::pushData ( const std::string &  groupName,
const std::string &  dataName,
const DataPackage dataPackage,
const ReceiverInterface producer,
PackageFlag  flags 
)
pure virtual

pushes a DataPackage into the DataBroker

Parameters
groupNameA string to identify different DataPackages belonging to the same group or category. The combination of groupName and dataName should be unique.
dataNameA string to to identify this DataPackage. The combination of groupName and dataName should be unique.
dataPackageThe DataPackage that will be distributed to the receivers.
producerIn case a receiver pushes data to the stream it has registered itself to, it normally would get a callback. To prevent this self-callback it may pass pointer to itself to prevent receiving a callback for this single push it did itself. If NULL is passed this has no effect.
flagsThis is used to indicate the nature of the data.
Returns
A unique pushId.

An object that regularly pushes data to the DataBroker should only use this method once and record the returned pushId. Subsequently it should use the pushId and call pushData(unsigned long,...) for better performance.

See also
pushData(unsigned long, const DataPackage&, const ReceiverInterface*)

Implemented in mars::data_broker::DataBroker.

◆ pushData() [2/2]

virtual unsigned long mars::data_broker::DataBrokerInterface::pushData ( unsigned long  id,
const DataPackage dataPackage,
const ReceiverInterface producer = NULL 
)
pure virtual

pushes a DataPackage into the DataBroker

Parameters
idThe pushId previously returned by this method.
dataPackageThe DataPackage that will be distributed to the receivers.
producerIn case a receiver pushes data to the stream it has registered itself to, it normally would get a callback. To prevent this self-callback it may pass pointer to itself to prevent receiving a callback for this single push it did itself. If NULL is passed this has no effect.
Returns
The pushId id.

An object that regularly pushes data to the DataBroker should use the named version of this method once and record the returned pushId. Subsequently it should use the pushId and call this method for better performance.

See also
pushData(const std::string& , const std::string&, const DataPackage&, const ReceiverInterface*, PackageFlag)

Implemented in mars::data_broker::DataBroker.

◆ pushDebug()

virtual void mars::data_broker::DataBrokerInterface::pushDebug ( const std::string &  format,
  ... 
)
pure virtual

◆ pushError()

virtual void mars::data_broker::DataBrokerInterface::pushError ( const std::string &  format,
  ... 
)
pure virtual

◆ pushFatal()

virtual void mars::data_broker::DataBrokerInterface::pushFatal ( const std::string &  format,
  ... 
)
pure virtual

◆ pushInfo()

virtual void mars::data_broker::DataBrokerInterface::pushInfo ( const std::string &  format,
  ... 
)
pure virtual

◆ pushMessage() [1/2]

virtual void mars::data_broker::DataBrokerInterface::pushMessage ( MessageType  messageType,
const std::string &  format,
va_list  args 
)
pure virtual

◆ pushMessage() [2/2]

virtual void mars::data_broker::DataBrokerInterface::pushMessage ( MessageType  messageType,
const std::string &  format,
  ... 
)
pure virtual

◆ pushWarning()

virtual void mars::data_broker::DataBrokerInterface::pushWarning ( const std::string &  format,
  ... 
)
pure virtual

◆ registerAsyncReceiver()

virtual bool mars::data_broker::DataBrokerInterface::registerAsyncReceiver ( ReceiverInterface receiver,
const std::string &  groupName,
const std::string &  dataName,
int  callbackParam = 0 
)
pure virtual

register a receiver to receive a asynchronous callback for a certain stream

Parameters
receiverThe ReceiverInterface that should be called whenever a certain stream is pushed to the DataBroker.
groupNameThe groupName of the DataPackage the receiver is interested in.
dataNameThe dataName of the DataPackage the receiver is interested in.
callbackParamAn optional int that will be passed back to the receiver in receiveData. This can be used by the receiver to distinguish callbacks from different registrations.
Returns
true if the registration was successful. false if no DataPackage with the given groupName and dataName exists. This doesn't necessarily indicate an error. The registration will be cached and may be performed when the requested DataPackage is pushed at a later time.

The callbacks to the receivers will be performed asynchronous by the DataBroker. This means that the callback will occur from a different thread as the one from which pushData was called. The receivers will only get a callback for the latest pushData call. This means that asynchronous receivers might miss some DataPackages when they are pushed fast to the DataBroker. If you cannot afford to miss DataPackages you should use registerSyncReceiver.

See also
unregisterAsyncReceiver, registerSyncReceiver, ReceiverInterface, pushData

Implemented in mars::data_broker::DataBroker.

◆ registerSyncReceiver()

virtual bool mars::data_broker::DataBrokerInterface::registerSyncReceiver ( ReceiverInterface receiver,
const std::string &  groupName,
const std::string &  dataName,
int  callbackParam = 0 
)
pure virtual

register a receiver to receive a synchronous callback for a certain stream

Parameters
receiverThe ReceiverInterface that should be called whenever a certain stream is pushed to the DataBroker.
groupNameThe groupName of the DataPackage the receiver is interested in.
dataNameThe dataName of the DataPackage the receiver is interested in.
callbackParamAn optional int that will be passed back to the receiver in receiveData. This can be used by the receiver to distinguish callbacks from different registrations.
Returns
true if the registration was successful. false if no DataPackage with the given groupName and dataName exists. This doesn't necessarily indicate an error. The registration will be cached and may be performed when the requested DataPackage is pushed at a later time.

The callbacks to the receivers will be performed synchronous by the DataBroker. This means that the callback will occur from within the same thread where the pushData happened and the call to pushData will not return until all receivers that registered to this stream were called and returned from their callbacks.

See also
unregisterSyncReceiver, registerAsyncReceiver, ReceiverInterface, pushData

Implemented in mars::data_broker::DataBroker.

◆ registerTimedProducer()

virtual bool mars::data_broker::DataBrokerInterface::registerTimedProducer ( ProducerInterface producer,
const std::string &  groupName,
const std::string &  dataName,
const std::string &  timerName,
int  updatePeriod,
int  callbackParam = 0 
)
pure virtual

◆ registerTimedReceiver()

virtual bool mars::data_broker::DataBrokerInterface::registerTimedReceiver ( ReceiverInterface receiver,
const std::string &  groupName,
const std::string &  dataName,
const std::string &  timerName,
int  updatePeriod,
int  callbackParam = 0 
)
pure virtual

registers a receiver for a group/data with a timer

Parameters
receiverThe ReceiverInterface that should be called back.
groupNameThe groupName of the DataPackage the receiver is interested in.
dataNameThe dataName of the DataPackage the receiver is interested in.
timerNameThe name of the timer that should call the receiver.
updatePeriodThe number of timer steps that should lie between callbacks. If you pass 0 the receiver will be called back every time the timer is stepped.
callbackParamAn optional int that will be passed back to the receiver in receiveData. This can be used by the receiver to distinguish callbacks from different registrations.
Returns
false if the timer timerName doesn't exist. true otherwise. If this method returns false this doesn't necessarily indicate an error. The registration will be cached in case the timer gets created at a later time. This is only intended as feedback in case you know the timer should exist.
See also
createTimer, stepTimer, unregisterTimedReceiver, ReceiverInterface

Implemented in mars::data_broker::DataBroker.

◆ registerTriggeredReceiver()

virtual bool mars::data_broker::DataBrokerInterface::registerTriggeredReceiver ( ReceiverInterface receiver,
const std::string &  groupName,
const std::string &  dataName,
const std::string &  triggerName,
int  callbackParam = 0 
)
pure virtual

registers a receiver for a group/data with a trigger

Parameters
receiverThe ReceiverInterface that should be called back.
groupNameThe groupName of the DataPackage the receiver is intersted in.
dataNameThe dataName of the DataPackage the receiver is intersted in.
triggerNameThe name of the trigger that should call the receiver.
callbackParamAn optional int that will be passed back to the receiver in receiveData. This can be used by the receiver to distinguish callbacks from different registrations.
Returns
false if the trigger triggerName doesn't exist. true otherwise. If this method returns false this doesn't necessarily indicate an error. The registration will be cached in case the trigger gets created at a later time. This is only intended as feedback in case you know the trigger should exist.
See also
createTrigger, trigger, unregisterTriggeredReceiver, ReceiverInterface

Implemented in mars::data_broker::DataBroker.

◆ stepTimer()

virtual bool mars::data_broker::DataBrokerInterface::stepTimer ( const std::string &  timerName,
long  step = 1 
)
pure virtual

advances the timer timerName by step

Parameters
timerNameThe name of the timer that should be stepped. It should have been previously created with createTimer.
stepThe amount by which the timer should be stepped. This can be anything from the amount of seconds passed in real time to an artificial simulation time or something entirely different. It's up to you.
Returns
true if the timer was stepped. false if no timer with the name timerName exists.

Stepping a timer with this function will advance its internal time by the given step. It will then check all receivers who registered to this timer with registerTimedReceiver if their update time has expired in which case they will be called from within this thread.

See also
createTimer, registerTimedReceiver, unregisterTimedReceiver, ReceiverInterface

Implemented in mars::data_broker::DataBroker.

◆ trigger()

virtual bool mars::data_broker::DataBrokerInterface::trigger ( const std::string &  triggerName)
pure virtual

triggers the trigger triggerName

Parameters
triggerNameThe name of the trigger that should be triggered. It should have been previously created with createTrigger.
Returns
true if the trigger was triggered. false if no trigger with the name triggerName exists.

Triggering a trigger causes it to send the latest DataPackage to all receivers that registered to this trigger.

See also
createTrigger, registerTriggeredReceiver, unregisterTriggeredReceiver, ReceiverInterface

Implemented in mars::data_broker::DataBroker.

◆ unregisterAsyncReceiver()

virtual bool mars::data_broker::DataBrokerInterface::unregisterAsyncReceiver ( ReceiverInterface receiver,
const std::string &  groupName,
const std::string &  dataName 
)
pure virtual

unregister a receiver from receiving callbacks for certain group/data

Parameters
receiverThe ReceiverInterface that wants to unregister.
groupNameThe groupName of the DataPackage for which the receiver no longer wishes to receive callbacks.
dataNameThe dataName of the DataPackage for which the receiver no longer wishes to receive callbacks.
Returns
true if the receiver successfully unregistered. false otherwise. Returning false could have several reasons
  • No DataPackage with the given groupName and dataName exist.
  • The receiver was not registered for the DataPackage of the given groupName and dataName.
See also
registerAsyncReceiver, ReceiverInterface

Implemented in mars::data_broker::DataBroker.

◆ unregisterSyncReceiver()

virtual bool mars::data_broker::DataBrokerInterface::unregisterSyncReceiver ( ReceiverInterface receiver,
const std::string &  groupName,
const std::string &  dataName 
)
pure virtual

unregister a receiver from receiving callbacks for certain group/data

Parameters
receiverThe ReceiverInterface that wants to unregister.
groupNameThe groupName of the DataPackage for which the receiver no longer wishes to receive callbacks.
dataNameThe dataName of the DataPackage for which the receiver no longer wishes to receive callbacks.
Returns
true if the receiver successfully unregistered. false otherwise. Returning false could have several reasons
  • No DataPackage with the given groupName and dataName exist.
  • The receiver was not registered for the DataPackage of the given groupName and dataName.
See also
registerSyncReceiver, ReceiverInterface

Implemented in mars::data_broker::DataBroker.

◆ unregisterTimedProducer()

virtual bool mars::data_broker::DataBrokerInterface::unregisterTimedProducer ( ProducerInterface producer,
const std::string &  groupName,
const std::string &  dataName,
const std::string &  timerName 
)
pure virtual

◆ unregisterTimedReceiver()

virtual bool mars::data_broker::DataBrokerInterface::unregisterTimedReceiver ( ReceiverInterface receiver,
const std::string &  groupName,
const std::string &  dataName,
const std::string &  timerName 
)
pure virtual

unregister a receiver from receiving callbacks from a timer for certain group/data

Parameters
receiverThe ReceiverInterface that wants to unregister.
groupNameThe groupName of the DataPackage for which the receiver no longer wishes to receive callbacks from the timer.
dataNameThe dataName of the DataPackage for which the receiver no longer wishes to receive callbacks from the timer.
timerNameThe name of the timer that should stop notifying the receiver.
Returns
true if the receiver successfully unregistered. false otherwise. Returning false could have several reasons
  • No timer called timerName was created
  • No DataPackage with the given groupName and dataName exist.
  • The receiver was not registered with this timer for the DataPackage of the given groupName and dataName.
See also
createTimer, stepTimer, registerTimedReceiver, ReceiverInterface

Implemented in mars::data_broker::DataBroker.

◆ unregisterTriggeredReceiver()

virtual bool mars::data_broker::DataBrokerInterface::unregisterTriggeredReceiver ( ReceiverInterface receiver,
const std::string &  groupName,
const std::string &  dataName,
const std::string &  triggerName 
)
pure virtual

register a receiver from receiving callbacks from a trigger for certain group/data

Parameters
receiverThe ReceiverInterface that wants to unregister.
groupNameThe groupName of the DataPackage for which the receiver no longer wishes to receive callbacks from the trigger.
dataNameThe dataName of the DataPackage for which the receiver no longer wishes to receive callbacks from the trigger.
triggerNameThe name of the trigger that should stop notifying the receiver.
Returns
true if the receiver successfully unregistered. false otherwise. Returning false could have several reasons
  • No trigger called timerName was created
  • No DataPackage with the given groupName and dataName exist.
  • The receiver was not registered with this trigger for the DataPackage of the given groupName and dataName.
See also
createTrigger, trigger, registerTriggeredReceiver, ReceiverInterface

Implemented in mars::data_broker::DataBroker.


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