SMACC
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | Friends | List of all members
smacc::ISmaccClient Class Reference

#include <smacc_client.h>

Inheritance diagram for smacc::ISmaccClient:
Inheritance graph
Collaboration diagram for smacc::ISmaccClient:
Collaboration graph

Public Member Functions

 ISmaccClient ()
 
virtual ~ISmaccClient ()
 
virtual void initialize ()
 
virtual std::string getName () const
 
template<typename EventType >
void postEvent (const EventType &ev)
 
template<typename EventType >
void postEvent ()
 
template<typename TComponent >
TComponent * getComponent ()
 
template<typename TComponent >
TComponent * getComponent (std::string name)
 
virtual smacc::introspection::TypeInfo::Ptr getType ()
 
ISmaccStateMachinegetStateMachine ()
 
template<typename TSmaccSignal , typename T >
void connectSignal (TSmaccSignal &signal, void(T::*callback)(), T *object)
 
template<typename SmaccClientType >
void requiresClient (SmaccClientType *&storage)
 
void getComponents (std::vector< std::shared_ptr< ISmaccComponent > > &components)
 

Protected Member Functions

template<typename TOrthogonal , typename TSourceObject >
void onOrthogonalAllocation ()
 
template<typename SmaccComponentType , typename TOrthogonal , typename TClient , typename... TArgs>
SmaccComponentType * createComponent (TArgs... targs)
 
template<typename SmaccComponentType , typename TOrthogonal , typename TClient , typename... TArgs>
SmaccComponentType * createNamedComponent (std::string name, TArgs... targs)
 
void setStateMachine (ISmaccStateMachine *stateMachine)
 
void setOrthogonal (ISmaccOrthogonal *orthogonal)
 

Protected Attributes

std::map< ComponentKey, std::shared_ptr< smacc::ISmaccComponent > > components_
 

Private Attributes

ISmaccStateMachinestateMachine_
 
ISmaccOrthogonalorthogonal_
 

Friends

class ISmaccOrthogonal
 
class ISmaccComponent
 

Detailed Description

Definition at line 36 of file smacc_client.h.

Constructor & Destructor Documentation

◆ ISmaccClient()

smacc::ISmaccClient::ISmaccClient ( )

Definition at line 13 of file client.cpp.

14{
15}

◆ ~ISmaccClient()

smacc::ISmaccClient::~ISmaccClient ( )
virtual

Definition at line 17 of file client.cpp.

18{
19}

Member Function Documentation

◆ connectSignal()

template<typename TSmaccSignal , typename T >
void smacc::ISmaccClient::connectSignal ( TSmaccSignal &  signal,
void(T::*)()  callback,
T *  object 
)

Definition at line 96 of file smacc_client_impl.h.

97 {
98 return this->getStateMachine()->createSignalConnection(signal, callback, object);
99 }
ISmaccStateMachine * getStateMachine()
boost::signals2::connection createSignalConnection(TSmaccSignal &signal, TMemberFunctionPrototype callback, TSmaccObjectType *object)

References smacc::ISmaccStateMachine::createSignalConnection(), and getStateMachine().

Here is the call graph for this function:

◆ createComponent()

template<typename SmaccComponentType , typename TOrthogonal , typename TClient , typename... TArgs>
SmaccComponentType * smacc::ISmaccClient::createComponent ( TArgs...  targs)
protected

Definition at line 90 of file smacc_client_impl.h.

91 {
92 return this->createNamedComponent<SmaccComponentType, TOrthogonal, TClient>(std::string(), targs...);
93 }

Referenced by smacc::ClientHandler< TOrthogonal, TClient >::createComponent(), and smacc::ISmaccComponent::createSiblingComponent().

Here is the caller graph for this function:

◆ createNamedComponent()

template<typename SmaccComponentType , typename TOrthogonal , typename TClient , typename... TArgs>
SmaccComponentType * smacc::ISmaccClient::createNamedComponent ( std::string  name,
TArgs...  targs 
)
protected

Definition at line 57 of file smacc_client_impl.h.

58 {
59 ComponentKey componentkey(&typeid(SmaccComponentType), name);
60
61 std::shared_ptr<SmaccComponentType> ret;
62
63 auto it = this->components_.find(componentkey);
64
65 if (it == this->components_.end())
66 {
67 auto tname = demangledTypeName<SmaccComponentType>();
68 ROS_DEBUG("%s smacc component is required. Creating a new instance.", tname.c_str());
69
70 ret = std::shared_ptr<SmaccComponentType>(new SmaccComponentType(targs...));
71 ret->setStateMachine(this->getStateMachine());
72 ret->owner_ = this;
73 ret->initialize(this);
74
75 this->components_[componentkey] = ret; //std::dynamic_pointer_cast<smacc::ISmaccComponent>(ret);
76 ROS_DEBUG("%s resource is required. Done.", tname.c_str());
77 }
78 else
79 {
80 ROS_DEBUG("%s resource is required. Found resource in cache.", demangledTypeName<SmaccComponentType>().c_str());
81 ret = dynamic_pointer_cast<SmaccComponentType>(it->second);
82 }
83
84 ret->template onOrthogonalAllocation<TOrthogonal, TClient>();
85
86 return ret.get();
87 }
std::map< ComponentKey, std::shared_ptr< smacc::ISmaccComponent > > components_
Definition: smacc_client.h:78

