Tulip  5.3.0
Large graphs analysis and drawing
ImportModule.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 ///@cond DOXYGEN_HIDDEN
20 
21 #ifndef _IMPORTMODULE_H
22 #define _IMPORTMODULE_H
23 
24 #include <tulip/Plugin.h>
25 
26 #include <list>
27 #include <string>
28 
29 namespace tlp {
30 
31 static const std::string IMPORT_CATEGORY = "Import";
32 
33 class PluginProgress;
34 class Graph;
35 class DataSet;
36 
37 /**
38  * @addtogroup Plugins
39  * @brief Base class for import plug-ins.
40  **/
41 class ImportModule : public tlp::Plugin {
42 public:
43  ImportModule(const tlp::PluginContext *context) {
44  if (context != nullptr) {
45  const tlp::AlgorithmContext *algoritmContext =
46  static_cast<const tlp::AlgorithmContext *>(context);
47  graph = algoritmContext->graph;
48  pluginProgress = algoritmContext->pluginProgress;
49  dataSet = algoritmContext->dataSet;
50  }
51  }
52 
53  /**
54  * @brief Gets the extensions of the file formats the plugin can import.
55  * e.g. a TLP import would return 'tlp'.
56  *
57  * @return the list of file extensions the plugin can import.
58  **/
59  virtual std::list<std::string> fileExtensions() const {
60  return std::list<std::string>();
61  }
62 
63  /**
64  * @brief Gets the extensions of the gzipped file formats this plugin can import.
65  * e.g. a TLP import would return 'tlp.gz and tlpz'.
66  *
67  * @since Tulip 5.0
68  *
69  * @return the list of gzipped file extensions the plugin can import.
70  **/
71  virtual std::list<std::string> gzipFileExtensions() const {
72  return std::list<std::string>();
73  }
74 
75  /**
76  * @brief Gets all the extensions (normal and gzipped) of the file formats this plugin can import.
77  *
78  * @since Tulip 5.0
79  *
80  * @return the list of file extensions the plugin can import.
81  **/
82  std::list<std::string> allFileExtensions() const {
83  std::list<std::string> zext(gzipFileExtensions());
84  std::list<std::string> ext(fileExtensions());
85  ext.splice(ext.end(), zext);
86  return ext;
87  }
88 
89  std::string category() const override {
90  return IMPORT_CATEGORY;
91  }
92 
93  std::string icon() const override {
94  return ":/tulip/gui/icons/64/document-import.png";
95  }
96 
97  /**
98  * @brief The import operations should take place here.
99  *
100  * @return bool Whether the import was successful or not.
101  **/
102  virtual bool importGraph() = 0;
103 
104  /**
105  * @brief The Graph in which to write the data to import.
106  **/
107  Graph *graph;
108 
109  /**
110  * @brief A means to report progress to the user.
111  **/
112  PluginProgress *pluginProgress;
113 
114  /**
115  * @brief A container for the parameters of this import plug-in.
116  **/
117  DataSet *dataSet;
118 };
119 } // namespace tlp
120 #endif
121 ///@endcond
PluginProgress * pluginProgress
A progress handler to notify the user about the progress state of the algorithm when run...
Definition: PluginContext.h:74
Graph * importGraph(const std::string &format, DataSet &dataSet, PluginProgress *progress=nullptr, Graph *newGraph=nullptr)
Imports a graph using the specified import plugin with the parameters stored in the DataSet...
DataSet * dataSet
Input parameters set by the user when running the plugin.
Definition: PluginContext.h:67
Contains runtime parameters for a plugin.
Definition: PluginContext.h:42
Top-level interface for plug-ins.
Definition: Plugin.h:85
Parameters structure for a tlp::Algorithm.
Definition: PluginContext.h:55
Graph * graph
The pointer to the tlp::Graph on which the algorithm will be run.
Definition: PluginContext.h:60