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

#include <smacc_client.hpp>

Inheritance diagram for smacc2::ISmaccClient:
Inheritance graph
Collaboration diagram for smacc2::ISmaccClient:
Collaboration graph

Public Member Functions

 ISmaccClient ()
 
virtual ~ISmaccClient ()
 
virtual void onInitialize ()
 
virtual std::string getName () const
 
template<typename TComponent >
TComponent * getComponent ()
 
template<typename TComponent >
TComponent * getComponent (std::string name)
 
template<typename TComponent >
TComponent * getComponent (int index)
 
virtual smacc2::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)
 
const std::vector< std::shared_ptr< ISmaccComponent > > & iterateComponents () const
 
template<typename EventType >
void postEvent (const EventType &ev)
 
template<typename EventType >
void postEvent ()
 

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)
 
rclcpp::Node::SharedPtr getNode ()
 
rclcpp::Logger getLogger ()
 

Protected Attributes

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

Private Member Functions

void initialize ()
 
void setStateMachine (ISmaccStateMachine *stateMachine)
 
void setOrthogonal (ISmaccOrthogonal *orthogonal)
 

Private Attributes

ISmaccStateMachinestateMachine_
 
ISmaccOrthogonalorthogonal_
 

Friends

class ISmaccOrthogonal
 
class ISmaccComponent
 

Detailed Description

Definition at line 44 of file smacc_client.hpp.

Constructor & Destructor Documentation

◆ ISmaccClient()

smacc2::ISmaccClient::ISmaccClient ( )

Definition at line 26 of file client.cpp.

26{}

◆ ~ISmaccClient()

smacc2::ISmaccClient::~ISmaccClient ( )
virtual

Definition at line 28 of file client.cpp.

28{}

Member Function Documentation

◆ connectSignal()

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

Definition at line 138 of file smacc_client_impl.hpp.

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

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

Here is the call graph for this function:

◆ createComponent()

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

Definition at line 131 of file smacc_client_impl.hpp.

132{
133 return this->createNamedComponent<SmaccComponentType, TOrthogonal, TClient>(
134 std::string(), targs...);
135}

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

Here is the caller graph for this function:

◆ createNamedComponent()

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

Definition at line 91 of file smacc_client_impl.hpp.

92{
93 ComponentKey componentkey(&typeid(SmaccComponentType), name);
94
95 std::shared_ptr<SmaccComponentType> ret;
96
97 auto it = this->components_.find(componentkey);
98
99 if (it == this->components_.end())
100 {
101 auto tname = demangledTypeName<SmaccComponentType>();
102 RCLCPP_INFO(
103 getLogger(),
104 "Creating a new component of type %s smacc component is required by client '%s'. Creating a "
105 "new instance %s",
106 this->getName().c_str(), demangledTypeName<SmaccComponentType>().c_str(), tname.c_str());
107
108 ret = std::shared_ptr<SmaccComponentType>(new SmaccComponentType(targs...));
109 ret->setStateMachine(this->getStateMachine());
110 ret->owner_ = this;
111 ret->initialize(this);
112
113 this->components_[componentkey] =
114 ret; //std::dynamic_pointer_cast<smacc2::ISmaccComponent>(ret);
115 RCLCPP_DEBUG(getLogger(), "%s resource is required. Done.", tname.c_str());
116 }
117 else
118 {
119 RCLCPP_INFO(
120 getLogger(), "%s resource is required. Found resource in cache.",
121 demangledTypeName<SmaccComponentType>().c_str());
122 ret = dynamic_pointer_cast<SmaccComponentType>(it->second);
123 }
124
125 ret->template onOrthogonalAllocation<TOrthogonal, TClient>();
126
127 return ret.get();
128}
std::map< ComponentKey, std::shared_ptr< smacc2::ISmaccComponent > > components_
virtual std::string getName() const
Definition: client.cpp:42
rclcpp::Logger getLogger()

References components_, getLogger(), getName(), and getStateMachine().

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

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

◆ getComponent() [1/3]

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

◆ getComponent() [2/3]

template<typename TComponent >
TComponent * smacc2::ISmaccClient::getComponent ( int  index)

