SMACC2
Loading...
Searching...
No Matches
cb_http_request.hpp
Go to the documentation of this file.
1// Copyright 2023 RobosoftAI Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15/*****************************************************************************************************************
16 *
17 * Authors: Jaycee Lock & Brett Aldrich
18 *
19 ******************************************************************************************************************/
20
21#pragma once
22
23#include <cl_http/cl_http.hpp>
25#include <cstring>
26#include <smacc2/smacc.hpp>
27
28namespace cl_http
29{
30
32{
33public:
35 : kRequestType(http_request_type)
36 {
37 }
38
39 template <typename TOrthogonal, typename TSourceObject>
41 {
42 // Base implementation - can be overridden by derived classes
43 }
44
45 virtual void runtimeConfigure() override
46 {
47 // Access executor component and connect to response signal
51 }
52
53 virtual void onResponseReceived(const CpHttpRequestExecutor::TResponse & /*response*/) {}
54
55 virtual void onEntry() override { requestExecutor_->executeRequest(kRequestType); }
56
57 virtual void onExit() override {}
58
59private:
61
63};
64} // namespace cl_http
CbHttpRequestBase(const CpHttpRequestExecutor::HttpMethod http_request_type)
virtual void onEntry() override
virtual void onExit() override
CpHttpRequestExecutor * requestExecutor_
const CpHttpRequestExecutor::HttpMethod kRequestType
virtual void runtimeConfigure() override
virtual void onResponseReceived(const CpHttpRequestExecutor::TResponse &)
http_session_base::TResponse TResponse
smacc2::SmaccSignal< void(const TResponse &)> onResponseReceived_
void executeRequest(const HttpMethod method, const std::string &path="/", const std::string &body="", const std::unordered_map< std::string, std::string > &headers={})
void requiresComponent(SmaccComponentType *&storage, ComponentRequirement requirementType=ComponentRequirement::SOFT)
boost::signals2::connection createSignalConnection(TSmaccSignal &signal, TMemberFunctionPrototype callback, TSmaccObjectType *object)