OpenDaVINCI  4.15.3
odcore::base::module::MasterModule Class Referenceabstract

#include <MasterModule.h>

Inheritance diagram for odcore::base::module::MasterModule:
Inheritance graph

Public Member Functions

 MasterModule (const int32_t &argc, char **argv) throw (exceptions::InvalidArgumentException)
 
virtual ~MasterModule ()
 
virtual
odcore::data::dmcp::ModuleExitCodeMessage::ModuleExitCode 
runModule ()
 
virtual float getFrequency () const
 
uint32_t getIdentifier () const
 
const string getMultiCastGroup () const
 
uint32_t getCID () const
 
bool isProfiling () const
 
bool isRealtime () const
 
uint32_t getRealtimePriority () const
 
virtual void waitForNextFullSecond (const uint32_t &secondsIncrement)
 
void setBreakpoint (Breakpoint *bp)
 
void setModuleState (const odcore::data::dmcp::ModuleStateMessage::ModuleState &s)
 
odcore::data::dmcp::ModuleStateMessage::ModuleState getModuleState ()
 
odcore::data::dmcp::ModuleStateMessage::ModuleState getModuleStateAndWaitForRemainingTimeInTimeslice ()
 

Static Public Member Functions

static bool isVerbose ()
 
static int32_t getVerbosity ()
 
static vector< AbstractModule * > & getListOfModules ()
 

Protected Member Functions

virtual
odcore::data::dmcp::ModuleExitCodeMessage::ModuleExitCode 
body ()=0
 
virtual void wait ()
 

Detailed Description

This class is the base for every master module. A master module masters the configuration for every module as well as the the overall state machines. For using this class one has to override the method "virtual int32_t body();":

class MyModule: public MasterModule
{
public:
MyModule(const int32_t argc, char **argv) :
MasterModule(argc, argv)
{}
int32_t body() {
// Do something.
return OKAY;
}
};
// Regular main method.
int32_t main(int32_t argc, char **argv) {
MyModule myModule(argc, argv);
return myModule.runModule();
}

Constructor & Destructor Documentation

odcore::base::module::MasterModule::MasterModule ( const int32_t &  argc,
char **  argv 
)
throw (exceptions::InvalidArgumentException
)

Constructor.

Parameters
argcNumber of command line arguments.
argvCommand line arguments.
Exceptions
InvalidArgumentExceptionif the signal handler could not be registered.

References odcore::serialization::SerializationFactory::getInstance().

odcore::base::module::MasterModule::~MasterModule ( )
virtual

Member Function Documentation

virtual odcore::data::dmcp::ModuleExitCodeMessage::ModuleExitCode odcore::base::module::MasterModule::body ( )
protectedpure virtual
uint32_t odcore::base::module::AbstractCIDModule::getCID ( ) const
inherited

This method returns the CID.

Returns
CID.
float odcore::base::module::AbstractCIDModule::getFrequency ( ) const
virtualinherited

This method returns the runtime frequency.

Returns
Runtime frequency.

Implements odcore::base::module::Periodic.

uint32_t odcore::base::module::AbstractCIDModule::getIdentifier ( ) const
inherited

This method returns this module's identifier as specified in the command line.

Returns
This module's identifier.
vector< AbstractModule * > & odcore::base::module::AbstractModule::getListOfModules ( )
staticinherited

This method returns the list of created modules for this class. This method can be used to broadcast signals to all instances.

Referenced by odcore::base::module::finalize(), odcore::base::module::signalHandler(), and odcore::base::module::AbstractModule::~AbstractModule().

odcore::data::dmcp::ModuleStateMessage::ModuleState odcore::base::module::AbstractModule::getModuleState ( )
inherited

This method returns the module MODULE_STATE.

Returns
Module MODULE_STATE.

Referenced by odcore::base::module::AbstractModule::getModuleStateAndWaitForRemainingTimeInTimeslice().

odcore::data::dmcp::ModuleStateMessage::ModuleState odcore::base::module::AbstractModule::getModuleStateAndWaitForRemainingTimeInTimeslice ( )
inherited

This method returns the module MODULE_STATE and suspends the execution of the calling thread for the rest of the current time slice.

Returns
Module MODULE_STATE.

References odcore::base::module::AbstractModule::calledGetModuleState(), and odcore::base::module::AbstractModule::getModuleState().

Referenced by odcontext::base::RuntimeControl::run().

const string odcore::base::module::AbstractCIDModule::getMultiCastGroup ( ) const
inherited

This method returns the module's multicast group as specified in the command line

uint32_t odcore::base::module::AbstractCIDModule::getRealtimePriority ( ) const
inherited

This method returns the priority, if –realtime is enabled.

Returns
Scheduling priority.
int32_t odcore::base::module::AbstractCIDModule::getVerbosity ( )
staticinherited

This method returns the level of verbosity.

Returns
Level of verbosity.
bool odcore::base::module::AbstractCIDModule::isProfiling ( ) const
inlineinherited

This method returns true, if –profiling is enabled.

Returns
true if profiling is enabled.
bool odcore::base::module::AbstractCIDModule::isRealtime ( ) const
inlineinherited

This method returns true, if –realtime is enabled.

Returns
true if realtime is enabled.
bool odcore::base::module::AbstractCIDModule::isVerbose ( )
staticinherited

This method returns true, if –verbose is enabled.

Returns
true if verbose.
odcore::data::dmcp::ModuleExitCodeMessage::ModuleExitCode odcore::base::module::MasterModule::runModule ( )
virtual

This method executes the application body.

Implements odcore::base::module::InterruptibleModule.

void odcore::base::module::InterruptibleModule::setBreakpoint ( Breakpoint bp)
inherited
void odcore::base::module::AbstractModule::setModuleState ( const odcore::data::dmcp::ModuleStateMessage::ModuleState &  s)
inherited

This method sets the module MODULE_STATE.

Parameters
sMODULE_STATE of the module.

Referenced by odcontext::base::TimeTriggeredConferenceClientModuleRunner::beforeStop(), odcontext::base::RuntimeControl::run(), and odcore::base::module::signalHandler().

void odcore::base::module::AbstractModule::wait ( )
protectedvirtualinherited

This method is called to enforce a specific frequency.

References odcore::base::Thread::usleepFor().

Referenced by odcore::base::module::AbstractModule::calledGetModuleState().

void odcore::base::module::AbstractCIDModule::waitForNextFullSecond ( const uint32_t &  secondsIncrement)
virtualinherited

This method suspends the execution of this thread to the next full second.

Parameters
secondsIncrementFrom the current point in time, for how many full seconds shall we wait?

Implements odcore::base::module::AbstractModule.

References odcore::base::Thread::usleepUntil().