Definition at line 47 of file smacc_client_impl.hpp.

48{
49 int count = 0;
50 for (auto & component : components_)
51 {
52 auto * tcomponent = dynamic_cast<TComponent *>(component.second.get());
53 if (tcomponent != nullptr)
54 {
55 if (count == index)
56 {
57 return tcomponent;
58 }
59 else
60 {
61 count++;
62 continue;
63 }
64 }
65 }
66
67 return nullptr;
68}

References components_.

◆ getComponent() [3/3]

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

Definition at line 71 of file smacc_client_impl.hpp.

72{
73 for (auto & component : components_)
74 {
75 if (!name.empty() && component.first.name != name) continue;
76
77 auto * tcomponent = dynamic_cast<TComponent *>(component.second.get());
78 if (tcomponent != nullptr)
79 {
80 return tcomponent;
81 }
82 }
83
84 return nullptr;
85}

References components_.

◆ getComponents()

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

Definition at line 34 of file client.cpp.

35{
36 for (auto & ce : components_)
37 {
38 components.push_back(ce.second);
39 }
40}

References components_.

Referenced by smacc2::ISmaccComponent::requiresComponent().

Here is the caller graph for this function:

◆ getLogger()

rclcpp::Logger smacc2::ISmaccClient::getLogger ( )
inlineprotected

◆ getName()

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

◆ getNode()

rclcpp::Node::SharedPtr smacc2::ISmaccClient::getNode ( )
protected

◆ getStateMachine()

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

◆ getType()

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

Definition at line 55 of file client.cpp.

56{
58}
static TypeInfo::Ptr getFromStdTypeInfo(const std::type_info &tid)

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

Here is the call graph for this function:

◆ initialize()

void smacc2::ISmaccClient::initialize ( )
private

Definition at line 30 of file client.cpp.

30{ this->onInitialize(); }
virtual void onInitialize()
Definition: client.cpp:32

References onInitialize().

Here is the call graph for this function:

◆ iterateComponents()

const std::vector< std::shared_ptr< ISmaccComponent > > & smacc2::ISmaccClient::iterateComponents ( ) const

◆ onInitialize()

void smacc2::ISmaccClient::onInitialize ( )
virtual

◆ onOrthogonalAllocation()

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

Definition at line 90 of file smacc_client.hpp.

91 {
92 }

◆ postEvent() [1/2]

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

◆ postEvent() [2/2]

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

Definition at line 29 of file smacc_client_impl.hpp.

30{
32}

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

Here is the call graph for this function:

◆ requiresClient()

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

Definition at line 144 of file smacc_client_impl.hpp.

145{
146 this->orthogonal_->requiresClient(storage);
147}
ISmaccOrthogonal * orthogonal_
bool requiresClient(SmaccClientType *&storage)

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

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

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

◆ setOrthogonal()

void smacc2::ISmaccClient::setOrthogonal ( ISmaccOrthogonal orthogonal)
private

Definition at line 53 of file client.cpp.

53{ orthogonal_ = orthogonal; }

References orthogonal_.

◆ setStateMachine()

void smacc2::ISmaccClient::setStateMachine ( ISmaccStateMachine stateMachine)
private

Definition at line 48 of file client.cpp.

49{
50 stateMachine_ = stateMachine;
51}

References stateMachine_.

Friends And Related Function Documentation

◆ ISmaccComponent

friend class ISmaccComponent
friend

Definition at line 123 of file smacc_client.hpp.

◆ ISmaccOrthogonal

friend class ISmaccOrthogonal
friend

Definition at line 122 of file smacc_client.hpp.

Member Data Documentation

◆ components_

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

Definition at line 95 of file smacc_client.hpp.

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

◆ orthogonal_

ISmaccOrthogonal* smacc2::ISmaccClient::orthogonal_
private

Definition at line 110 of file smacc_client.hpp.

Referenced by requiresClient(), and setOrthogonal().

◆ stateMachine_

ISmaccStateMachine* smacc2::ISmaccClient::stateMachine_
private

Definition at line 109 of file smacc_client.hpp.

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


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