Tulip  5.4.0
Large graphs analysis and drawing
WithDependency.h
1 /*
2  *
3  * This file is part of Tulip (http://tulip.labri.fr)
4  *
5  * Authors: David Auber and the Tulip development Team
6  * from LaBRI, University of Bordeaux
7  *
8  * Tulip is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License
10  * as published by the Free Software Foundation, either version 3
11  * of the License, or (at your option) any later version.
12  *
13  * Tulip is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  * See the GNU General Public License for more details.
17  *
18  */
19 
20 ///@cond DOXYGEN_HIDDEN
21 
22 #ifndef _TULIPWITHDEPENDENCY
23 #define _TULIPWITHDEPENDENCY
24 
25 #include <list>
26 #include <string>
27 #include <typeinfo>
28 #include <tulip/tulipconf.h>
29 
30 namespace tlp {
31 
32 /**
33  * @ingroup Plugins
34  *
35  * @brief Represents a plugin's dependency to another plugin.
36  * In addition to maganing plugin registration, Tulip also handles a dependency mechanism between
37  * plugins.
38  * Every Tulip plugin inherits from the tlp::WithDependency interface which allows to declare that
39  * another plugin should be loaded in order for this plugin to run.
40  * When declaring a dependency, a plugin state the name and the version of the dependency. This is
41  * done by calling tlp::WithDependency::addDependency()
42  *
43  * @see tlp::WithDependency
44  */
45 struct Dependency {
46  /**
47  * @brief The name of the plug-in, as registered in the Tulip plug-in system.
48  */
49  std::string pluginName;
50  /**
51  * @brief The required version of the plug-in.
52  */
53  std::string pluginRelease;
54 
55  /**
56  * @brief Constructs a new dependency.
57  *
58  * @param pName The name of the plug-in, as registered in the Tulip plug-in system.
59  * @param pRelease The required version of the plug-in.
60  */
61  Dependency(std::string pName, std::string pRelease)
62  : pluginName(pName), pluginRelease(pRelease) {}
63 };
64 
65 /**
66  * @ingroup Plugins
67  * @brief Describes the dependencies of a plug-in on other plug-ins, identified by their name and
68  * their version number.
69  *
70  * This allows to have a plug-in inner workings depend on other plug-ins without linking them
71  * statically, or hoping depended plug-in will be there.
72  */
73 class WithDependency {
74 protected:
75  /**
76  * @brief The inner list of dependencies.
77  */
78  std::list<Dependency> _dependencies;
79 
80 public:
81  /**
82  * @brief Adds a dependency upon another plug-in.
83  *
84  * @param factory The type name of the plug-in (e.g. 'DoubleAlgorithm')
85  * @param name The name of the plug-in, as registered in the Tulip plug-in system.
86  * @param release The required version of the depended plug-in.
87  */
88  void addDependency(const char *name, const char *release) {
89  _dependencies.push_back(Dependency(name, release));
90  }
91 
92  /**
93  * @brief Gets the list of Dependencies of this plug-in.
94  *
95  * @return list<Dependency> The list of dependencies of this plug-in.
96  */
97  const std::list<Dependency> &dependencies() const {
98  return _dependencies;
99  }
100 };
101 } // namespace tlp
102 #endif
103 
104 ///@endcond