2121#include < optional>
2222
2323#include < ddspipe_core/types/dds/Endpoint.hpp>
24- #include < ddsenabler_participants/RpcUtils .hpp>
24+ #include < ddsenabler_participants/RpcTypes .hpp>
2525
2626namespace eprosima {
2727namespace ddsenabler {
@@ -34,13 +34,60 @@ enum class ActionEraseReason
3434 FORCED // Force erase regardless of status/result
3535};
3636
37+ struct RpcAction
38+ {
39+ RpcAction () = default ;
40+ RpcAction (
41+ const std::string& action_name,
42+ const ddspipe::core::types::RpcTopic& goal,
43+ const ddspipe::core::types::RpcTopic& result,
44+ const ddspipe::core::types::RpcTopic& cancel,
45+ const ddspipe::core::types::DdsTopic& feedback,
46+ const ddspipe::core::types::DdsTopic& status)
47+ : action_name(action_name)
48+ , goal(goal)
49+ , result(result)
50+ , cancel(cancel)
51+ , feedback(feedback)
52+ , status(status)
53+ {
54+ }
55+
56+ std::string action_name;
57+ ddspipe::core::types::RpcTopic goal;
58+ ddspipe::core::types::RpcTopic result;
59+ ddspipe::core::types::RpcTopic cancel;
60+ ddspipe::core::types::DdsTopic feedback;
61+ ddspipe::core::types::DdsTopic status;
62+ };
63+
64+ struct RpcInfo
65+ {
66+ RpcInfo (const std::string& dds_topic_name)
67+ : topic_name(dds_topic_name)
68+ , rpc_protocol(RPC_PROTOCOL ::PROTOCOL_UNKNOWN )
69+ , rpc_type(RPC_TYPE ::RPC_NONE )
70+ , service_type(SERVICE_TYPE ::SERVICE_NONE )
71+ , action_type(ACTION_TYPE ::ACTION_NONE )
72+ {
73+ }
74+
75+ std::string topic_name;
76+ std::string service_name;
77+ std::string action_name;
78+ RPC_PROTOCOL rpc_protocol;
79+ RPC_TYPE rpc_type;
80+ SERVICE_TYPE service_type;
81+ ACTION_TYPE action_type;
82+ };
83+
3784struct ActionRequestInfo
3885{
3986 ActionRequestInfo () = default ;
4087
4188 ActionRequestInfo (
4289 const std::string& _action_name,
43- RpcUtils::ActionType action_type,
90+ ACTION_TYPE action_type,
4491 uint64_t request_id,
4592 RPC_PROTOCOL rpc_protocol)
4693 : action_name(_action_name)
@@ -52,14 +99,14 @@ struct ActionRequestInfo
5299
53100 void set_request (
54101 uint64_t request_id,
55- RpcUtils::ActionType action_type)
102+ ACTION_TYPE action_type)
56103 {
57104 switch (action_type)
58105 {
59- case RpcUtils::ActionType:: GOAL :
106+ case ACTION_TYPE :: ACTION_GOAL :
60107 goal_request_id = request_id;
61108 break ;
62- case RpcUtils::ActionType:: RESULT :
109+ case ACTION_TYPE :: ACTION_RESULT :
63110 result_request_id = request_id;
64111 break ;
65112 default :
@@ -69,13 +116,13 @@ struct ActionRequestInfo
69116 }
70117
71118 uint64_t get_request (
72- RpcUtils::ActionType action_type) const
119+ ACTION_TYPE action_type) const
73120 {
74121 switch (action_type)
75122 {
76- case RpcUtils::ActionType:: GOAL :
123+ case ACTION_TYPE :: ACTION_GOAL :
77124 return goal_request_id;
78- case RpcUtils::ActionType:: RESULT :
125+ case ACTION_TYPE :: ACTION_RESULT :
79126 return result_request_id;
80127 default :
81128 return 0 ;
@@ -137,7 +184,7 @@ struct ServiceDiscovered
137184 }
138185
139186 std::string service_name;
140- RPC_PROTOCOL rpc_protocol{RPC_PROTOCOL ::UNKNOWN };
187+ RPC_PROTOCOL rpc_protocol{RPC_PROTOCOL ::PROTOCOL_UNKNOWN };
141188
142189 ddspipe::core::types::DdsTopic topic_request;
143190 bool request_discovered{false };
@@ -153,9 +200,9 @@ struct ServiceDiscovered
153200
154201 bool add_topic (
155202 const ddspipe::core::types::DdsTopic& topic,
156- RpcUtils::RpcType rpc_type )
203+ SERVICE_TYPE service_type )
157204 {
158- if (rpc_type == RpcUtils::RpcType:: RPC_REQUEST )
205+ if (service_type == SERVICE_TYPE :: SERVICE_REQUEST )
159206 {
160207 if (request_discovered)
161208 return false ;
@@ -187,9 +234,9 @@ struct ServiceDiscovered
187234 return false ;
188235 }
189236
190- bool remove_topic (RpcUtils::RpcType rpc_type )
237+ bool remove_topic (SERVICE_TYPE service_type )
191238 {
192- if (rpc_type == RpcUtils::RpcType:: RPC_REQUEST )
239+ if (service_type == SERVICE_TYPE :: SERVICE_REQUEST )
193240 {
194241 request_discovered = false ;
195242 topic_request = ddspipe::core::types::DdsTopic ();
@@ -214,17 +261,17 @@ struct ServiceDiscovered
214261 }
215262
216263 bool get_topic (
217- const RpcUtils::RpcType& rpc_type ,
264+ SERVICE_TYPE service_type ,
218265 ddspipe::core::types::DdsTopic& topic)
219266 {
220- if (rpc_type == RpcUtils::RpcType:: RPC_REQUEST )
267+ if (service_type == SERVICE_TYPE :: SERVICE_REQUEST )
221268 {
222269 if (!request_discovered)
223270 return false ;
224271 topic = topic_request;
225272 return true ;
226273 }
227- if (rpc_type == RpcUtils::RpcType:: RPC_REPLY )
274+ if (service_type == SERVICE_TYPE :: SERVICE_REPLY )
228275 {
229276 if (!reply_discovered)
230277 return false ;
@@ -251,7 +298,7 @@ struct ActionDiscovered
251298 }
252299
253300 std::string action_name;
254- RPC_PROTOCOL rpc_protocol{RPC_PROTOCOL ::UNKNOWN };
301+ RPC_PROTOCOL rpc_protocol{RPC_PROTOCOL ::PROTOCOL_UNKNOWN };
255302 std::weak_ptr<ServiceDiscovered> goal;
256303 std::weak_ptr<ServiceDiscovered> result;
257304 std::weak_ptr<ServiceDiscovered> cancel;
@@ -281,20 +328,17 @@ struct ActionDiscovered
281328
282329 bool add_service (
283330 std::shared_ptr<ServiceDiscovered> service,
284- RpcUtils::RpcType rpc_type )
331+ ACTION_TYPE action_type )
285332 {
286- switch (rpc_type )
333+ switch (action_type )
287334 {
288- case RpcUtils::RpcType::ACTION_GOAL_REQUEST :
289- case RpcUtils::RpcType::ACTION_GOAL_REPLY :
335+ case ACTION_TYPE ::ACTION_GOAL :
290336 goal = service;
291337 break ;
292- case RpcUtils::RpcType::ACTION_RESULT_REQUEST :
293- case RpcUtils::RpcType::ACTION_RESULT_REPLY :
338+ case ACTION_TYPE ::ACTION_RESULT :
294339 result = service;
295340 break ;
296- case RpcUtils::RpcType::ACTION_CANCEL_REQUEST :
297- case RpcUtils::RpcType::ACTION_CANCEL_REPLY :
341+ case ACTION_TYPE ::ACTION_CANCEL :
298342 cancel = service;
299343 break ;
300344 default :
@@ -306,15 +350,15 @@ struct ActionDiscovered
306350
307351 bool add_topic (
308352 const ddspipe::core::types::DdsTopic& topic,
309- RpcUtils::RpcType rpc_type )
353+ ACTION_TYPE action_type )
310354 {
311- switch (rpc_type )
355+ switch (action_type )
312356 {
313- case RpcUtils::RpcType ::ACTION_FEEDBACK :
357+ case ACTION_TYPE ::ACTION_FEEDBACK :
314358 feedback = topic;
315359 feedback_discovered = true ;
316360 break ;
317- case RpcUtils::RpcType ::ACTION_STATUS :
361+ case ACTION_TYPE ::ACTION_STATUS :
318362 status = topic;
319363 status_discovered = true ;
320364 break ;
@@ -325,7 +369,7 @@ struct ActionDiscovered
325369 return true ;
326370 }
327371
328- RpcUtils:: RpcAction get_action (const std::string& action_name )
372+ RpcAction get_action ()
329373 {
330374 auto g = goal.lock ();
331375 auto r = result.lock ();
@@ -334,7 +378,7 @@ struct ActionDiscovered
334378 if (!fully_discovered || !g || !r || !c)
335379 throw std::runtime_error (" Action not fully discovered or ServiceDiscovered expired" );
336380
337- return RpcUtils:: RpcAction (
381+ return RpcAction (
338382 action_name,
339383 g->get_service (),
340384 r->get_service (),
0 commit comments