RTC Toolkit 6.0.0-pre2
Loading...
Searching...
No Matches
runtimeRepoAdapter.hpp
Go to the documentation of this file.
1
12
13#ifndef RTCTK_COMPONENTFRAMEWORK_RUNTIMEREPOADAPTER_HPP
14#define RTCTK_COMPONENTFRAMEWORK_RUNTIMEREPOADAPTER_HPP
15
20
22
23// forward declaration for internal usage
24class RtrClient;
25
32public:
33 inline static const std::string SUPPORTED_URI_SCHEME = "rtr";
34
37
40
43
47
54 explicit RuntimeRepoAdapter(const elt::mal::Uri& baseuri);
55
56 ~RuntimeRepoAdapter() override = default;
57
58 elt::mal::Uri GetUri() const override {
59 return m_baseuri;
60 }
61
62protected:
63 BatchResponse ProcessRequests(const RequestList& requests) override;
64
65 template <typename T>
67
68 template <typename T>
70
71 template <typename T>
73
74 template <typename T>
76
77 template <typename T>
79
82
88
92
93 virtual void InvokeRequestHandler(std::any&, RtrClient&);
95
96 elt::mal::Uri m_baseuri;
97 std::string m_ip;
98 uint16_t m_port;
99 std::string m_topic;
100
103
106
108 mutable std::mutex m_mutex;
109
122
133
134 std::list<ValueSubscription> m_value_subscriptions;
135 std::list<CreateDeleteSubscription> m_create_delete_subscriptions;
136
137 // TODO: ideally we would not instantiate a concrete EventService here,
138 // but currently we cant get the abstract service interface from the service container,
139 // so how to solve this?
142 std::unique_ptr<EventSubscriberIf> m_event_subscriber;
143
144 using DispatchFunction = std::function<void(RuntimeRepoAdapter*, std::any&, RtrClient&)>;
145 using LookupTable = std::unordered_map<std::type_index, DispatchFunction>;
146 using TableEntry = typename LookupTable::value_type;
147
148 template <typename T>
149 static TableEntry Bind(void (RuntimeRepoAdapter::*method)(T&, RtrClient&));
150
152};
153
154} // namespace rtctk::componentFramework
155
156#endif // RTCTK_COMPONENTFRAMEWORK_RUNTIMEREPOADAPTER_HPP
This class provides a wrapper for a data point path.
Definition dataPointPath.hpp:77
The DynamicThreadPool allows creating multiple threads which are garbage collected.
Definition dynamicThreadPool.hpp:37
Interface class for providing pub/sub facilities for JSON events.
Definition eventServiceIf.hpp:29
Implementation of low-level event service using CII MAL DDS as middleware.
Definition malDdsEventService.hpp:36
std::vector< std::any > RequestList
Definition repositoryIf.hpp:53
std::function< void(const DataPointPath &)> CallbackType
Signature of the callback functions that can be registered with the repository requests.
Definition repositoryIf.hpp:61
std::function< void(std::exception_ptr)> ErrorCallbackType
Definition repositorySubscriberIf.hpp:49
std::function< void(const DataPointPath &, const MetaData &)> NotifyCallbackType
Definition repositorySubscriberIf.hpp:48
size_t SubscriptionId
Definition repositorySubscriberIf.hpp:51
This internal class implements the basic communication and commands toward the server.
Definition runtimeRepoAdapter.cpp:54
DynamicThreadPool m_thread_pool
Thread pool for worker threads.
Definition runtimeRepoAdapter.hpp:102
void WriteImpl(detail::WriteRequest< T > &, RtrClient &)
Definition runtimeRepoAdapter.cpp:733
void CreateImpl(detail::CreateRequest< T > &, RtrClient &)
Definition runtimeRepoAdapter.cpp:716
void DeleteImpl(detail::DeleteRequest &, RtrClient &)
Definition runtimeRepoAdapter.cpp:888
std::list< CreateDeleteSubscription > m_create_delete_subscriptions
Definition runtimeRepoAdapter.hpp:135
std::function< void(RuntimeRepoAdapter *, std::any &, RtrClient &)> DispatchFunction
Definition runtimeRepoAdapter.hpp:144
BatchResponse ProcessRequests(const RequestList &requests) override
Definition runtimeRepoAdapter.cpp:1107
RuntimeRepoAdapter(RuntimeRepoAdapter &&)=delete
Objects of this class can not be moved because we have a mutex.
RuntimeRepoAdapter()=delete
Do not allow construction with no arguments.
void GetChildrenImpl(detail::GetChildrenRequest &, RtrClient &)
Definition runtimeRepoAdapter.cpp:908
void ReadMetaDataImpl(detail::ReadMetaDataRequest &, RtrClient &)
Definition runtimeRepoAdapter.cpp:871
elt::mal::Uri m_baseuri
Definition runtimeRepoAdapter.hpp:96
RuntimeRepoAdapter & operator=(const RuntimeRepoAdapter &)=delete
This class cannot be copy assigned.
void UpdateLinkImpl(detail::UpdateSymlinkRequest &, RtrClient &)
Definition runtimeRepoAdapter.cpp:928
void ExistsImpl(detail::ExistsRequest &, RtrClient &)
Definition runtimeRepoAdapter.cpp:898
typename LookupTable::value_type TableEntry
Definition runtimeRepoAdapter.hpp:146
void CreateDeleteSubscribeImpl(detail::CreateDeleteSubscribeRequest &, RtrClient &)
Definition runtimeRepoAdapter.cpp:965
EventServiceIf & m_event_service
Definition runtimeRepoAdapter.hpp:141
virtual void InvokeRequestHandler(std::any &, RtrClient &)
Definition runtimeRepoAdapter.cpp:1149
MalDdsEventService m_mal_event_service
Definition runtimeRepoAdapter.hpp:140
elt::mal::Uri GetUri() const override
Get the URI used when creating this adapter object.
Definition runtimeRepoAdapter.hpp:58
RuntimeRepoAdapter(const RuntimeRepoAdapter &)=delete
This class cannot be copy constructed.
std::mutex m_mutex
Mutex for synchronising access to subscriptions.
Definition runtimeRepoAdapter.hpp:108
std::string m_ip
Definition runtimeRepoAdapter.hpp:97
static TableEntry Bind(void(RuntimeRepoAdapter::*method)(T &, RtrClient &))
Definition runtimeRepoAdapter.cpp:1160
std::unique_ptr< EventSubscriberIf > m_event_subscriber
Definition runtimeRepoAdapter.hpp:142
std::list< ValueSubscription > m_value_subscriptions
Definition runtimeRepoAdapter.hpp:134
void PartialReadImpl(detail::PartialReadRequest< T > &, RtrClient &)
Definition runtimeRepoAdapter.cpp:831
static const std::string SUPPORTED_URI_SCHEME
Definition runtimeRepoAdapter.hpp:33
void SubscriptionCallbackHandler(const JsonPayload &)
Definition runtimeRepoAdapter.cpp:1006
std::unordered_map< std::type_index, DispatchFunction > LookupTable
Definition runtimeRepoAdapter.hpp:145
std::string m_topic
Definition runtimeRepoAdapter.hpp:99
uint16_t m_port
Definition runtimeRepoAdapter.hpp:98
void PartialWriteImpl(detail::PartialWriteRequest< T > &, RtrClient &)
Definition runtimeRepoAdapter.cpp:755
void WriteMetaDataImpl(detail::WriteMetaDataRequest &, RtrClient &)
Definition runtimeRepoAdapter.cpp:783
DynamicThreadPool m_thread_pool_callback
Thread pool for callback threads.
Definition runtimeRepoAdapter.hpp:105
void ReadImpl(detail::ReadRequest< T > &, RtrClient &)
Definition runtimeRepoAdapter.cpp:798
void UnsubscribeImpl(detail::UnsubscribeRequest &, RtrClient &)
Definition runtimeRepoAdapter.cpp:972
RuntimeRepoAdapter & operator=(RuntimeRepoAdapter &&)=delete
void SubscribeImpl(detail::ValueSubscribeRequest &, RtrClient &)
Definition runtimeRepoAdapter.cpp:955
static const LookupTable S_REQUEST_DISPATCHER_TABLE
Definition runtimeRepoAdapter.hpp:151
void CreateLinkImpl(detail::CreateSymlinkRequest &, RtrClient &)
Definition runtimeRepoAdapter.cpp:918
Base interface for all Runtime Configuration Repository adapters.
Definition runtimeRepoIf.hpp:27
Header file for a dynamic resizing thread pool.
Low-level interface of the event service.
Implementation of the event service.
Definition commandReplier.cpp:22
nlohmann::json JsonPayload
Type requirements:
Definition jsonPayload.hpp:25
Header file for RuntimeRepoIf, which defines the API for RuntimeRepoAdapters.
CallbackType cb_deleted
Definition runtimeRepoAdapter.hpp:127
CallbackType cb_created
Definition runtimeRepoAdapter.hpp:126
ErrorCallbackType cb_error
Definition runtimeRepoAdapter.hpp:128
CreateDeleteSubscription(SubscriptionId, CallbackType, CallbackType, ErrorCallbackType)
Definition runtimeRepoAdapter.cpp:945
std::atomic< size_t > cb_created_busy
Definition runtimeRepoAdapter.hpp:129
std::atomic< size_t > cb_deleted_busy
Definition runtimeRepoAdapter.hpp:130
std::atomic< size_t > cb_error_busy
Definition runtimeRepoAdapter.hpp:131
SubscriptionId id
Definition runtimeRepoAdapter.hpp:125
ValueSubscription(SubscriptionId, const DataPointPath &, NotifyCallbackType, ErrorCallbackType)
Definition runtimeRepoAdapter.cpp:938
std::atomic< size_t > cb_value_busy
Definition runtimeRepoAdapter.hpp:119
ErrorCallbackType cb_error
Definition runtimeRepoAdapter.hpp:118
NotifyCallbackType cb_value
Definition runtimeRepoAdapter.hpp:117
SubscriptionId id
Definition runtimeRepoAdapter.hpp:115
std::atomic< size_t > cb_error_busy
Definition runtimeRepoAdapter.hpp:120
DataPointPath path
Definition runtimeRepoAdapter.hpp:116
Definition repositorySubscriberIf.ipp:41
Definition repositorySubscriberIf.ipp:27