ComponentLoader.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  tag: Peter Soetens Thu Feb 1 16:30:11 2007 +0000 ComponentLoader.hpp
3 
4  ComponentLoader.hpp - description
5  -------------------
6  begin : Thu Feb 1 2007
7  copyright : (C) 2007 Peter Soetens
8  email : peter@thesourceworks.com
9 
10  ***************************************************************************
11  * This library is free software; you can redistribute it and/or *
12  * modify it under the terms of the GNU General Public *
13  * License as published by the Free Software Foundation; *
14  * version 2 of the License. *
15  * *
16  * As a special exception, you may use this file as part of a free *
17  * software library without restriction. Specifically, if other files *
18  * instantiate templates or use macros or inline functions from this *
19  * file, or you compile this file and link it with other files to *
20  * produce an executable, this file does not by itself cause the *
21  * resulting executable to be covered by the GNU General Public *
22  * License. This exception does not however invalidate any other *
23  * reasons why the executable file might be covered by the GNU General *
24  * Public License. *
25  * *
26  * This library is distributed in the hope that it will be useful, *
27  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
28  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
29  * General Public License for more details. *
30  * *
31  * You should have received a copy of the GNU General Public *
32  * License along with this library; if not, write to the Free Software *
33  * Foundation, Inc., 59 Temple Place, *
34  * Suite 330, Boston, MA 02111-1307 USA *
35  * *
36  ***************************************************************************/
37 
38 
39 #ifndef ORO_COMPONENTLOADER_HPP_
40 #define ORO_COMPONENTLOADER_HPP_
41 
42 #include <string>
43 #include <vector>
44 #include <boost/shared_ptr.hpp>
45 #include <rtt/Component.hpp>
46 
47 namespace RTT {
61  {
66  class LoadedLib{
67  public:
68  LoadedLib(std::string n, std::string short_name, void* h)
69  : filename(n), shortname(short_name), handle(h)
70  {
71  }
75  std::string filename;
79  std::string shortname;
80 
84  void* handle;
85 
86  std::vector<std::string> components_type;
87  };
88 
89  struct ComponentData {
91  : instance(0), type("")
92  {}
97  std::string type;
98  };
99 
103  typedef std::map<std::string, ComponentData> CompList;
104 
105  CompList comps;
106 
107 
108  std::vector< LoadedLib > loadedLibs;
109 
110  std::vector< std::string > loadedPackages;
111 
115  std::string component_path;
116 
125  bool loadInProcess(std::string filename, std::string shortname, bool log_error );
126 
133  bool reloadInProcess(std::string filename, std::string shortname);
134 
142  bool isCompatibleComponent(std::string const& filepath);
143 
147  bool importInstalledPackage(std::string const& package, std::string const& path_list);
148  public:
149  typedef boost::shared_ptr<ComponentLoader> shared_ptr;
155  static boost::shared_ptr<ComponentLoader> Instance();
156 
161  static void Release();
162 
170  bool import(std::string const& path_list);
171 
181  bool isImported(std::string type_name);
182 
190  bool import(std::string const& name, std::string const& path_list);
191 
197  bool loadLibrary(std::string const& path);
198 
203  bool reloadLibrary(std::string const& filepath);
204 
211  RTT::TaskContext* loadComponent(std::string const& name, std::string const& type);
212 
219  bool unloadComponent( RTT::TaskContext* tc );
220 
225  std::vector<std::string> listComponents() const;
226 
231  std::vector<std::string> listComponentTypes() const;
232 
239  std::string getComponentPath() const;
240 
247  void setComponentPath( std::string const& newpath );
248 
253  const FactoryMap& getFactories() const;
254 
258  void addFactory( std::string const& name, ComponentLoaderSignature factory );
259  };
260 }
261 
262 
263 #endif /* ORO_COMPONENTLOADER_HPP_ */
TaskContext *(* ComponentLoaderSignature)(std::string instance_name)
Definition: Component.hpp:61
LoadedLib(std::string n, std::string short_name, void *h)
boost::shared_ptr< ComponentLoader > shared_ptr
bool loadInProcess(std::string filename, std::string shortname, bool log_error)
bool isImported(std::string type_name)
RTT::TaskContext * loadComponent(std::string const &name, std::string const &type)
void addFactory(std::string const &name, ComponentLoaderSignature factory)
static boost::shared_ptr< ComponentLoader > Instance()
std::map< std::string, ComponentLoaderSignature > FactoryMap
Definition: Component.hpp:62
std::vector< std::string > listComponents() const
std::string getComponentPath() const
bool loadLibrary(std::string const &path)
std::vector< LoadedLib > loadedLibs
std::vector< std::string > listComponentTypes() const
bool reloadLibrary(std::string const &filepath)
void setComponentPath(std::string const &newpath)
std::map< std::string, ComponentData > CompList
std::vector< std::string > components_type
bool unloadComponent(RTT::TaskContext *tc)
std::vector< std::string > loadedPackages
bool importInstalledPackage(std::string const &package, std::string const &path_list)
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
Definition: Activity.cpp:53
bool reloadInProcess(std::string filename, std::string shortname)
const FactoryMap & getFactories() const
bool isCompatibleComponent(std::string const &filepath)


rtt
Author(s): RTT Developers
autogenerated on Tue Jun 25 2019 19:33:22