rad  3.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Member Functions | List of all members
rad::SMAdapter Class Reference

#include <smAdapter.hpp>

Inheritance diagram for rad::SMAdapter:
scxml4cpp::EventListener scxml4cpp::StatusListener

Public Member Functions

 SMAdapter (boost::asio::io_service &ios, scxml4cpp::Context *context, scxml4cpp::EventQueue &external_events)
 
virtual ~SMAdapter ()
 
void Load (const std::string &filename, std::list< scxml4cpp::Action * > *action_list, std::list< scxml4cpp::Activity * > *activity_list)
 
void Append (const std::string &filename, std::list< scxml4cpp::Action * > *action_list, std::list< scxml4cpp::Activity * > *activity_list)
 
void Start ()
 
void Stop ()
 
void PostEvent (SharedEvent e)
 
void ProcessEvent ()
 
void ProcessEvent (scxml4cpp::Event *e)
 
void ProcessEvent (const AnyEvent &e)
 
void SetStatusRepresentation (const bool use_fully_qualified_state)
 
std::string GetStatus () const
 
std::set< scxml4cpp::State * > GetActiveStates ()
 
void AddStatusListener (scxml4cpp::StatusListener *listener)
 
void RemoveStatusListener (scxml4cpp::StatusListener *listener)
 
void AddEventListener (scxml4cpp::EventListener *listener)
 
void RemoveEventListener (scxml4cpp::EventListener *listener)
 
void SetStatusPublisher (std::function< void(const std::string &)> publisher)
 
void PublishStatus ()
 
void RegisterRejectHandler (const std::string &id, std::function< void(const rad::AnyEvent &, const std::string &state)> handler)
 
template<typename T >
void RegisterDefaultRequestRejectHandler ()
 
void SetLogLevel (const std::string &level)
 
 SMAdapter (const SMAdapter &e)=delete
 
SMAdapteroperator= (SMAdapter &e)=delete
 
 SMAdapter (boost::asio::io_service &ios, scxml4cpp::Context *context, scxml4cpp::EventQueue &external_events)
 
virtual ~SMAdapter ()
 
void Load (const std::string &filename, std::list< scxml4cpp::Action * > *action_list, std::list< scxml4cpp::Activity * > *activity_list)
 
void Append (const std::string &filename, std::list< scxml4cpp::Action * > *action_list, std::list< scxml4cpp::Activity * > *activity_list)
 
void Start ()
 
void Stop ()
 
void PostEvent (SharedEvent e)
 
void ProcessEvent ()
 
void ProcessEvent (scxml4cpp::Event *e)
 
void ProcessEvent (const AnyEvent &e)
 
void SetStatusRepresentation (const bool use_fully_qualified_state)
 
std::string GetStatus () const
 
std::set< scxml4cpp::State * > GetActiveStates ()
 
void AddStatusListener (scxml4cpp::StatusListener *listener)
 
void RemoveStatusListener (scxml4cpp::StatusListener *listener)
 
void AddEventListener (scxml4cpp::EventListener *listener)
 
void RemoveEventListener (scxml4cpp::EventListener *listener)
 
void SetStatusPublisher (std::function< void(const std::string &)> publisher)
 
void PublishStatus ()
 
void RegisterRejectHandler (const std::string &id, std::function< void(const rad::AnyEvent &, const std::string &state)> handler)
 
template<typename T >
void RegisterDefaultRequestRejectHandler ()
 
void SetLogLevel (const std::string &level)
 
 SMAdapter (const SMAdapter &e)=delete
 
SMAdapteroperator= (SMAdapter &e)=delete
 

Detailed Description

This is the adapter to the SCXML engine.

Todo:
replace raw pointers with smart pointers.

This is the adapter to the SCXML engine.

Todo:
replace raw pointers with smart pointers.

Constructor & Destructor Documentation

◆ SMAdapter() [1/4]

rad::SMAdapter::SMAdapter ( boost::asio::io_service &  ios,
scxml4cpp::Context context,
scxml4cpp::EventQueue external_events 
)
Parameters
[in]iosEvent loop.
[in]contextSCXML context.
[in]external_eventsSCXML external event queue.

◆ ~SMAdapter() [1/2]

rad::SMAdapter::~SMAdapter ( )
virtual

Cleanup before quitting.

◆ SMAdapter() [2/4]

