AceSmartSoft API Documentation
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
SmartACE::SmartComponent Class Reference

Component management class. More...

#include <smartComponent.hh>

Inheritance diagram for SmartACE::SmartComponent:

Public Member Functions

 SmartComponent (const std::string &serverName, int argc, char **argv, SmartACE::ReactorTask *reactor=NULL, const ACE_Sched_Params &sched_params=ACE_Sched_Params(ACE_SCHED_OTHER, ACE_THR_PRI_OTHER_DEF), const char *compileDate=__DATE__, const char *compileTime=__TIME__)
 Initializes the component. More...
 
virtual ~SmartComponent ()
 Destructor. More...
 
virtual Smart::StatusCode run (void)
 Runs the SmartSoft framework within a component which includes handling intercomponent communication etc. More...
 
virtual void signal_shutdown (void)
 
virtual Smart::ITimerManager * getTimerManager ()
 get timer-manager for registering timer-handlers More...
 
Smart::StatusCode blocking (const bool b)
 Allow or abort and reject blocking calls in communication patterns of this component. More...
 
void setStateSlave (StateSlave *state)
 
StateSlavegetStateSlave () const
 
SmartACE::ReactorTaskgetReactorTask ()
 
Smart::StatusCode addCV (SmartCVwithMemory *cond)
 
Smart::StatusCode removeCV (SmartCVwithMemory *cond)
 
Smart::StatusCode addCV (SmartCVwithoutMemory *cond)
 
Smart::StatusCode removeCV (SmartCVwithoutMemory *cond)
 
Smart::StatusCode addSmartMonitor (SmartMonitor *monitor)
 
Smart::StatusCode removeSmartMonitor (SmartMonitor *monitor)
 
Smart::StatusCode waitForCond (SmartCondClass &cond)
 
Smart::StatusCode waitForCond (SmartCntCondClass &cond)
 
void enqueue (void *, void(*internalServInitDisc)(void *, int), int cid)
 
void sign_on (void *ptr)
 
void sign_off (void *ptr)
 

Protected Member Functions

void waitOnRuntimeCondVar ()
 
virtual int handle_signal (int signum, siginfo_t *, ucontext_t *)
 Signal handler method for SIGINT. More...
 
virtual void signalSmartTasksToStop (const Smart::Duration &watchdogTime=std::chrono::seconds(2))
 
virtual void cleanUpInternalResources ()
 
virtual void setTimedModeForAllSmartMonitors (const Smart::Duration &timeout)
 

Protected Attributes

SIDhandler srvInitDiscHandler
 
ShutdownTimer shutdownWatchdog
 
StateSlavestate
 
bool componentIsRunning
 
bool firstCallOfCleanupMethod
 
bool first_call_of_handle_signal
 
TimerManagerThread timerThread
 
bool ownReactor
 
SmartACE::ReactorTaskreactorTask
 

Detailed Description

Component management class.

Every component needs exactly one component management class which wraps basic services of the SmartSoft framework. This infrastructure is for example needed by the communication patterns.

The main thread of a component is used by this class to run the SmartSoft framework. Therefore all user activities must be started before in separate threads. Further details can be found in the examples.

Constructor & Destructor Documentation

◆ SmartComponent()

SmartACE::SmartComponent::SmartComponent ( const std::string &  serverName,
int  argc,
char **  argv,
SmartACE::ReactorTask reactor = NULL,
const ACE_Sched_Params &  sched_params = ACE_Sched_Params(ACE_SCHED_OTHER, ACE_THR_PRI_OTHER_DEF),
const char *  compileDate = __DATE__,
const char *  compileTime = __TIME__ 
)

Initializes the component.

Parameters
serverNameunique name of the whole component, which is used by the clients to address this server
argc# of command line arguments
argvarray of command line arguments
reactoroptionally a customized implementation of the Reactor can be used (otherwise component automatically initializes an own reactor)
sched_paramsoptional scheduling parameters used for the related internal reactor thread
compileDatecompile date, just for debugging, don't touch
compileTimecompile time, just for debugging, don't touch

◆ ~SmartComponent()

virtual SmartACE::SmartComponent::~SmartComponent ( )
virtual

Destructor.

Member Function Documentation

◆ addCV() [1/2]

Smart::StatusCode SmartACE::SmartComponent::addCV ( SmartCVwithMemory cond)

Returns the pointer of the shutdown task.

called by the communication patterns to add their condition variable to the component. Used to set the cancelled state for all communication patterns of a component by a single call to the blocking() member function of this class. This is for example used by the state pattern.

◆ addCV() [2/2]

Smart::StatusCode SmartACE::SmartComponent::addCV ( SmartCVwithoutMemory cond)

see above

◆ addSmartMonitor()

Smart::StatusCode SmartACE::SmartComponent::addSmartMonitor ( SmartMonitor monitor)

see above

◆ blocking()

Smart::StatusCode SmartACE::SmartComponent::blocking ( const bool  b)

Allow or abort and reject blocking calls in communication patterns of this component.

if blocking is set to false all blocking calls of all communication patterns of this component return with SMART_CANCELLED. This can be used to abort blocking calls of ALL communication patterns inside a component.

Parameters
b(blocking) true/false
Returns
status code
  • SMART_OK : new mode set
  • SMART_ERROR : something went wrong

◆ cleanUpInternalResources()

virtual void SmartACE::SmartComponent::cleanUpInternalResources ( )
protectedvirtual

◆ enqueue()

void SmartACE::SmartComponent::enqueue ( void *  ,
void(*)(void *, int)  internalServInitDisc,
int  cid 
)

see thesis from Schlegel on page 195!

◆ getReactorTask()

SmartACE::ReactorTask* SmartACE::SmartComponent::getReactorTask ( )
inline

Returns the reactor that is responsible for handling all Events of this component and its communication patterns

◆ getStateSlave()

StateSlave* SmartACE::SmartComponent::getStateSlave ( ) const

Returns the reference for the StateSlave if one is started otherwise NULL is returned.

◆ getTimerManager()

virtual Smart::ITimerManager* SmartACE::SmartComponent::getTimerManager ( )
inlinevirtual

get timer-manager for registering timer-handlers

An instance of an ITimerManager is instantiated by an IComponent. An ITimerManager allows activation of ITimerHandler instances that are triggered (once or repeatedly) after a given time period.

Returns
a pointer to the ITimerManager

◆ handle_signal()

virtual int SmartACE::SmartComponent::handle_signal ( int  signum,
siginfo_t *  ,
ucontext_t *   
)
protectedvirtual

Signal handler method for SIGINT.

The Default constructor registers this method to SIGINT.

This method calls exit(0) on SIGINT, resulting in a uncontrolled shutdown, no destructors will be called etc.

Overriding this method in a subclass is recommended to enable a clean shutdown after a Ctrl-C.

Warning
this code runs in a signal handler (see http://www.cs.wustl.edu/~schmidt/signal-patterns.html for the approach)

◆ removeCV() [1/2]

Smart::StatusCode SmartACE::SmartComponent::removeCV ( SmartCVwithMemory cond)

see above

◆ removeCV() [2/2]

Smart::StatusCode SmartACE::SmartComponent::removeCV ( SmartCVwithoutMemory cond)

see above

◆ removeSmartMonitor()

Smart::StatusCode SmartACE::SmartComponent::removeSmartMonitor ( SmartMonitor monitor)

see above

◆ run()

virtual Smart::StatusCode SmartACE::SmartComponent::run ( void  )
virtual

Runs the SmartSoft framework within a component which includes handling intercomponent communication etc.

This method is called in the main()-routine of a component after all initializations including activation of user threads are finished.

Returns
status code
  • SMART_ERROR_UNKNOWN: unknown error (probably a corba problem)
  • SMART_OK: gracefully terminated

◆ setStateSlave()

void SmartACE::SmartComponent::setStateSlave ( StateSlave state)

Returns the reference for the StateSlave if one is started otherwise NULL is returned.

◆ setTimedModeForAllSmartMonitors()

virtual void SmartACE::SmartComponent::setTimedModeForAllSmartMonitors ( const Smart::Duration &  timeout)
protectedvirtual

◆ sign_off()

void SmartACE::SmartComponent::sign_off ( void *  ptr)

see thesis from Schlegel on page 195!

◆ sign_on()

void SmartACE::SmartComponent::sign_on ( void *  ptr)

see thesis from Schlegel on page 195!

◆ signal_shutdown()

virtual void SmartACE::SmartComponent::signal_shutdown ( void  )
virtual

◆ signalSmartTasksToStop()

virtual void SmartACE::SmartComponent::signalSmartTasksToStop ( const Smart::Duration &  watchdogTime = std::chrono::seconds(2))
protectedvirtual

◆ waitForCond() [1/2]

Smart::StatusCode SmartACE::SmartComponent::waitForCond ( SmartCondClass cond)

provide interruptable wait on condition variable.

◆ waitForCond() [2/2]

Smart::StatusCode SmartACE::SmartComponent::waitForCond ( SmartCntCondClass cond)

provide interruptable wait on condition variable.

◆ waitOnRuntimeCondVar()

void SmartACE::SmartComponent::waitOnRuntimeCondVar ( )
protected

Member Data Documentation

◆ componentIsRunning

bool SmartACE::SmartComponent::componentIsRunning
protected

◆ first_call_of_handle_signal

bool SmartACE::SmartComponent::first_call_of_handle_signal
protected

variable is used to detect the first call of SIGINT handler and to ignore all further calls

◆ firstCallOfCleanupMethod

bool SmartACE::SmartComponent::firstCallOfCleanupMethod
protected

◆ ownReactor

bool SmartACE::SmartComponent::ownReactor
protected

◆ reactorTask

SmartACE::ReactorTask* SmartACE::SmartComponent::reactorTask
protected

◆ shutdownWatchdog

ShutdownTimer SmartACE::SmartComponent::shutdownWatchdog
protected

◆ srvInitDiscHandler

SIDhandler SmartACE::SmartComponent::srvInitDiscHandler
protected

◆ state

StateSlave* SmartACE::SmartComponent::state
protected

◆ timerThread

TimerManagerThread SmartACE::SmartComponent::timerThread
protected

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