/usr/include/tulip/cxx/TemplateFactory.cxx is in libtulip-dev 3.1.2-2.3ubuntu3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | //-*-c++-*-
/**
Authors: David Auber, Patrick Mary, Morgan Mathiaut
from the LaBRI Visualization Team
Email : auber@tulip-software.org
Last modification : 13/03/2009
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
*/
//====================================================================================
#include <iostream>
#include <tulip/StlIterator.h>
#include <tulip/Plugin.h>
template<class ObjectFactory, class ObjectType, class Context>
tlp::Iterator<std::string>* tlp::TemplateFactory<ObjectFactory, ObjectType, Context>::availablePlugins() {
return new tlp::StlIterator<std::string,std::set<std::string>::const_iterator>(objNames.begin(), objNames.end());
}
template<class ObjectFactory, class ObjectType, class Context>
bool tlp::TemplateFactory<ObjectFactory, ObjectType, Context>::pluginExists(const std::string &pluginName) {
return (objMap.find(pluginName) != objMap.end());
}
template<class ObjectFactory, class ObjectType, class Context>
void tlp::TemplateFactory<ObjectFactory,ObjectType,Context>::registerPlugin(ObjectFactory *objectFactory) {
std::string pluginName = objectFactory->getName();
if (!pluginExists(pluginName)) {
objNames.insert(pluginName);
objMap[pluginName]=objectFactory;
ObjectType *withParam=objectFactory->createPluginObject(Context());
objParam[pluginName] = withParam->getParameters();
// loop over dependencies
// to demangle the class names
std::list<tlp::Dependency> dependencies = withParam->getDependencies();
std::list<tlp::Dependency>::iterator itD = dependencies.begin();
for (; itD != dependencies.end(); itD++) {
const char *factoryDepName = (*itD).factoryName.c_str();
(*itD).factoryName = std::string(tlp::demangleTlpClassName(factoryDepName));
}
objDeps[pluginName] = dependencies;
objRels[pluginName] = objectFactory->getRelease();
if (currentLoader!=0) currentLoader->loaded(
pluginName,
objectFactory->getAuthor(),
objectFactory->getDate(),
objectFactory->getInfo(),
objectFactory->getRelease(),
objectFactory->getTulipRelease(),
dependencies
);
} else {
if (currentLoader != 0) {
std::string tmpStr;
tmpStr += "'" + pluginName + "' " + getPluginsClassName() + " plugin";
currentLoader->aborted(tmpStr, "multiple definitions found; check your plugin librairies.");
}
}
}
template<class ObjectFactory, class ObjectType, class Context>
void tlp::TemplateFactory<ObjectFactory,ObjectType,Context>::removePlugin(const std::string &name) {
objNames.erase(name);
objMap.erase(name);
objParam.erase(name);
objDeps.erase(name);
objRels.erase(name);
}
template<class ObjectFactory, class ObjectType, class Context>
ObjectType * tlp::TemplateFactory<ObjectFactory,ObjectType,Context>::getPluginObject(const std::string& name, Context c) {
typename ObjectCreator::iterator it;
it=objMap.find(name);
if (it!=objMap.end()) return (*it).second->createPluginObject(c);
return 0;
}
template<class ObjectFactory, class ObjectType, class Context>
tlp::StructDef tlp::TemplateFactory<ObjectFactory,ObjectType,Context>::getPluginParameters(std::string name) {
assert(objMap.find(name)!=objMap.end());
return objParam[name];
}
template<class ObjectFactory, class ObjectType, class Context>
std::string tlp::TemplateFactory<ObjectFactory,ObjectType,Context>::getPluginRelease(std::string name) {
assert(objMap.find(name)!=objMap.end());
return objRels[name];
}
template<class ObjectFactory, class ObjectType, class Context>
std::list<tlp::Dependency> tlp::TemplateFactory<ObjectFactory,ObjectType,Context>::getPluginDependencies(std::string name) {
assert(objMap.find(name)!=objMap.end());
return objDeps[name];
}
template<class ObjectFactory, class ObjectType, class Context> std::string tlp::TemplateFactory<ObjectFactory,ObjectType,Context>::getPluginsClassName() {
return std::string(demangleTlpClassName(typeid(ObjectType).name()));
}
|