Tulip  4.6.0
Better Visualization Through Research
library/tulip-core/include/tulip/WithDependency.h
00001 /*
00002  *
00003  * This file is part of Tulip (www.tulip-software.org)
00004  *
00005  * Authors: David Auber and the Tulip development Team
00006  * from LaBRI, University of Bordeaux
00007  *
00008  * Tulip is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU Lesser General Public License
00010  * as published by the Free Software Foundation, either version 3
00011  * of the License, or (at your option) any later version.
00012  *
00013  * Tulip is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00016  * See the GNU General Public License for more details.
00017  *
00018  */
00019 
00020 #ifndef _TULIPWITHDEPENDENCY
00021 #define _TULIPWITHDEPENDENCY
00022 
00023 #include <list>
00024 #include <string>
00025 #include <typeinfo>
00026 #include <tulip/tulipconf.h>
00027 
00028 namespace tlp {
00029 
00030 /**
00031  * @ingroup Plugins
00032  *
00033  * @brief Represents a plugin's dependency to another plugin.
00034  * In addition to maganing plugin registration, Tulip also handles a dependency mechanism between plugins.
00035  * Every Tulip plugin inherits from the tlp::WithDependency interface which allows to declare that another plugin should be loaded in order for this plugin to run.
00036  * When declaring a dependency, a plugin state the name and the version of the dependecy. This is done by calling tlp::WithDependency::addDependency()
00037  *
00038  * @see tlp::WithDependency
00039  */
00040 struct Dependency {
00041   /**
00042    * @brief The name of the plug-in, as registered in the Tulip plug-in system.
00043    */
00044   std::string pluginName;
00045   /**
00046    * @brief The required version of the plug-in.
00047    */
00048   std::string pluginRelease;
00049 
00050   /**
00051    * @brief Constructs a new dependency.
00052    *
00053    * @param pName The name of the plug-in, as registered in the Tulip plug-in system.
00054    * @param pRelease The required version of the plug-in.
00055    */
00056   Dependency(std::string pName,
00057              std::string pRelease):pluginName(pName),pluginRelease(pRelease) {
00058 
00059   }
00060 };
00061 
00062 /**
00063  * @ingroup Plugins
00064  * @brief Describes the dependencies of a plug-in on other plug-ins, identified by their name and their version number.
00065  *
00066  * This allows to have a plug-in inner workings depend on other plug-ins without linking them statically, or hoping depended plug-in will be there.
00067  */
00068 class WithDependency {
00069 protected:
00070   /**
00071    * @brief The inner list of dependencies.
00072    */
00073   std::list<Dependency> _dependencies;
00074 public:
00075   /**
00076    * @brief Adds a dependency upon another plug-in.
00077    *
00078    * @param factory The type name of the plug-in (e.g. 'DoubleAlgorithm')
00079    * @param name The name of the plug-in, as registered in the Tulip plug-in system.
00080    * @param release The required version of the depended plug-in.
00081    */
00082   void addDependency(const char *name,const char *release) {
00083     _dependencies.push_back(Dependency(name, release));
00084   }
00085 
00086   /**
00087    * @brief Gets the list of Dependencies of this plug-in.
00088    *
00089    * @return list<Dependency> The list of dependencies of this plug-in.
00090    */
00091   const std::list<Dependency>& dependencies() const {
00092     return _dependencies;
00093   }
00094 
00095 };
00096 
00097 
00098 }
00099 #endif
 All Classes Files Functions Variables Enumerations Enumerator Properties