SMACC2
Loading...
Searching...
No Matches
cl_http::ClHttp Class Reference

HTTP/HTTPS client with pure component-based architecture. More...

#include <cl_http.hpp>

Inheritance diagram for cl_http::ClHttp:
Inheritance graph
Collaboration diagram for cl_http::ClHttp:
Collaboration graph

Public Types

enum class  kHttpRequestMethod { GET = static_cast<int>(boost::beast::http::verb::get) , POST = static_cast<int>(boost::beast::http::verb::post) , PUT = static_cast<int>(boost::beast::http::verb::put) }
 
using TResponse = http_session_base::TResponse
 

Public Member Functions

 ClHttp (const std::string &server, const int &timeout=1500)
 
virtual ~ClHttp ()
 
void onInitialize () override
 
template<typename TOrthogonal , typename TClient >
void onComponentInitialization ()
 
- Public Member Functions inherited from smacc2::ISmaccClient
 ISmaccClient ()
 
virtual ~ISmaccClient ()
 
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 ()
 

Private Attributes

const int HTTP_VERSION = 11
 
bool initialized_
 
std::string server_url_
 
CpHttpConnectionManagerconnectionManager_
 
CpHttpSessionManagersessionManager_
 
CpHttpRequestExecutorrequestExecutor_
 

Additional Inherited Members

- Protected Member Functions inherited from smacc2::ISmaccClient
template<typename TOrthogonal , typename TClient >
void onComponentInitialization ()
 
template<typename TOrthogonal , typename TSourceObject >
void onStateOrthogonalAllocation ()
 
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 inherited from smacc2::ISmaccClient
std::map< ComponentKey, std::shared_ptr< smacc2::ISmaccComponent > > components_
 

Detailed Description

HTTP/HTTPS client with pure component-based architecture.

This client acts as a minimal orchestrator that creates and configures three specialized components during initialization. All HTTP functionality is delegated to components.

Components created:

Behaviors should access CpHttpRequestExecutor directly via requiresComponent() rather than using the client interface.

Definition at line 61 of file cl_http.hpp.

Member Typedef Documentation

◆ TResponse

Member Enumeration Documentation

◆ kHttpRequestMethod

Enumerator
GET 
POST 
PUT 

Definition at line 64 of file cl_http.hpp.

65 {
66 GET = static_cast<int>(boost::beast::http::verb::get),
67 POST = static_cast<int>(boost::beast::http::verb::post),
68 PUT = static_cast<int>(boost::beast::http::verb::put),
69 };

Constructor & Destructor Documentation

◆ ClHttp()

cl_http::ClHttp::ClHttp ( const std::string & server,
const int & timeout = 1500 )
explicit

Definition at line 25 of file cl_http.cpp.

26: initialized_{false},
27 server_url_{server_name},
28 connectionManager_{nullptr},
29 sessionManager_{nullptr},
30 requestExecutor_{nullptr}
31{
32 // Timeout parameter kept for API compatibility but unused (managed by components)
33}
CpHttpRequestExecutor * requestExecutor_
Definition cl_http.hpp:105
std::string server_url_
Definition cl_http.hpp:100
CpHttpConnectionManager * connectionManager_
Definition cl_http.hpp:103
CpHttpSessionManager * sessionManager_
Definition cl_http.hpp:104

◆ ~ClHttp()

cl_http::ClHttp::~ClHttp ( )
virtual

Definition at line 35 of file cl_http.cpp.

36{
37 // Thread cleanup handled by CpHttpConnectionManager destructor
38}

Member Function Documentation

◆ onComponentInitialization()

template<typename TOrthogonal , typename TClient >
void cl_http::ClHttp::onComponentInitialization ( )
inline

Definition at line 81 of file cl_http.hpp.

82 {
83 // Create components
87
88 // Set component dependencies
90
91 // Configure session manager with server URL
93 }
void setDependencies(CpHttpConnectionManager *connMgr, CpHttpSessionManager *sessMgr)
void setServerUrl(const std::string &server_url)
SmaccComponentType * createComponent(TArgs... targs)

References connectionManager_, smacc2::ISmaccClient::createComponent(), requestExecutor_, server_url_, sessionManager_, cl_http::CpHttpRequestExecutor::setDependencies(), and cl_http::CpHttpSessionManager::setServerUrl().

Here is the call graph for this function:

◆ onInitialize()

void cl_http::ClHttp::onInitialize ( )
overridevirtual

Reimplemented from smacc2::ISmaccClient.

Definition at line 40 of file cl_http.cpp.

41{
42 // Components created in onComponentInitialization()
43 this->initialized_ = true;
44}

References initialized_.

Member Data Documentation

◆ connectionManager_

CpHttpConnectionManager* cl_http::ClHttp::connectionManager_
private

Definition at line 103 of file cl_http.hpp.

Referenced by onComponentInitialization().

◆ HTTP_VERSION

const int cl_http::ClHttp::HTTP_VERSION = 11
private

Definition at line 96 of file cl_http.hpp.

◆ initialized_

bool cl_http::ClHttp::initialized_
private

Definition at line 98 of file cl_http.hpp.

Referenced by onInitialize().

◆ requestExecutor_

CpHttpRequestExecutor* cl_http::ClHttp::requestExecutor_
private

Definition at line 105 of file cl_http.hpp.

Referenced by onComponentInitialization().

◆ server_url_

std::string cl_http::ClHttp::server_url_
private

Definition at line 100 of file cl_http.hpp.

Referenced by onComponentInitialization().

◆ sessionManager_

CpHttpSessionManager* cl_http::ClHttp::sessionManager_
private

Definition at line 104 of file cl_http.hpp.

Referenced by onComponentInitialization().


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