Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@

namespace cl_keyboard
{
//------------------ KEYBOARD CLIENT ---------------------------------------------

class ClKeyboard : public smacc2::ISmaccClient
{
public:
Expand All @@ -40,19 +38,20 @@ class ClKeyboard : public smacc2::ISmaccClient
// Override the base class methods to call our setup
template <typename TOrthogonal, typename TClient>
void onComponentInitialization()
// clients utilizes a composition based architecture for their components
// here we define the list of components that this client will have in a component based architecture

// Clients utilize a composition based architecture for their components.
// In the function body below we create the components that will be used in this client.

{
// for listener we use dependency injection pattern where we reference the CpTopicSubscriber inside the smacc core
// this would be the basic subscription component to the topic
// we use this to gain the topic funcionality interated with SMACC and that post smacc events for transitions
// we are using it to handle ros topic messages reception and notifying other components in the client
// We start by creating a topic subscriber component from SMACC2s client core components.
// We use this to gain the topic funcionality interated with SMACC and the ability to post smacc events for transitions.
// We are using it to handle the reception of ros topic messages and to notify the other components in the client.
this->createComponent<
smacc2::client_core_components::CpTopicSubscriber<std_msgs::msg::UInt16>, TOrthogonal,
ClKeyboard>("/keyboard_unicode");

// this keyboard subscriber component requires the first subscriber component
// it is notified by the CpTopicSubscriber and processes the messages to decide with keyboard event must be posted and then post it
// This keyboard listener component requires the first subscriber component.
// It is notified by the CpTopicSubscriber and processes the messages to decide which keyboard event must be posted and then posts it.
this->createComponent<cl_keyboard::components::CpKeyboardListener1, TOrthogonal, ClKeyboard>();
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ class CbDefaultKeyboardBehavior : public smacc2::SmaccClientBehavior
components::CpKeyboardListener1 * cpSubscriber1;
std::function<void(char)> postEventKeyPress;

void onEntry();
void onEntry()
{
this->requiresComponent(this->cpSubscriber1);
this->cpSubscriber1->OnKeyPress(&CbDefaultKeyboardBehavior::OnKeyPress, this);
}

template <typename TOrthogonal, typename TSourceObject>
void onStateOrthogonalAllocation()
Expand Down Expand Up @@ -91,7 +95,7 @@ class CbDefaultKeyboardBehavior : public smacc2::SmaccClientBehavior
};
}

void OnKeyPress(char character);
void OnKeyPress(char character) { postEventKeyPress(character); }

template <typename TEv>
void postKeyEvent()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ struct EvKeyPressZ : sc::event<EvKeyPressZ<TSource, TOrthogonal>>
{
};

//------------------ KEYBOARD CLIENT ---------------------------------------------
//------------------ KEYBOARD LISTENER COMPONENT ---------------------------------------------

class CpKeyboardListener1 : public smacc2::ISmaccComponent
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@

namespace cl_keyboard
{
// Declare the Client's default constructor.
ClKeyboard::ClKeyboard() {}

// Declare the Client's default destructor.
ClKeyboard::~ClKeyboard() {}

} // namespace cl_keyboard

This file was deleted.

3 changes: 3 additions & 0 deletions smacc2_dev_tools/claude/Prompts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
> think hard and make a plan to refactor the smacc2 keyboard client package so
that the cb_default_keyboard_behavior.cpp file is removed and any necessary
code is moved to the cb_default_keyboard_behavior.hpp.