arcsinternaltypes.h
1 /*
2  name: include/arcs/arcsinternaltypes.h
3 
4  This file is part of ARCS - Augmented Reality Component System
5  (version 2-current), written by Jean-Yves Didier
6  for IBISC Laboratory (http://www.ibisc.univ-evry.fr)
7 
8  Copyright (C) 2013 Université d'Evry-Val d'Essonne
9 
10  This program is free software: you can redistribute it and/or modify
11  it under the terms of the GNU General Public License as published by
12  the Free Software Foundation, either version 2 of the License, or
13  (at your option) any later version.
14 
15  This program 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 General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with this program. If not, see <http://www.gnu.org/licenses/>.
22 
23 
24  Please send bugreports with examples or suggestions to
25  jean-yves.didier__at__ibisc.univ-evry.fr
26 */
27 
28 
29 #ifndef __ARCSINTERNALTYPES_H__
30 #define __ARCSINTERNALTYPES_H__
31 
32 #include <arcs/arcsarray.h>
33 #include <QMetaType>
34 #include <QSize>
35 
36 /*class ARCSTypeFactory_void : public ARCSTypeFactoryTemplate<void>
37 {
38 public:
39  virtual QString getTypeName() const { return "void"; }
40  virtual bool isInternal() const { return true; }
41 
42 protected:
43  virtual void parse(QString s) { return ; }
44  virtual QString serielize(void) { return QString::null; }
45  }*/
46 
48 {
49 public:
50  virtual QString getTypeName() const { return "void"; }
51  virtual bool isInternal() const { return true; }
52  virtual QString toString(QVariant) { return ""; }
53  virtual QVariant parseString(QString) { return QVariant(); }
54 };
55 
56 
58 {
59 public :
60  virtual QString getTypeName() const { return "bool"; }
61  virtual bool isInternal() const { return true; }
62 protected :
63  virtual bool parse(QString s) {
64  if (s.toLower() == "true" || s == "1" || s.toLower() =="t" ) return true;
65  return false; }
66 
67  virtual QString serialize(bool obj) { return (obj)?"true":"false"; }
68 };
69 
70 
72 {
73 public:
74  virtual QString getTypeName() const { return "int"; }
75  virtual bool isInternal() const { return true; }
76 
77 protected:
78  virtual int parse(QString s) { return s.toInt(); }
79  virtual QString serialize(int obj) { return QString::number(obj);}
80 
81 };
82 
84 {
85 public:
86  virtual QString getTypeName() const { return "short"; }
87  virtual bool isInternal() const { return true; }
88 protected:
89  virtual short parse(QString s) { return s.toShort(); }
90  virtual QString serialize(short obj) { return QString::number(obj); }
91 };
92 
94 {
95 public:
96  virtual QString getTypeName() const { return "long"; }
97  virtual bool isInternal() const { return true; }
98 protected:
99  virtual long parse(QString s) { return s.toLong(); }
100  virtual QString serialize(long obj) { return QString::number(obj); }
101 };
102 
104 {
105 public:
106  virtual QString getTypeName() const { return "float"; }
107  virtual bool isInternal() const { return true; }
108 protected:
109  virtual float parse(QString s) { return s.toFloat(); }
110  virtual QString serialize(float obj) { return QString::number(obj); }
111 };
112 
114 {
115 public:
116  virtual QString getTypeName() const { return "double"; }
117  virtual bool isInternal() const { return true; }
118 protected:
119  virtual double parse(QString s) { return s.toDouble(); }
120  virtual QString serialize(double obj) { return QString::number(obj); }
121 };
122 
124 {
125 public:
126  virtual QString getTypeName() const { return "string"; }
127  virtual bool isInternal() const { return true; }
128 
129 protected:
130  virtual QString parse(QString s) { return s; }
131  virtual QString serialize(QString obj) { return obj; }
132 };
133 
134 class ARCSConstant : public QString
135 {
136 public:
137 ARCSConstant(QString s) : QString(s) { }
138 ARCSConstant() : QString() {}
139 };
140 
141 Q_DECLARE_METATYPE(ARCSConstant)
142 
144 {
145 public:
146  virtual QString getTypeName() const { return "constant"; }
147  virtual bool isInternal() const { return true; }
148 
149 protected:
150  virtual ARCSConstant parse(QString s) { return ARCSConstant(s); }
151  virtual QString serialize(ARCSConstant obj) { return obj; }
152 };
153 
154 class ARCSComponent : public QString
155 {
156 public:
157 ARCSComponent(QString s) : QString(s) { }
158 ARCSComponent() : QString () {}
159 };
160 
161 Q_DECLARE_METATYPE(ARCSComponent)
162 
164 {
165  public:
166  virtual QString getTypeName() const { return "component"; }
167  virtual bool isInternal() const { return true; }
168 
169  protected:
170  virtual ARCSComponent parse(QString s) { return ARCSComponent(s); }
171  virtual QString serialize(ARCSComponent obj) { return obj; }
172 };
173 
174 
176 {
177  public:
178  virtual QString getTypeName() const { return "size"; }
179  virtual bool isInternal() const { return true; }
180 
181  protected:
182  virtual QSize parse(QString s) ;
183  virtual QString serialize(QSize s);
184 };
185 
186 /**************************************************************************
187  * Arrays
188  *************************************************************************/
189 template class ARCSArrayTemplate<bool>;
191 Q_DECLARE_METATYPE(boolArray)
193 {
194 public:
195  virtual bool isInternal() const { return true; }
196 protected:
197  QString baseType() const { return "bool"; }
198 };
199 
200 
201 template class ARCSArrayTemplate<int>;
203 Q_DECLARE_METATYPE(intArray)
205 {
206 public:
207  virtual bool isInternal() const { return true; }
208 protected:
209  QString baseType() const { return "int"; }
210 };
211 
212 template class ARCSArrayTemplate<short>;
214 Q_DECLARE_METATYPE(shortArray)
216 {
217  public:
218  virtual bool isInternal() const { return true; }
219  protected:
220  QString baseType() const { return "short"; }
221 };
222 
223 template class ARCSArrayTemplate<long>;
225 Q_DECLARE_METATYPE(longArray)
227 {
228  public:
229  virtual bool isInternal() const { return true; }
230  protected:
231  QString baseType() const { return "long"; }
232 };
233 
234 template class ARCSArrayTemplate<double>;
236 Q_DECLARE_METATYPE(doubleArray)
238 {
239  public:
240  virtual bool isInternal() const { return true; }
241  protected:
242  QString baseType() const { return "double"; }
243 };
244 
245 template class ARCSArrayTemplate<QString>;
247 Q_DECLARE_METATYPE(stringArray)
249 {
250  public:
251  virtual bool isInternal() const { return true; }
252  protected:
253  QString baseType() const { return "string"; }
254 };
255 
256 
257 
258 template class ARCSArrayTemplate<float>;
260 Q_DECLARE_METATYPE(floatArray)
262 {
263  public:
264  virtual bool isInternal() const { return true; }
265  protected:
266  QString baseType() const { return "float"; }
267 };
268 
269 
270 
271 #endif //__ARCSINTERNALTYPES_H__
virtual QString toString(QVariant)
Should return a string representation of data.
virtual bool isInternal() const
Tells wether the factory is internal or not (false by default).
virtual QString serialize(ARCSComponent obj)
This function serializes an X object to a string.
virtual QString serialize(double obj)
This function serializes an X object to a string.
virtual QString serialize(int obj)
This function serializes an X object to a string.
virtual bool isInternal() const
Tells wether the factory is internal or not (false by default).
virtual bool isInternal() const
Tells wether the factory is internal or not (false by default).
virtual ARCSComponent parse(QString s)
This function should return a X object according to its string representation.
virtual QString getTypeName() const
Should return the name of the type factory.
virtual QString getTypeName() const
Should return the name of the type factory.
virtual double parse(QString s)
This function should return a X object according to its string representation.
virtual short parse(QString s)
This function should return a X object according to its string representation.
virtual bool isInternal() const
Tells wether the factory is internal or not (false by default).
virtual int parse(QString s)
This function should return a X object according to its string representation.
Template class to implement type factories.
virtual bool isInternal() const
Tells wether the factory is internal or not (false by default).
virtual bool parse(QString s)
This function should return a X object according to its string representation.
virtual long parse(QString s)
This function should return a X object according to its string representation.
virtual bool isInternal() const
Tells wether the factory is internal or not (false by default).
virtual QString getTypeName() const
Should return the name of the type factory.
virtual bool isInternal() const
Tells wether the factory is internal or not (false by default).
virtual bool isInternal() const
Tells wether the factory is internal or not (false by default).
virtual bool isInternal() const
Tells wether the factory is internal or not (false by default).
Template class to implement array serialization.
Definition: arcsarray.h:134
virtual bool isInternal() const
Tells wether the factory is internal or not (false by default).
virtual bool isInternal() const
Tells wether the factory is internal or not (false by default).
virtual bool isInternal() const
Tells wether the factory is internal or not (false by default).
virtual QVariant parseString(QString)
Should create data from their string representation.
virtual QString getTypeName() const
Should return the name of the type factory.
virtual QString serialize(short obj)
This function serializes an X object to a string.
Template class to implement arrays.
Definition: arcsarray.h:50
virtual QString getTypeName() const
Should return the name of the type factory.
virtual QString serialize(ARCSConstant obj)
This function serializes an X object to a string.
virtual QString getTypeName() const
Should return the name of the type factory.
virtual float parse(QString s)
This function should return a X object according to its string representation.
virtual bool isInternal() const
Tells wether the factory is internal or not (false by default).
Generic class describing how type factories should be implemented.
virtual bool isInternal() const
Tells wether the factory is internal or not (false by default).
virtual QString serialize(QSize s)
This function serializes an X object to a string.
virtual QString getTypeName() const
Should return the name of the type factory.
virtual QString getTypeName() const
Should return the name of the type factory.
virtual QString serialize(long obj)
This function serializes an X object to a string.
virtual QSize parse(QString s)
This function should return a X object according to its string representation.
virtual bool isInternal() const
Tells wether the factory is internal or not (false by default).
virtual QString serialize(QString obj)
This function serializes an X object to a string.
virtual bool isInternal() const
Tells wether the factory is internal or not (false by default).
virtual ARCSConstant parse(QString s)
This function should return a X object according to its string representation.
virtual QString getTypeName() const
Should return the name of the type factory.
virtual QString getTypeName() const
Should return the name of the type factory.
virtual bool isInternal() const
Tells wether the factory is internal or not (false by default).
virtual QString serialize(bool obj)
This function serializes an X object to a string.
virtual QString parse(QString s)
This function should return a X object according to its string representation.
This file defines basic templates in order to make arrays of new types available to the ARCS engine...
virtual QString getTypeName() const
Should return the name of the type factory.
virtual QString serialize(float obj)
This function serializes an X object to a string.
virtual bool isInternal() const
Tells wether the factory is internal or not (false by default).