rad::SMAdapter::SMAdapter ( const SMAdapter e)
delete

◆ SMAdapter() [3/4]

rad::SMAdapter::SMAdapter ( boost::asio::io_service &  ios,
scxml4cpp::Context context,
scxml4cpp::EventQueue external_events 
)

◆ ~SMAdapter() [2/2]

virtual rad::SMAdapter::~SMAdapter ( )
virtual

◆ SMAdapter() [4/4]

rad::SMAdapter::SMAdapter ( const SMAdapter e)
delete

Member Function Documentation

◆ AddEventListener() [1/2]

void rad::SMAdapter::AddEventListener ( scxml4cpp::EventListener listener)

Register a listener for the event processed notification.

Parameters
[in]listenerListener to be registered.

◆ AddEventListener() [2/2]

void rad::SMAdapter::AddEventListener ( scxml4cpp::EventListener listener)

◆ AddStatusListener() [1/2]

void rad::SMAdapter::AddStatusListener ( scxml4cpp::StatusListener listener)

Register a listener for a change of SM state notification.

Parameters
[in]listenerListener to be registered.

◆ AddStatusListener() [2/2]

void rad::SMAdapter::AddStatusListener ( scxml4cpp::StatusListener listener)

◆ Append() [1/2]

void rad::SMAdapter::Append ( const std::string &  filename,
std::list< scxml4cpp::Action * > *  action_list,
std::list< scxml4cpp::Activity * > *  activity_list 
)

◆ Append() [2/2]

void rad::SMAdapter::Append ( const std::string &  filename,
std::list< scxml4cpp::Action * > *  action_list,
std::list< scxml4cpp::Activity * > *  activity_list 
)

◆ GetActiveStates() [1/2]

std::set< scxml4cpp::State * > rad::SMAdapter::GetActiveStates ( )
Returns
the current active SM state configuration returned by the SCXML engine.

◆ GetActiveStates() [2/2]

std::set<scxml4cpp::State*> rad::SMAdapter::GetActiveStates ( )

◆ GetStatus() [1/2]

std::string rad::SMAdapter::GetStatus ( ) const
Returns
the current SM state configuration as string formatted from the information provided by the status notification.

◆ GetStatus() [2/2]

std::string rad::SMAdapter::GetStatus ( ) const

◆ Load() [1/2]

void rad::SMAdapter::Load ( const std::string &  filename,
std::list< scxml4cpp::Action * > *  action_list,
std::list< scxml4cpp::Activity * > *  activity_list 
)

Load an SCXML model from file.

Parameters
[in]filenameSCXML model to load.
[in]action_listList of actions mapped to SCXML model.
[in]activity_listList of activities mapped to SCXML model.
Returns
0 if the model can be loaded, -1 otherwise.
Todo:
throw exception for ill-formed models?

◆ Load() [2/2]

void rad::SMAdapter::Load ( const std::string &  filename,
std::list< scxml4cpp::Action * > *  action_list,
std::list< scxml4cpp::Activity * > *  activity_list 
)

◆ operator=() [1/2]

SMAdapter& rad::SMAdapter::operator= ( SMAdapter e)
delete

◆ operator=() [2/2]

SMAdapter& rad::SMAdapter::operator= ( SMAdapter e)
delete

◆ PostEvent() [1/2]

void rad::SMAdapter::PostEvent ( SharedEvent  e)

Post asynchronously an event, to be processed by the SM, in the Event Loop. Note: this method can be invoked also by passing UniqueEvent as argument since C++ will upgrade it SharedEvent automatically.

Parameters
[in]eShared RAD event to post.

◆ PostEvent() [2/2]

void rad::SMAdapter::PostEvent ( SharedEvent  e)

◆ ProcessEvent() [1/6]

void rad::SMAdapter::ProcessEvent ( )

Trigger the processing of the events in the SM external event queue.

◆ ProcessEvent() [2/6]

void rad::SMAdapter::ProcessEvent ( )

◆ ProcessEvent() [3/6]

void rad::SMAdapter::ProcessEvent ( const AnyEvent e)

Method invoked to trigger the processing of an event by the SM.

Parameters
[in]eRAD event to be processed by the SM

◆ ProcessEvent() [4/6]

void rad::SMAdapter::ProcessEvent ( const AnyEvent e)

◆ ProcessEvent() [5/6]

