ROS 2 rclcpp + rcl - humble  humble
ROS 2 C++ Client Library with ROS Client Library
executable_list.cpp
1 // Copyright 2019 Nobleo Technology
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 #include <utility>
16 
17 #include "rclcpp/experimental/executable_list.hpp"
18 
20 
21 ExecutableList::ExecutableList()
22 : number_of_subscriptions(0),
23  number_of_timers(0),
24  number_of_services(0),
25  number_of_clients(0),
26  number_of_waitables(0)
27 {}
28 
29 ExecutableList::~ExecutableList()
30 {}
31 
32 void
33 ExecutableList::clear()
34 {
35  this->timer.clear();
36  this->number_of_timers = 0;
37 
38  this->subscription.clear();
39  this->number_of_subscriptions = 0;
40 
41  this->service.clear();
42  this->number_of_services = 0;
43 
44  this->client.clear();
45  this->number_of_clients = 0;
46 
47  this->waitable.clear();
48  this->number_of_waitables = 0;
49 }
50 
51 void
52 ExecutableList::add_subscription(rclcpp::SubscriptionBase::SharedPtr subscription)
53 {
54  this->subscription.push_back(std::move(subscription));
55  this->number_of_subscriptions++;
56 }
57 
58 void
59 ExecutableList::add_timer(rclcpp::TimerBase::SharedPtr timer)
60 {
61  this->timer.push_back(std::move(timer));
62  this->number_of_timers++;
63 }
64 
65 void
66 ExecutableList::add_service(rclcpp::ServiceBase::SharedPtr service)
67 {
68  this->service.push_back(std::move(service));
69  this->number_of_services++;
70 }
71 
72 void
73 ExecutableList::add_client(rclcpp::ClientBase::SharedPtr client)
74 {
75  this->client.push_back(std::move(client));
76  this->number_of_clients++;
77 }
78 
79 void
80 ExecutableList::add_waitable(rclcpp::Waitable::SharedPtr waitable)
81 {
82  this->waitable.push_back(std::move(waitable));
83  this->number_of_waitables++;
84 }
This class contains subscriptionbase, timerbase, etc. which can be used to run callbacks.