References components_, and getStateMachine().

Referenced by smacc::ClientHandler< TOrthogonal, TClient >::createNamedComponent(), and smacc::ISmaccComponent::createSiblingNamedComponent().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getComponent() [1/2]

template<typename TComponent >
TComponent * smacc::ISmaccClient::getComponent

◆ getComponent() [2/2]

template<typename TComponent >
TComponent * smacc::ISmaccClient::getComponent ( std::string  name)

Definition at line 33 of file smacc_client_impl.h.

34 {
35 for (auto &component : components_)
36 {
37 if (component.first.name != name)
38 continue;
39
40 auto *tcomponent = dynamic_cast<TComponent *>(component.second.get());
41 if (tcomponent != nullptr)
42 {
43 return tcomponent;
44 }
45 }
46
47 return nullptr;
48 }

References components_.

◆ getComponents()

void smacc::ISmaccClient::getComponents ( std::vector< std::shared_ptr< ISmaccComponent > > &  components)

Definition at line 26 of file client.cpp.

27{
28 for (auto &ce : components_)
29 {
30 components.push_back(ce.second);
31 }
32}

References components_.

◆ getName()

std::string smacc::ISmaccClient::getName ( ) const
virtual

◆ getStateMachine()

ISmaccStateMachine * smacc::ISmaccClient::getStateMachine ( )
inline

◆ getType()

smacc::introspection::TypeInfo::Ptr smacc::ISmaccClient::getType ( )
virtual

Definition at line 50 of file client.cpp.

51{
53}
static TypeInfo::Ptr getFromStdTypeInfo(const std::type_info &tid)

References smacc::introspection::TypeInfo::getFromStdTypeInfo().

Here is the call graph for this function:

◆ initialize()

void smacc::ISmaccClient::initialize ( )
virtual

◆ onOrthogonalAllocation()

template<typename TOrthogonal , typename TSourceObject >
void smacc::ISmaccClient::onOrthogonalAllocation ( )
inlineprotected

Definition at line 75 of file smacc_client.h.

75{}

◆ postEvent() [1/2]

template<typename EventType >
void smacc::ISmaccClient::postEvent

◆ postEvent() [2/2]

template<typename EventType >
void smacc::ISmaccClient::postEvent ( const EventType &  ev)

Definition at line 15 of file smacc_client_impl.h.

16 {
18 }

References smacc::ISmaccStateMachine::postEvent(), and stateMachine_.

Here is the call graph for this function:

◆ requiresClient()

template<typename SmaccClientType >
void smacc::ISmaccClient::requiresClient ( SmaccClientType *&  storage)

Definition at line 102 of file smacc_client_impl.h.

103 {
104 this->orthogonal_->requiresClient(storage);
105 }
ISmaccOrthogonal * orthogonal_
Definition: smacc_client.h:94
bool requiresClient(SmaccClientType *&storage)

References orthogonal_, and smacc::ISmaccOrthogonal::requiresClient().

Referenced by smacc::ISmaccComponent::requiresClient().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setOrthogonal()

void smacc::ISmaccClient::setOrthogonal ( ISmaccOrthogonal orthogonal)
protected

Definition at line 45 of file client.cpp.

46{
47 orthogonal_ = orthogonal;
48}

References orthogonal_.

◆ setStateMachine()

void smacc::ISmaccClient::setStateMachine ( ISmaccStateMachine stateMachine)
protected

Definition at line 40 of file client.cpp.

41{
42 stateMachine_ = stateMachine;
43}

References stateMachine_.

Friends And Related Function Documentation

◆ ISmaccComponent

friend class ISmaccComponent
friend

Definition at line 97 of file smacc_client.h.

◆ ISmaccOrthogonal

friend class ISmaccOrthogonal
friend

Definition at line 96 of file smacc_client.h.

Member Data Documentation

◆ components_

std::map<ComponentKey, std::shared_ptr<smacc::ISmaccComponent> > smacc::ISmaccClient::components_
protected

Definition at line 78 of file smacc_client.h.

Referenced by createNamedComponent(), getComponent(), and getComponents().

◆ orthogonal_

ISmaccOrthogonal* smacc::ISmaccClient::orthogonal_
private

Definition at line 94 of file smacc_client.h.

Referenced by requiresClient(), and setOrthogonal().

◆ stateMachine_

ISmaccStateMachine* smacc::ISmaccClient::stateMachine_
private

Definition at line 93 of file smacc_client.h.

Referenced by getStateMachine(), postEvent(), and setStateMachine().


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