COVISE Core
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
WSModule.h
Go to the documentation of this file.
1 /* This file is part of COVISE.
2 
3  You can use it under the terms of the GNU Lesser General Public License
4  version 2.1 or later, see lgpl-2.1.txt.
5 
6  * License: LGPL 2+ */
7 
8 #ifndef WSMODULE_H
9 #define WSMODULE_H
10 
11 #include "WSExport.h"
12 #include "WSParameter.h"
13 #include "WSPort.h"
14 
15 #include "WSCoviseStub.h"
16 
17 #include <QPoint>
18 #include <QObject>
19 
20 namespace covise
21 {
22 
23 class WSLIBEXPORT WSModule : public QObject
24 {
25 
26  Q_OBJECT
27 
28  Q_PROPERTY(QString name READ getName)
29  Q_PROPERTY(QString id READ getID)
30  Q_PROPERTY(QString host READ getHost)
31  Q_PROPERTY(QString description READ getDescription)
32  Q_PROPERTY(QString category READ getCategory)
33  Q_PROPERTY(QString title READ getTitle WRITE setTitle)
34  Q_PROPERTY(QString instance READ getInstance)
35  Q_PROPERTY(bool dead READ isDead)
36 
37 public:
38  WSModule(const QString &name, const QString &category, const QString &host);
39  explicit WSModule(const covise::covise__Module &module);
40  ~WSModule();
41 
48  WSPort *addInputPort(const QString &inName, const QStringList &inTypes, WSPort::PortType inPortType = WSPort::Default);
49 
56  WSPort *addOutputPort(const QString &name, const QStringList &types, WSPort::PortType portType = WSPort::Default);
57 
64  WSParameter *addParameter(const QString &name, const QString &type, const QString &description);
65 
66  WSPort *getOutputPort(const QString &name) const;
67  WSPort *getInputPort(const QString &name) const;
68 
73  const QMap<QString, WSPort *> &getInputPorts() const
74  {
75  return this->inputPorts;
76  }
77 
82  const QMap<QString, WSPort *> &getOutputPorts() const
83  {
84  return this->outputPorts;
85  }
86 
91  const QMap<QString, WSParameter *> &getParameters() const
92  {
93  return this->parameters;
94  }
95 
96 signals:
97  void changed();
98  void parameterChanged(covise::WSParameter *);
99  void died();
100  void deleted(const QString &moduleID);
101 
102 public slots:
103 
104  // All return values have to be by value for the scripting interface to function
105 
110  QString getHost() const
111  {
112  return this->host;
113  }
114 
119  QString getName() const
120  {
121  return this->name;
122  }
123 
128  QString getID() const
129  {
130  return this->id;
131  }
132 
137  QString getDescription() const
138  {
139  return this->description;
140  }
141 
146  QString getCategory() const
147  {
148  return this->category;
149  }
150 
155  void setTitle(const QString &title);
156 
161  QString getTitle() const
162  {
163  return this->title;
164  }
165 
170  WSParameter *getParameter(const QString &name) const;
171 
176  QPoint getPosition() const
177  {
178  return this->position;
179  }
180 
186  void setPosition(int x, int y)
187  {
188  this->position.setX(x);
189  this->position.setY(y);
190  emit changed();
191  }
192 
193  QString getInstance() const
194  {
195  return this->instance;
196  }
197 
198  QStringList getParameterNames() const;
199 
200  bool isDead() const
201  {
202  return this->dead;
203  }
204 
205 public:
206  virtual covise::covise__Module getSerialisable() const;
207  void setFromSerialisable(const covise::covise__Module &serialisable);
208 
212  void instantiate(const QString &host, const QString &instance);
213 
218  void setID(const QString &id)
219  {
220  this->id = id;
221  emit changed();
222  }
223 
228  void setCategory(const QString &category)
229  {
230  this->category = category;
231  emit changed();
232  }
233 
238  void setDescription(const QString &description)
239  {
240  this->description = description;
241  emit changed();
242  }
243 
248  void setDead(bool dead);
249 
250 private slots:
251  void parameterChangedCB(covise::WSParameter *);
252 
253 private:
254  // Name of module
255  QString name;
256  // ID of a (running) module
257  QString id;
258  // Host the module is running on, may be empty
259  QString host;
260  // Description of module
261  QString description;
262  // Category of module
263  QString category;
264  // Module title
265  QString title;
266  // Module instance
267  QString instance;
268  // Parameters of the module with name of each parameter
269  QMap<QString, WSParameter *> parameters;
270  // Input ports of the module with name of each port
271  QMap<QString, WSPort *> inputPorts;
272  // Output ports of the module with name of each port
273  QMap<QString, WSPort *> outputPorts;
274 
275  // Position of the module on the canvas
276  QPoint position;
277 
278  bool dead;
279 };
280 }
281 #endif // WSMODULE_H
void setPosition(int x, int y)
Definition: WSModule.h:186
QMap< QString, WSParameter * > parameters
Definition: WSModule.h:269
QPoint position
Definition: WSModule.h:276
QString getHost() const
Definition: WSModule.h:110
QString getTitle() const
Definition: WSModule.h:161
Definition: WSPort.h:24
QString getCategory() const
Definition: WSModule.h:146
GLuint const GLchar * name
Definition: khronos-glext.h:6722
QPoint getPosition() const
Definition: WSModule.h:176
QString getID() const
Definition: WSModule.h:128
void setCategory(const QString &category)
Definition: WSModule.h:228
Definition: WSParameter.h:27
QMap< QString, WSPort * > inputPorts
Definition: WSModule.h:271
QString getName() const
Definition: WSModule.h:119
QString getDescription() const
Definition: WSModule.h:137
bool isDead() const
Definition: WSModule.h:200
GLint GLint GLint GLint GLint GLint y
Definition: khronos-glext.h:6346
QString getInstance() const
Definition: WSModule.h:193
Definition: WSModule.h:23
#define WSLIBEXPORT
Definition: coExport.h:373
GLenum GLuint id
Definition: khronos-glext.h:6279
const QMap< QString, WSParameter * > & getParameters() const
Definition: WSModule.h:91
void setDescription(const QString &description)
Definition: WSModule.h:238
void setID(const QString &id)
Definition: WSModule.h:218
GLenum type
Definition: khronos-glext.h:6279
GLint GLint GLint GLint GLint x
Definition: khronos-glext.h:6346
GLsizei GLenum GLenum * types
Definition: khronos-glext.h:8471
const QMap< QString, WSPort * > & getOutputPorts() const
Definition: WSModule.h:82
QMap< QString, WSPort * > outputPorts
Definition: WSModule.h:273