loader_ros.h
Go to the documentation of this file.
1 #pragma once
2 
3 /*
4  * Copyright (c) 2010, Willow Garage, Inc.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are met:
9  *
10  * * Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  * * Neither the name of the Willow Garage, Inc. nor the names of its
16  * contributors may be used to endorse or promote products derived from
17  * this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 // This class is a copy-paste of LoaderROS from
33 // https://github.com/ros/nodelet_core/blob/indigo-devel/nodelet/src/loader.cpp which is not exported.
34 // It was only split to .h and .cpp file and imports were optimized. Also the namespace has been changed from
35 // nodelet:: to cras:: and, few cosmetic changes have been made and documentation has been added.
36 
37 #include <string>
38 
39 #include <boost/thread/mutex.hpp>
40 #include <boost/ptr_container/ptr_map.hpp>
41 
42 #include <bondcpp/bond.h>
43 #include <nodelet/loader.h>
44 #include <nodelet/nodelet.h>
45 #include <nodelet/NodeletLoad.h>
46 #include <nodelet/NodeletUnload.h>
47 #include <nodelet/NodeletList.h>
48 #include <ros/spinner.h>
49 #include <ros/callback_queue.h>
50 #include <ros/node_handle.h>
51 #include <ros/service_server.h>
52 
53 namespace cras
54 {
55 
64 class LoaderROS
65 {
66 public:
72  LoaderROS(::nodelet::Loader* parent, const ::ros::NodeHandle& nh);
73 
74 protected:
81  bool serviceLoad(::nodelet::NodeletLoad::Request& req, ::nodelet::NodeletLoad::Response& res);
82 
89  bool serviceUnload(::nodelet::NodeletUnload::Request& req, ::nodelet::NodeletUnload::Response& res);
90 
96  bool unload(const ::std::string& name);
97 
104  bool serviceList(::nodelet::NodeletList::Request& req, ::nodelet::NodeletList::Response& res);
105 
108 
111 
114 
117 
120 
122  ::boost::mutex lock_;
123 
126 
129 
131  typedef ::boost::ptr_map<::std::string, ::bond::Bond> M_stringToBond;
132 
134  M_stringToBond bond_map_;
135 };
136 
137 }
bool serviceLoad(::nodelet::NodeletLoad::Request &req, ::nodelet::NodeletLoad::Response &res)
Load a nodelet.
::ros::ServiceServer unload_server_
Service server for unload_nodelet service.
Definition: loader_ros.h:116
::boost::mutex lock_
Lock protecting access to parent_ and bond_map_.
Definition: loader_ros.h:122
::boost::ptr_map<::std::string, ::bond::Bond > M_stringToBond
Type of the map of nodelet name->bond.
Definition: loader_ros.h:131
::ros::ServiceServer list_server_
Service server for list service.
Definition: loader_ros.h:119
::ros::NodeHandle nh_
The node handle to use for the advertised services.
Definition: loader_ros.h:110
::nodelet::Loader * parent_
The actual nodelet loader to use.
Definition: loader_ros.h:107
::ros::ServiceServer load_server_
Service server for load_nodelet service.
Definition: loader_ros.h:113
bool unload(const ::std::string &name)
Unload a nodelet of the given name.
M_stringToBond bond_map_
Map of nodelet name->bond.
Definition: loader_ros.h:134
Definition: any.hpp:15
LoaderROS(::nodelet::Loader *parent, const ::ros::NodeHandle &nh)
Construct the ROS interface for the given loader.
bool serviceList(::nodelet::NodeletList::Request &req, ::nodelet::NodeletList::Response &res)
List all loaded nodelets.
::ros::AsyncSpinner bond_spinner_
Spinner of bond_callback_queue_.
Definition: loader_ros.h:128
bool serviceUnload(::nodelet::NodeletUnload::Request &req, ::nodelet::NodeletUnload::Response &res)
Unload a nodelet.
ROS interface for loading/unloading nodelets (internally using nodelet::Loader to do the work)...
Definition: loader_ros.h:64
::ros::CallbackQueue bond_callback_queue_
Callback queue used for the created bonds.
Definition: loader_ros.h:125


cras_cpp_common
Author(s): Martin Pecka
autogenerated on Sat Jun 17 2023 02:32:53