void rad::SMAdapter::ProcessEvent ( scxml4cpp::Event e)

Trigger the processing of the given event. (the processing terminates when the SM external event queue is empty)

Parameters
[in]eSCXML event to be processed.

◆ ProcessEvent() [6/6]

void rad::SMAdapter::ProcessEvent ( scxml4cpp::Event e)

◆ PublishStatus() [1/2]

void rad::SMAdapter::PublishStatus ( )

Publishes the SM information.

◆ PublishStatus() [2/2]

void rad::SMAdapter::PublishStatus ( )

◆ RegisterDefaultRequestRejectHandler() [1/2]

template<typename T >
void rad::SMAdapter::RegisterDefaultRequestRejectHandler ( )
inline

Method to register the reject handler implemented via the free function rad::DefaultRequestRejectHandler() (see above) to be used to reject event associated to requests.

TODO find out why the logging doesn't work in templated inline methods!

◆ RegisterDefaultRequestRejectHandler() [2/2]

template<typename T >
void rad::SMAdapter::RegisterDefaultRequestRejectHandler ( )
inline

Method to register the reject handler implemented via the free function rad::DefaultRequestRejectHandler() (see above) to be used to reject event associated to requests.

TODO find out why the logging doesn't work in templated inline methods!

◆ RegisterRejectHandler() [1/2]

void rad::SMAdapter::RegisterRejectHandler ( const std::string &  id,
std::function< void(const rad::AnyEvent &, const std::string &state)>  handler 
)

Method to register a handler that can be used to reject an event.

Parameters
idEvent identifier to be rejected.
handlerFunction implementing the rejection handler.

Register a function to be invoked when an event is ingored/rejected by the SM engine.

Parameters
[in]idEvent identifier.
[in]handlerFunction to be invoked.

◆ RegisterRejectHandler() [2/2]

void rad::SMAdapter::RegisterRejectHandler ( const std::string &  id,
std::function< void(const rad::AnyEvent &, const std::string &state)>  handler 
)

Method to register a handler that can be used to reject an event.

Parameters
idEvent identifier to be rejected.
handlerFunction implementing the rejection handler.

◆ RemoveEventListener() [1/2]

void rad::SMAdapter::RemoveEventListener ( scxml4cpp::EventListener listener)

Deregister a listener for the event processed notification.

Parameters
[in]listenerListener to be deregistered.

◆ RemoveEventListener() [2/2]

void rad::SMAdapter::RemoveEventListener ( scxml4cpp::EventListener listener)

◆ RemoveStatusListener() [1/2]

void rad::SMAdapter::RemoveStatusListener ( scxml4cpp::StatusListener listener)

Deregister a listener for a change of SM state notification.

Parameters
[in]listenerListener to be deregistered.

◆ RemoveStatusListener() [2/2]

void rad::SMAdapter::RemoveStatusListener ( scxml4cpp::StatusListener listener)

◆ SetLogLevel() [1/2]

void rad::SMAdapter::SetLogLevel ( const std::string &  level)

Sets the log level of the SM engine.

Parameters
[in]levelThe desired log level.

◆ SetLogLevel() [2/2]

void rad::SMAdapter::SetLogLevel ( const std::string &  level)

◆ SetStatusPublisher() [1/2]

void rad::SMAdapter::SetStatusPublisher ( std::function< void(const std::string &)>  publisher)

Configure a function to be used as publisher for the SM information.

◆ SetStatusPublisher() [2/2]

void rad::SMAdapter::SetStatusPublisher ( std::function< void(const std::string &)>  publisher)

◆ SetStatusRepresentation() [1/2]

void rad::SMAdapter::SetStatusRepresentation ( const bool  use_fully_qualified_state)

Set a flag indicating whether states ID are fully qualified (i.e. include parent states) or not.

◆ SetStatusRepresentation() [2/2]

void rad::SMAdapter::SetStatusRepresentation ( const bool  use_fully_qualified_state)

◆ Start() [1/2]

void rad::SMAdapter::Start ( )

Starts the SM model interpretation.

◆ Start() [2/2]

void rad::SMAdapter::Start ( )

◆ Stop() [1/2]

void rad::SMAdapter::Stop ( )

Stops the SM model interpretation.

◆ Stop() [2/2]

void rad::SMAdapter::Stop ( )

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