Slave part of state pattern.
More...
#include <smartState.hh>
Slave part of state pattern.
Demonstrated in third example
◆ StateSlave()
Constructor.
- Parameters
-
component | management class of the component |
hnd | optional callback interface which is called on each state-change |
serviceName | the name for the internal communication-port (as will be visible on component hull) |
◆ ~StateSlave()
virtual SmartACE::StateSlave::~StateSlave |
( |
| ) |
|
|
virtual |
◆ acquire()
Smart::StatusCode SmartACE::StateSlave::acquire |
( |
const std::string & |
SubState | ) |
|
Wait until specified substate is available and acquire it.
(hint: acquire(nonneutral) blocks until some main state is set.)
- Parameters
-
SubState | is the name of the substate to be acquired. |
- Returns
- status code
- SMART_OK : everything is ok
- SMART_UNKNOWNSTATE : returns immediately if the requested state is unknown
- SMART_NOTACTIVATED : state object of component not yet activated
- SMART_ERROR_COMMUNICATION : communication problems
- SMART_ERROR : something went wrong
◆ activate()
Smart::StatusCode SmartACE::StateSlave::activate |
( |
| ) |
|
Activation is necessary since otherwise no states can be set or acquired.
No more state definitions are possible after activation.
- Returns
- status code
- SMART_OK : configuration has been activated and no more state definitions possible
◆ defineStates()
Smart::StatusCode SmartACE::StateSlave::defineStates |
( |
const std::string & |
MainState, |
|
|
const std::string & |
SubState |
|
) |
| |
Add the SubState to the MainState.
As long as the state object within a component is not activated, one can configure the name of the main states and substates which are afterwards visible externally.
If one or both names are used the first time the corresponding states are created automatically.
- Parameters
-
MainState | is the MainState (parent) |
SubState | is the SubState to be assigned to the MainState |
- Returns
- status code
- SMART_OK : everything is ok
- SMART_ACTIVATED : configuration can not be changed anymore once state object has been activated
- SMART_NOTALLOWED : tried to assign substates to the neutral state or something similar which is not allowed
- SMART_ERROR_COMMUNICATION : communication problems
- SMART_ERROR : something went wrong
◆ getCurrentMainState()
std::string SmartACE::StateSlave::getCurrentMainState |
( |
| ) |
const |
Returns the currently active MainState.
If the StateSlave is in progress of a state-change, the MainState to be entered is returned instead of the currently active MainState. This is more convenient for Monitoring state changes!
- Returns
- MainState string
◆ release()
Smart::StatusCode SmartACE::StateSlave::release |
( |
const std::string & |
SubState | ) |
|
Release specified substate.
- Parameters
-
SubState | is the name of the substate to be released. |
- Returns
- status code
- SMART_OK : everything is ok
- SMART_UNKNOWNSTATE : returns immediately if the requested state is unknown
- SMART_NOTACTIVATED : state object of component not yet activated
- SMART_ERROR_COMMUNICATION : communication problems
- SMART_ERROR : something went wrong
◆ setUpInitialState()
Smart::StatusCode SmartACE::StateSlave::setUpInitialState |
( |
const std::string & |
MainState = "Neutral" | ) |
|
Set the first MainState which is automatically entered after the pattern switched into Alive state.
Per default the MainState Neutral is entered after StateSlave entered Alive state. If this behavior is not wanted this method can be used to change the initial MainState (which must be one of the previously defined MainStates).
- Parameters
-
MainState | is the initial MainState after reaching Alive state |
- Returns
- status code
- SMART_OK : everything OK
- SMART_NOTALLOWED : tried to assign substates to the neutral state or something similar which is not allowed
- SMART_ERROR : something went wrong
◆ setWaitState()
Smart::StatusCode SmartACE::StateSlave::setWaitState |
( |
const std::string & |
MainState | ) |
|
Blocking call to change the current component MainState.
- Parameters
-
MainState |
- StateSlave is only allowed to change the components lifecycle MainState (Alive, Shutdown and FatalError). Other MainStates are only allowed to be changed from the remote StateMaster.
|
- Returns
- status code
- SMART_OK : everything is ok
- SMART_UNKNOWNSTATE : requested mainstate is unknown and therefore no state change has been performed
- SMART_NOTACTIVATED : state object of server component not yet activated
- SMART_CANCELLED : component has been requested to reach neutral state, therefore pending setWaitState has been aborted
- SMART_ERROR : something went wrong
◆ tryAcquire()
Smart::StatusCode SmartACE::StateSlave::tryAcquire |
( |
const std::string & |
SubState | ) |
|
Acquire specified substate if available, otherwise return immediately.
(hint: tryAcquire(nonneutral) can be used e.g. in a query handler to decide whether to process the query or to immediately return an appropriate status code indicating the components inactivity.)
- Parameters
-
SubState | is the name of the substate to be acquired. |
- Returns
- status code
- SMART_OK : everything is ok
- SMART_UNKNOWNSTATE : returns immediately if the requested state is unknown
- SMART_NOTACTIVATED : state object of component not yet activated
- SMART_ERROR_COMMUNICATION : communication problems
- SMART_ERROR : something went wrong
◆ updateState()
void SmartACE::StateSlave::updateState |
( |
void |
| ) |
|
◆ updateStateFromThread()
void SmartACE::StateSlave::updateStateFromThread |
( |
void |
| ) |
|
◆ SmartComponent
◆ StateSlaveHandler
The documentation for this class was generated from the following file: