SMACC2
Loading...
Searching...
No Matches
cl_keyboard::CbDefaultKeyboardBehavior Class Reference

#include <cb_default_keyboard_behavior.hpp>

Inheritance diagram for cl_keyboard::CbDefaultKeyboardBehavior:
Inheritance graph
Collaboration diagram for cl_keyboard::CbDefaultKeyboardBehavior:
Collaboration graph

Public Member Functions

void onEntry ()
 
template<typename TOrthogonal , typename TSourceObject >
void onStateOrthogonalAllocation ()
 
void OnKeyPress (char character)
 
void OnArrowPress (ArrowKey arrow)
 
template<typename TEv >
void postKeyEvent ()
 
- Public Member Functions inherited from smacc2::SmaccClientBehavior
virtual ~SmaccClientBehavior ()
 
void onEntry () override
 
void onExit () override
 
- Public Member Functions inherited from smacc2::ISmaccClientBehavior
 ISmaccClientBehavior ()
 
virtual ~ISmaccClientBehavior ()
 
ISmaccStateMachinegetStateMachine ()
 
std::string getName () const
 
template<typename SmaccClientType >
void requiresClient (SmaccClientType *&storage)
 
template<typename SmaccComponentType >
void requiresComponent (SmaccComponentType *&storage, ComponentRequirement requirementType=ComponentRequirement::SOFT)
 
template<typename SmaccComponentType >
void requiresComponent (std::string name, SmaccComponentType *&storage, ComponentRequirement requirementType=ComponentRequirement::SOFT)
 
virtual void executeOnEntry ()
 
virtual void executeOnExit ()
 

Public Attributes

components::CpKeyboardListener1cpSubscriber1
 
std::function< void(char)> postEventKeyPress
 
std::function< void(ArrowKey)> postEventArrowPress
 

Additional Inherited Members

- Protected Member Functions inherited from smacc2::ISmaccClientBehavior
virtual void runtimeConfigure ()
 
template<typename EventType >
void postEvent (const EventType &ev)
 
template<typename EventType >
void postEvent ()
 
ISmaccStategetCurrentState ()
 
virtual void dispose ()
 
virtual rclcpp::Node::SharedPtr getNode () const
 
virtual rclcpp::Logger getLogger () const
 

Detailed Description

Definition at line 24 of file cb_default_keyboard_behavior.hpp.

Member Function Documentation

◆ OnArrowPress()

void cl_keyboard::CbDefaultKeyboardBehavior::OnArrowPress ( ArrowKey arrow)
inline

Definition at line 119 of file cb_default_keyboard_behavior.hpp.

119{ postEventArrowPress(arrow); }

References postEventArrowPress.

Referenced by onEntry().

Here is the caller graph for this function:

◆ onEntry()

void cl_keyboard::CbDefaultKeyboardBehavior::onEntry ( )
inlinevirtual

Reimplemented from smacc2::ISmaccClientBehavior.

Definition at line 31 of file cb_default_keyboard_behavior.hpp.

32 {
36 }
void OnArrowPress(void(T::*callback)(ArrowKey arrow), T *object)
void OnKeyPress(void(T::*callback)(char keypress), T *object)
void requiresComponent(SmaccComponentType *&storage, ComponentRequirement requirementType=ComponentRequirement::SOFT)

References OnArrowPress(), cl_keyboard::components::CpKeyboardListener1::OnArrowPress(), OnKeyPress(), cl_keyboard::components::CpKeyboardListener1::OnKeyPress(), and smacc2::ISmaccClientBehavior::requiresComponent().

Here is the call graph for this function:

◆ OnKeyPress()

void cl_keyboard::CbDefaultKeyboardBehavior::OnKeyPress ( char character)
inline

Definition at line 117 of file cb_default_keyboard_behavior.hpp.

117{ postEventKeyPress(character); }

References postEventKeyPress.

Referenced by onEntry().

Here is the caller graph for this function:

◆ onStateOrthogonalAllocation()

template<typename TOrthogonal , typename TSourceObject >
void cl_keyboard::CbDefaultKeyboardBehavior::onStateOrthogonalAllocation ( )
inline

Definition at line 39 of file cb_default_keyboard_behavior.hpp.

40 {
41 postEventKeyPress = [=](char character)
42 {
43 if (character == 'a')
45 else if (character == 'b')
47 else if (character == 'c')
49 else if (character == 'd')
51 else if (character == 'e')
53 else if (character == 'f')
55 else if (character == 'g')
57 else if (character == 'h')
59 else if (character == 'i')
61 else if (character == 'j')
63 else if (character == 'k')
65 else if (character == 'l')
67 else if (character == 'm')
69 else if (character == 'n')
71 else if (character == 'o')
73 else if (character == 'p')
75 else if (character == 'q')
77 else if (character == 'r')
79 else if (character == 's')
81 else if (character == 't')
83 else if (character == 'u')
85 else if (character == 'v')
87 else if (character == 'w')
89 else if (character == 'x')
91 else if (character == 'y')
93 else if (character == 'z')
95 };
96
97 postEventArrowPress = [=](ArrowKey arrow)
98 {
99 switch (arrow)
100 {
101 case ArrowKey::Up:
103 break;
104 case ArrowKey::Down:
106 break;
107 case ArrowKey::Left:
109 break;
110 case ArrowKey::Right:
112 break;
113 }
114 };
115 }

References cl_keyboard::Down, cl_keyboard::Left, postEventArrowPress, postEventKeyPress, postKeyEvent(), cl_keyboard::Right, and cl_keyboard::Up.

Here is the call graph for this function:

◆ postKeyEvent()

template<typename TEv >
void cl_keyboard::CbDefaultKeyboardBehavior::postKeyEvent ( )
inline

Definition at line 122 of file cb_default_keyboard_behavior.hpp.

123 {
124 RCLCPP_WARN(
125 getLogger(), "CbDefaultKeyboardBehavior %ld ev: %s", (long)(void *)this,
126 smacc2::demangleSymbol(typeid(TEv).name()).c_str());
127 auto event = new TEv();
128 this->postEvent(event);
129 }
virtual rclcpp::Logger getLogger() const
std::string demangleSymbol()

References smacc2::introspection::demangleSymbol(), smacc2::ISmaccClientBehavior::getLogger(), and smacc2::ISmaccClientBehavior::postEvent().

Referenced by onStateOrthogonalAllocation().

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

Member Data Documentation

◆ cpSubscriber1

components::CpKeyboardListener1* cl_keyboard::CbDefaultKeyboardBehavior::cpSubscriber1

Definition at line 27 of file cb_default_keyboard_behavior.hpp.

◆ postEventArrowPress

std::function<void(ArrowKey)> cl_keyboard::CbDefaultKeyboardBehavior::postEventArrowPress

Definition at line 29 of file cb_default_keyboard_behavior.hpp.

Referenced by OnArrowPress(), and onStateOrthogonalAllocation().

◆ postEventKeyPress

std::function<void(char)> cl_keyboard::CbDefaultKeyboardBehavior::postEventKeyPress

Definition at line 28 of file cb_default_keyboard_behavior.hpp.

Referenced by OnKeyPress(), and onStateOrthogonalAllocation().


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