COVISE Core
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
WSParameter.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 WSPARAMETER_H
9 #define WSPARAMETER_H
10 
11 #include <QString>
12 #include <QStringList>
13 #include <QVector>
14 #include <QMap>
15 #include <QVariant>
16 
17 #include <map>
18 
19 #include "WSExport.h"
20 #include "WSCoviseStub.h"
21 
22 #include <QObject>
23 
24 namespace covise
25 {
26 
27 class WSLIBEXPORT WSParameter : public QObject
28 {
29 
30  Q_OBJECT
31 
32  Q_PROPERTY(QString name READ getName)
33  Q_PROPERTY(QString type READ getType)
34  Q_PROPERTY(QString description READ getDescription)
35  Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled)
36  Q_PROPERTY(bool mapped READ isMapped WRITE setMapped)
37 
38 public:
39  WSParameter(const QString &name, const QString &description, const QString &type);
40  virtual ~WSParameter();
41 
42 signals:
43  void parameterChanged(covise::WSParameter *parameter);
44 
45 public slots:
50  const QString &getName() const
51  {
52  return this->name;
53  }
54 
59  const QString &getType() const
60  {
61  return this->type;
62  }
63 
68  const QString &getDescription() const
69  {
70  return this->description;
71  }
72 
77  void setEnabled(bool state)
78  {
79  this->enabled = state;
80  }
81 
86  bool isEnabled() const
87  {
88  return this->enabled;
89  }
90 
94  void setMapped(bool mapped)
95  {
96  this->mapped = mapped;
97  }
98 
103  bool isMapped() const
104  {
105  return this->mapped;
106  }
107 
113  virtual int getComponentCount() const;
114 
119  virtual QString toString() const = 0;
120 
121  virtual WSParameter *clone() const = 0;
122 
123  virtual const covise::covise__Parameter *getSerialisable() = 0;
124 
129  virtual bool setValueFromSerialisable(const covise::covise__Parameter *serialisable) = 0;
130 
131  virtual QString toCoviseString() const
132  {
133  QString value = toString();
134  if (value == "")
135  return QChar('\177');
136  else
137  return value;
138  }
139 
140  static WSParameter *create(covise::covise__Parameter *parameter);
141 
142 protected:
143  const covise::covise__Parameter *getSerialisable(covise::covise__Parameter *parameter) const;
144 
145  static WSParameter *addPrototype(QString className, WSParameter *prototype)
146  {
147  static std::map<QString, WSParameter *> *p = new std::map<QString, WSParameter *>();
148  //std::cerr << "WSParameter::addPrototype info: adding " << qPrintable(className) << std::endl;
149  (*p)[className] = prototype;
150  prototypes = p;
151  return prototype;
152  }
153 
154  bool equals(const covise::covise__Parameter *, const covise::covise__Parameter *);
155 
156 protected:
157  WSParameter(const WSParameter &);
158 
159 private:
160  // Name of the parameter
161  QString name;
162  // Type of the parameter
163  QString type;
164  // Description of the parameter
165  QString description;
166 
167  bool enabled;
168  bool mapped;
169 
170  static std::map<QString, WSParameter *> *prototypes;
171 
176  void setName(const QString &inName)
177  {
178  this->name = inName;
179  }
180 
185  void setType(const QString &inType)
186  {
187  this->type = inType;
188  }
189 
194  void setDescription(const QString &inDescription)
195  {
196  this->description = inDescription;
197  }
198 };
199 }
200 
201 #endif // WSPARAMETER_H
GLuint const GLchar * name
Definition: khronos-glext.h:6722
#define WSLIBEXPORT
Definition: coExport.h:355
static std::map< QString, WSParameter * > * prototypes
Definition: WSParameter.h:170
bool isEnabled() const
Definition: WSParameter.h:86
static WSParameter * addPrototype(QString className, WSParameter *prototype)
Definition: WSParameter.h:145
const QString & getType() const
Definition: WSParameter.h:59
void setType(const QString &inType)
Definition: WSParameter.h:185
bool isMapped() const
Definition: WSParameter.h:103
void setDescription(const QString &inDescription)
Definition: WSParameter.h:194
virtual QString toCoviseString() const
Definition: WSParameter.h:131
void setEnabled(bool state)
Definition: WSParameter.h:77
void setName(const QString &inName)
Definition: WSParameter.h:176
GLfloat GLfloat p
Definition: khronos-glext.h:9861
GLenum type
Definition: khronos-glext.h:6279
void setMapped(bool mapped)
Definition: WSParameter.h:94
const QString & getDescription() const
Definition: WSParameter.h:68
Definition: WSParameter.h:27
GLenum GLenum GLsizei const GLuint GLboolean enabled
Definition: khronos-glext.h:8468
GLsizei const GLfloat * value
Definition: khronos-glext.h:6760