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