Tulip  6.0.0
Large graphs analysis and drawing
WithDependency.h
1 /*
2  *
3  * This file is part of Tulip (https://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 <tulip/tulipconf.h>
28 
29 namespace tlp {
30 
31 /**
32  * @ingroup Plugins
33  *
34  * @brief Represents a plugin's dependency to another plugin.
35  * In addition to maganing plugin registration, Tulip also handles a dependency mechanism between
36  * plugins.
37  * Every Tulip plugin inherits from the tlp::WithDependency interface which allows to declare that
38  * another plugin should be loaded in order for this plugin to run.
39  * When declaring a dependency, a plugin state the name and the version of the dependency. This is
40  * done by calling tlp::WithDependency::addDependency()
41  *
42  * @see tlp::WithDependency
43  */
44 struct Dependency {
45  /**
46  * @brief The name of the plug-in, as registered in the Tulip plug-in system.
47  */
48  std::string pluginName;
49  /**
50  * @brief The required version of the plug-in.
51  */
52  std::string pluginRelease;
53 
54  /**
55  * @brief Constructs a new dependency.
56  *
57  * @param pName The name of the plug-in, as registered in the Tulip plug-in system.
58  * @param pRelease The required version of the plug-in.
59  */
60  Dependency(std::string pName, std::string pRelease)
61  : pluginName(pName), pluginRelease(pRelease) {}
62 };
63 
64 /**
65  * @ingroup Plugins
66  * @brief Describes the dependencies of a plug-in on other plug-ins, identified by their name and
67  * their version number.
68  *
69  * This allows to have a plug-in inner workings depend on other plug-ins without linking them
70  * statically, or hoping depended plug-in will be there.
71  */
72 class WithDependency {
73 protected:
74  /**
75  * @brief The inner list of dependencies.
76  */
77  std::list<Dependency> _dependencies;
78 
79 public:
80  /**
81  * @brief Adds a dependency upon another plug-in.
82  *
83  * @param factory The type name of the plug-in (e.g. 'DoubleAlgorithm')
84  * @param name The name of the plug-in, as registered in the Tulip plug-in system.
85  * @param release The required version of the depended plug-in.
86  */
87  void addDependency(const char *name, const char *release) {
88  _dependencies.push_back(Dependency(name, release));
89  }
90 
91  /**
92  * @brief Gets the list of Dependencies of this plug-in.
93  *
94  * @return list<Dependency> The list of dependencies of this plug-in.
95  */
96  const std::list<Dependency> &dependencies() const {
97  return _dependencies;
98  }
99 };
100 } // namespace tlp
101 #endif
102 
103 ///@endcond