OpenWalnut  1.5.0dev
WMReadVIM.h
1 //---------------------------------------------------------------------------
2 //
3 // Project: OpenWalnut ( http://www.openwalnut.org )
4 //
5 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6 // For more information see http://www.openwalnut.org/copying
7 //
8 // This file is part of OpenWalnut.
9 //
10 // OpenWalnut is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // OpenWalnut is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22 //
23 //---------------------------------------------------------------------------
24 
25 #ifndef WMREADVIM_H
26 #define WMREADVIM_H
27 
28 #include <memory>
29 #include <string>
30 #include <vector>
31 
32 #include "core/dataHandler/WDataSetPoints.h"
33 #include "core/kernel/WDataModule.h"
34 #include "core/kernel/WModuleOutputData.h"
35 
36 /**
37  * This module loads VIM files (point data).
38  *
39  * \ingroup modules
40  */
41 class WMReadVIM: public WDataModule
42 {
43 public:
44  /**
45  * Default constructor.
46  */
47  WMReadVIM();
48 
49  /**
50  * Destructor.
51  */
52  virtual ~WMReadVIM();
53 
54  /**
55  * Gives back the name of this module.
56  * \return the module's name.
57  */
58  virtual const std::string getName() const;
59 
60  /**
61  * Gives back a description of this module.
62  * \return description to module.
63  */
64  virtual const std::string getDescription() const;
65 
66  /**
67  * Due to the prototype design pattern used to build modules, this method returns a new instance of this method. NOTE: it
68  * should never be initialized or modified in some other way. A simple new instance is required.
69  *
70  * \return the prototype used to create every module in OpenWalnut.
71  */
72  virtual std::shared_ptr< WModule > factory() const;
73 
74  /**
75  * Define a list of file filters we support.
76  *
77  * \return the list of filters
78  */
79  virtual std::vector< WDataModuleInputFilter::ConstSPtr > getInputFilter() const;
80 
81 protected:
82  /**
83  * Entry point after loading the module. Runs in separate thread.
84  */
85  virtual void moduleMain();
86 
87  /**
88  * Initialize the connectors this module is using.
89  */
90  virtual void connectors();
91 
92  /**
93  * Load data.
94  */
95  virtual void load();
96 
97  /**
98  * Handle a newly set input. Implement this method to load the newly set input. You can get the input using the \ref getInput and \ref getInputAs
99  * methods. Please remember that it is possible to get a NULL pointer here.
100  * This happens when the user explicitly sets no input. In this case, you should clean up and reset your output connectors.
101  *
102  * \note it is very important to NOT load the data inside of this method. It is usually called in the GUI thread. This would block the whole GUI.
103  * Instead, use this method for firing a condition, which then wakes your module thread.
104  */
105  virtual void handleInputChange();
106 
107 private:
108  /**
109  * The output connector for the data.
110  */
111  std::shared_ptr< WModuleOutputData< WDataSetPoints > > m_output;
112 
113  /**
114  * True if the load function needs to be called. Usually set by handleInputChange or the reload trigger
115  */
116  bool m_reload;
117 };
118 
119 #endif // WMREADVIM_H
Base for all data loader modules.
Definition: WDataModule.h:47
This module loads VIM files (point data).
Definition: WMReadVIM.h:42
virtual void load()
Load data.
Definition: WMReadVIM.cpp:120
std::shared_ptr< WModuleOutputData< WDataSetPoints > > m_output
The output connector for the data.
Definition: WMReadVIM.h:111
virtual std::shared_ptr< WModule > factory() const
Due to the prototype design pattern used to build modules, this method returns a new instance of this...
Definition: WMReadVIM.cpp:52
virtual const std::string getDescription() const
Gives back a description of this module.
Definition: WMReadVIM.cpp:63
virtual void connectors()
Initialize the connectors this module is using.
Definition: WMReadVIM.cpp:69
virtual void handleInputChange()
Handle a newly set input.
Definition: WMReadVIM.cpp:113
virtual void moduleMain()
Entry point after loading the module.
Definition: WMReadVIM.cpp:77
virtual std::vector< WDataModuleInputFilter::ConstSPtr > getInputFilter() const
Define a list of file filters we support.
Definition: WMReadVIM.cpp:103
virtual ~WMReadVIM()
Destructor.
Definition: WMReadVIM.cpp:47
bool m_reload
True if the load function needs to be called.
Definition: WMReadVIM.h:116
virtual const std::string getName() const
Gives back the name of this module.
Definition: WMReadVIM.cpp:57
WMReadVIM()
Default constructor.
Definition: WMReadVIM.cpp:40