COVISE Core
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
coGRMsg.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 //-*-Mode: C++;-*-
9 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
10 // ++ (C)2006 VISENSO ++
11 // ++ coGRMsg - Covise GUI to Renderer Messages ++
12 // ++ Base class for all messages ++
13 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
14 
15 #ifndef COGRMSG_H
16 #define COGRMSG_H
17 
18 #include <string>
19 #include <vector>
20 #include <util/coExport.h>
21 using namespace std;
22 
23 #ifdef WIN32
24 #define strdup _strdup
25 #endif //WIN32
26 #ifndef COGRMSG_SAFEFREE
27 #define COGRMSG_SAFEFREE(x) \
28  if (x) \
29  { \
30  free(x); \
31  x = NULL; \
32  }
33 #endif //COGRMSG_SAFEFREE
34 
35 namespace grmsg
36 {
37 
39 {
40 public:
42  typedef enum
43  {
44  NO_TYPE = 0,
104  SET_VARIANT, // KLSM
105  SET_APPEARANCE, // KLSM
106  KINEMATICS_STATE // KLSM
107  } Mtype; //, PLANEINT, BBINT, COLOR, MATERIAL, SELECT, VIEWPOINT, CLIPLANE } Mtype;
108 
110  coGRMsg(const char *msg);
111 
113  virtual ~coGRMsg()
114  {
115  if (str_)
116  delete[] str_;
117  };
118 
120  int isValid()
121  {
122  return (is_valid_ == 1);
123  };
124 
126  virtual void print_stdout();
127 
130  {
131  return type_;
132  };
133  const char *c_str();
134  string getString()
135  {
136  return content_;
137  };
138 
139 protected:
141  coGRMsg(Mtype type);
142 
144  void addToken(const char *token);
145 
147  string getFirstToken();
148 
150  string extractFirstToken();
151 
153  vector<string> getAllTokens();
154 
157 
158 private:
160  const char SplitToken;
161 
163  const string MsgID;
164 
166  string content_;
168  char *str_;
169 };
170 }
171 #endif
Definition: coGRMsg.h:95
Definition: coGRMsg.h:70
Definition: coGRMsg.h:94
virtual ~coGRMsg()
destructor
Definition: coGRMsg.h:113
Definition: coGRMsg.h:99
const char SplitToken
split message string by this token
Definition: coGRMsg.h:160
Definition: coGRMsg.h:45
char * str_
char representation of content
Definition: coGRMsg.h:168
Definition: coGRMsg.h:101
Definition: coGRMsg.h:86
Definition: coGRMsg.h:76
Definition: coGRMsg.h:80
Mtype
id to specify the type of the message
Definition: coGRMsg.h:42
Definition: coGRMsg.h:100
Definition: coGRMsg.h:89
Definition: coGRMsg.h:72
#define GRMSGEXPORT
Definition: coExport.h:319
const string MsgID
string put to the header to identify the type Gui2RenderMessage
Definition: coGRMsg.h:163
Definition: coGRMsg.h:93
Definition: coGRMsg.h:104
Definition: coGRMsg.h:51
Definition: coGRMsg.h:63
Definition: coGRMsg.h:73
Definition: coGRMsg.h:69
Definition: coGRMsg.h:57
string content_
Definition: coGRMsg.h:166
Definition: coGRMsg.h:75
Mtype type_
Definition: coGRMsg.h:165
Definition: coGRMsg.h:82
Definition: coGRMsg.h:59
Definition: coGRMsg.h:60
Definition: coGRMsg.h:49
Definition: coGRMsg.h:64
Definition: coGRMsg.h:102
Definition: coGRMsg.h:61
Definition: coGRMsg.h:71
Definition: coGRMsg.h:103
GLenum type
Definition: khronos-glext.h:6279
Definition: coGRMsg.h:85
Definition: coGRMsg.h:47
int isValid()
whether recreate was succesful
Definition: coGRMsg.h:120
Definition: coGRMsg.h:68
Definition: coGRMsg.h:50
Definition: coGRMsg.h:79
Definition: coGRMsg.h:98
int is_valid_
valid can be overwritten by children if their recreation was not succesful
Definition: coGRMsg.h:156
Definition: coGRMsg.h:55
Definition: coGRMsg.h:77
Definition: coGRMsg.h:87
Definition: coGRMsg.h:62
Definition: coGRMsg.h:46
Definition: coGRMsg.h:91
Definition: coGRMsg.h:48
Definition: coGRMsg.h:78
Definition: coGRMsg.h:74
Definition: coGRMsg.h:58
Mtype getType()
access to private variables
Definition: coGRMsg.h:129
Definition: coGRMsg.h:105
Definition: coGRMsg.h:92
Definition: coGRMsg.h:83
string getString()
Definition: coGRMsg.h:134
Definition: coGRMsg.h:53
Definition: coGRMsg.h:81
Definition: coGRMsg.h:84
Definition: coGRMsg.h:38