meta_object.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012, Willow Garage, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * * Neither the name of the Willow Garage, Inc. nor the names of its
14  * contributors may be used to endorse or promote products derived from
15  * this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  */
29 
30 #include <string>
31 
34 
35 namespace class_loader
36 {
37 namespace impl
38 {
39 
41  const std::string & class_name, const std::string & base_class_name)
42 : associated_library_path_("Unknown"),
43  base_class_name_(base_class_name),
44  class_name_(class_name),
45  typeid_base_class_name_("UNSET")
46 {
47  CONSOLE_BRIDGE_logDebug(
48  "class_loader.impl.AbstractMetaObjectBase: "
49  "Creating MetaObject %p (base = %s, derived = %s, library path = %s)",
50  this, baseClassName().c_str(), className().c_str(), getAssociatedLibraryPath().c_str());
51 }
52 
54 {
55  CONSOLE_BRIDGE_logDebug(
56  "class_loader.impl.AbstractMetaObjectBase: "
57  "Destroying MetaObject %p (base = %s, derived = %s, library path = %s)",
58  this, baseClassName().c_str(), className().c_str(), getAssociatedLibraryPath().c_str());
59 }
60 
62 {
63  return class_name_;
64 }
65 
67 {
68  return base_class_name_;
69 }
70 
72 {
74 }
75 
77 {
79 }
80 
82 {
83  associated_library_path_ = library_path;
84 }
85 
87 {
89  if (std::find(v.begin(), v.end(), loader) == v.end()) {
90  v.push_back(loader);
91  }
92 }
93 
95 {
97  ClassLoaderVector::iterator itr = std::find(v.begin(), v.end(), loader);
98  if (itr != v.end()) {
99  v.erase(itr);
100  }
101 }
102 
104 {
106  ClassLoaderVector::iterator itr = std::find(v.begin(), v.end(), loader);
107  return itr != v.end();
108 }
109 
111 {
112  return associated_class_loaders_.size() > 0;
113 }
114 
116 {
118 }
119 
120 } // namespace impl
121 } // namespace class_loader
std::string getAssociatedLibraryPath()
Gets the path to the library associated with this factory.
Definition: meta_object.cpp:76
std::vector< class_loader::ClassLoader * > ClassLoaderVector
Definition: meta_object.hpp:53
AbstractMetaObjectBase(const std::string &class_name, const std::string &base_class_name)
Constructor for the class.
Definition: meta_object.cpp:40
This class allows loading and unloading of dynamically linked libraries which contain class definitio...
~AbstractMetaObjectBase()
Destructor for the class. THIS MUST NOT BE VIRTUAL AND OVERRIDDEN BY TEMPLATE SUBCLASSES, OTHERWISE THEY WILL PULL IN A REDUNDANT METAOBJECT DESTRUCTOR OUTSIDE OF libclass_loader WITHIN THE PLUGIN LIBRARY! T.
Definition: meta_object.cpp:53
void addOwningClassLoader(ClassLoader *loader)
Associates a ClassLoader owner with this factory,.
Definition: meta_object.cpp:86
std::string baseClassName() const
gets the base class for the class this factory represents
Definition: meta_object.cpp:66
void setAssociatedLibraryPath(std::string library_path)
Sets the path to the library associated with this factory.
Definition: meta_object.cpp:81
void removeOwningClassLoader(const ClassLoader *loader)
Removes a ClassLoader that is an owner of this factory.
Definition: meta_object.cpp:94
bool isOwnedByAnybody()
Indicates if the factory is within the usable scope of any ClassLoader.
bool isOwnedBy(const ClassLoader *loader)
Indicates if the factory is within the usable scope of a ClassLoader.
std::string className() const
Gets the literal name of the class.
Definition: meta_object.cpp:61
std::string typeidBaseClassName() const
Gets the name of the class as typeid(BASE_CLASS).name() would return it.
Definition: meta_object.cpp:71


class_loader
Author(s): Mirza Shah
autogenerated on Sat Feb 8 2020 03:20:57