meta_object.cpp
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2012, Willow Garage, Inc.
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions are met:
00007  *
00008  *     * Redistributions of source code must retain the above copyright
00009  *       notice, this list of conditions and the following disclaimer.
00010  *     * Redistributions in binary form must reproduce the above copyright
00011  *       notice, this list of conditions and the following disclaimer in the
00012  *       documentation and/or other materials provided with the distribution.
00013  *     * Neither the name of the Willow Garage, Inc. nor the names of its
00014  *       contributors may be used to endorse or promote products derived from
00015  *       this software without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00018  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00021  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00022  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00023  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00024  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00025  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00026  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00027  * POSSIBILITY OF SUCH DAMAGE.
00028  */
00029 
00030 #include <string>
00031 
00032 #include "class_loader/meta_object.hpp"
00033 #include "class_loader/class_loader.hpp"
00034 
00035 namespace class_loader
00036 {
00037 namespace class_loader_private
00038 {
00039 
00040 AbstractMetaObjectBase::AbstractMetaObjectBase(
00041   const std::string & class_name, const std::string & base_class_name)
00042 : associated_library_path_("Unknown"),
00043   base_class_name_(base_class_name),
00044   class_name_(class_name),
00045   typeid_base_class_name_("UNSET")
00046 /*****************************************************************************/
00047 {
00048   CONSOLE_BRIDGE_logDebug(
00049     "class_loader.class_loader_private.AbstractMetaObjectBase: "
00050     "Creating MetaObject %p (base = %s, derived = %s, library path = %s)",
00051     this, baseClassName().c_str(), className().c_str(), getAssociatedLibraryPath().c_str());
00052 }
00053 
00054 AbstractMetaObjectBase::~AbstractMetaObjectBase()
00055 /*****************************************************************************/
00056 {
00057   CONSOLE_BRIDGE_logDebug(
00058     "class_loader.class_loader_private.AbstractMetaObjectBase: "
00059     "Destroying MetaObject %p (base = %s, derived = %s, library path = %s)",
00060     this, baseClassName().c_str(), className().c_str(), getAssociatedLibraryPath().c_str());
00061 }
00062 
00063 std::string AbstractMetaObjectBase::className() const
00064 /*****************************************************************************/
00065 {
00066   return class_name_;
00067 }
00068 
00069 std::string AbstractMetaObjectBase::baseClassName() const
00070 /*****************************************************************************/
00071 {
00072   return base_class_name_;
00073 }
00074 
00075 std::string AbstractMetaObjectBase::typeidBaseClassName() const
00076 /*****************************************************************************/
00077 {
00078   return typeid_base_class_name_;
00079 }
00080 
00081 std::string AbstractMetaObjectBase::getAssociatedLibraryPath()
00082 /*****************************************************************************/
00083 {
00084   return associated_library_path_;
00085 }
00086 
00087 void AbstractMetaObjectBase::setAssociatedLibraryPath(std::string library_path)
00088 /*****************************************************************************/
00089 {
00090   associated_library_path_ = library_path;
00091 }
00092 
00093 void AbstractMetaObjectBase::addOwningClassLoader(ClassLoader * loader)
00094 /*****************************************************************************/
00095 {
00096   ClassLoaderVector & v = associated_class_loaders_;
00097   if (std::find(v.begin(), v.end(), loader) == v.end()) {
00098     v.push_back(loader);
00099   }
00100 }
00101 
00102 void AbstractMetaObjectBase::removeOwningClassLoader(const ClassLoader * loader)
00103 /*****************************************************************************/
00104 {
00105   ClassLoaderVector & v = associated_class_loaders_;
00106   ClassLoaderVector::iterator itr = std::find(v.begin(), v.end(), loader);
00107   if (itr != v.end()) {
00108     v.erase(itr);
00109   }
00110 }
00111 
00112 bool AbstractMetaObjectBase::isOwnedBy(const ClassLoader * loader)
00113 /*****************************************************************************/
00114 {
00115   ClassLoaderVector & v = associated_class_loaders_;
00116   ClassLoaderVector::iterator itr = std::find(v.begin(), v.end(), loader);
00117   return itr != v.end();
00118 }
00119 
00120 bool AbstractMetaObjectBase::isOwnedByAnybody()
00121 /*****************************************************************************/
00122 {
00123   return associated_class_loaders_.size() > 0;
00124 }
00125 
00126 ClassLoaderVector AbstractMetaObjectBase::getAssociatedClassLoaders()
00127 /*****************************************************************************/
00128 {
00129   return associated_class_loaders_;
00130 }
00131 
00132 }  // namespace class_loader_private
00133 }  // namespace class_loader


class_loader
Author(s): Mirza Shah
autogenerated on Thu Jun 6 2019 20:43:27