Tulip  4.8.0
Better Visualization Through Research
 All Classes Files Functions Variables Enumerations Enumerator Properties Groups Pages
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  * @brief Initializes the DataSet to the one passed in the context.
47  *
48  * @param context The context this import plug-in runs into.
49  **/
50  ImportModule (const tlp::PluginContext* context) {
51  if(context != NULL) {
52  const tlp::AlgorithmContext* algoritmContext = dynamic_cast<const tlp::AlgorithmContext*>(context);
53  assert(algoritmContext != NULL);
54  graph = algoritmContext->graph;
55  pluginProgress = algoritmContext->pluginProgress;
56  dataSet = algoritmContext->dataSet;
57  }
58  }
59 
60  virtual std::list<std::string> fileExtensions() const {
61  return std::list<std::string>();
62  }
63 
64  virtual std::string getGroup() const {
65  return "Import";
66  }
67 
68  virtual std::string category() const {
69  return IMPORT_CATEGORY;
70  }
71  std::string icon() const {
72  return ":/tulip/gui/icons/32/plugin_import_export.png";
73  }
74 
75  /**
76  * @brief The import operations should take place here.
77  *
78  * @return bool Whether the import was successful or not.
79  **/
80  virtual bool importGraph()=0;
81 
82  /**
83  * @brief The Graph in which to write the data to import.
84  **/
85  Graph *graph;
86 
87  /**
88  * @brief A means to report progress to the user.
89  **/
90  PluginProgress *pluginProgress;
91 
92  /**
93  * @brief A container for the parameters of this import plug-in.
94  **/
95  DataSet *dataSet;
96 };
97 
98 
99 }
100 #endif
101 ///@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