Developer Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
DataTypes.hh
Go to the documentation of this file.
1 /*===========================================================================*\
2 * *
3 * OpenFlipper *
4  * Copyright (c) 2001-2015, RWTH-Aachen University *
5  * Department of Computer Graphics and Multimedia *
6  * All rights reserved. *
7  * www.openflipper.org *
8  * *
9  *---------------------------------------------------------------------------*
10  * This file is part of OpenFlipper. *
11  *---------------------------------------------------------------------------*
12  * *
13  * Redistribution and use in source and binary forms, with or without *
14  * modification, are permitted provided that the following conditions *
15  * are met: *
16  * *
17  * 1. Redistributions of source code must retain the above copyright notice, *
18  * this list of conditions and the following disclaimer. *
19  * *
20  * 2. Redistributions in binary form must reproduce the above copyright *
21  * notice, this list of conditions and the following disclaimer in the *
22  * documentation and/or other materials provided with the distribution. *
23  * *
24  * 3. Neither the name of the copyright holder nor the names of its *
25  * contributors may be used to endorse or promote products derived from *
26  * this software without specific prior written permission. *
27  * *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39 * *
40 \*===========================================================================*/
41 
42 /*===========================================================================*\
43 * *
44 * $Revision$ *
45 * $LastChangedBy$ *
46 * $Date$ *
47 * *
48 \*===========================================================================*/
49 
50 
51 
52 
53 //=============================================================================
54 //
55 // Types
56 //
57 //=============================================================================
58 
65 #ifndef DATATYPES_HH
66 #define DATATYPES_HH
67 
68 //== includes =================================================================
69 
70 
72 #include <OpenFlipper/common/UpdateType.hh>
73 
74 #include <ACG/Math/Matrix4x4T.hh>
75 #include <ACG/Math/VectorT.hh>
76 #include <climits>
77 #include <QIcon>
78 #include <QMetaType>
79 
80 //== Global Typedefs =================================================================
81 
97  public:
98  DataType();
99  DataType(const unsigned int& _i);
100 
101  bool operator!=( const unsigned int& _i ) const;
102  bool operator!=( const DataType& _i ) const;
103 
104  bool operator==( const unsigned int& _i ) const;
105  bool operator==( const DataType& _i ) const;
106 
107  DataType& operator=( const unsigned int& _i );
108  DataType& operator=( const DataType& _i );
109 
110  bool operator<( const unsigned int& _i ) const;
111  bool operator<( const DataType& _i ) const;
112 
113  DataType& operator|=( const unsigned int& _i );
114  DataType& operator|=( const DataType& _i );
115 
116  bool operator&( const unsigned int& _i ) const;
117  bool operator&( const DataType& _i ) const;
118 
119  DataType operator!();
120 
121  bool contains( const DataType& _i ) const;
122 
123  DataType operator|( const DataType& _i ) const;
124 
125  DataType operator++(int _unused);
126 
127  DataType& operator++();
128 
133  unsigned int value() const;
134 
136  QString name() const;
137 
138  private:
139  unsigned int field;
140 };
141 
142 class TypeInfo {
143 
144  public:
145 
146  TypeInfo(DataType _type, QString _name, QString _iconName, QString _readableName ) :
147  type(_type),
148  name(_name),
149  iconName(_iconName),
150  readableName(_readableName)
151  {
152  // Use internal name if no external name is given
153  if ( _readableName == "" )
154  readableName = _name;
155  }
156 
159 
161  QString name;
162 
164  QString iconName;
165 
166  QIcon icon;
167 
169  QString readableName;
170 };
171 
173 const DataType DATA_ALL(UINT_MAX);
174 
176 const DataType DATA_UNKNOWN(0);
177 
179 const DataType DATA_GROUP(1);
180 
181 std::ostream &operator<<(std::ostream &stream, DataType type);
182 
183 
184 //== TYPEDEFS =================================================================
185 
188 
192 typedef std::vector< int > IdList;
195 
196 Q_DECLARE_METATYPE(IdList)
197 Q_DECLARE_METATYPE(DataType)
198 Q_DECLARE_METATYPE(QVector< int >)
199 Q_DECLARE_METATYPE(Vector)
200 Q_DECLARE_METATYPE(Vector4)
201 Q_DECLARE_METATYPE(Matrix4x4)
202 Q_DECLARE_METATYPE(UpdateType)
203 
207 DLLEXPORT
208 void registerTypes();
209 
210 //================================================================================================
213 //================================================================================================
214 
220 DLLEXPORT
221 DataType addDataType(QString _name, QString _readableName);
222 
224 DLLEXPORT
225 DataType typeId(QString _name);
226 
232 DLLEXPORT
233 QString typeName(DataType _id);
234 
238 DLLEXPORT
239 bool typeExists( QString _name );
240 
248 DLLEXPORT
249 size_t typeCount();
250 
253 //================================================================================================
256 //================================================================================================
257 
259 DLLEXPORT
260 std::vector< TypeInfo >::const_iterator typesBegin();
261 
263 DLLEXPORT
264 std::vector< TypeInfo >::const_iterator typesEnd();
265 
268 //================================================================================================
271 //================================================================================================
272 
274 DLLEXPORT
275 QString dataTypeName( DataType _id );
276 
278 DLLEXPORT
279 QString dataTypeName( QString _typeName);
280 
282 DLLEXPORT
283 void setDataTypeName( DataType _id, QString _name );
284 
286 DLLEXPORT
287 void setDataTypeName( QString _typeName, QString _name );
288 
289 
292 //================================================================================================
295 //================================================================================================
296 
298 DLLEXPORT
299 QString typeIconName(QString _name);
300 
302 DLLEXPORT
303 QString typeIconName(DataType _id);
304 
310 DLLEXPORT
311 QIcon& typeIcon(DataType _id);
312 
314 DLLEXPORT
315 void setTypeIcon( DataType _id , QString _icon);
316 
318 DLLEXPORT
319 void setTypeIcon( QString _name , QString _icon );
320 
327 //=============================================================================
328 #endif // DATATYPES_HH defined
329 //=============================================================================
DLLEXPORT DataType typeId(QString _name)
Given a dataType Identifier string this function will return the id of the datatype.
Definition: Types.cc:150
DLLEXPORT QIcon & typeIcon(DataType _id)
Get an QIcon associated with the given DataType.
Definition: Types.cc:223
DLLEXPORT void setTypeIcon(DataType _id, QString _icon)
Set an Icon for a given DataType.
Definition: Types.cc:234
DLLEXPORT QString dataTypeName(DataType _id)
Get DataType Human readable name ( this name might change. Use the typeName instead! ) ...
Definition: Types.cc:263
DataType type
The id of the datatype.
Definition: DataTypes.hh:158
const DataType DATA_UNKNOWN(0)
None of the other Objects.
Update type class.
Definition: UpdateType.hh:70
const DataType DATA_GROUP(1)
Items used for Grouping.
ACG::Matrix4x4d Matrix4x4
Standard Type for a 4x4 Matrix used for scripting.
Definition: DataTypes.hh:194
DLLEXPORT size_t typeCount()
Get the number of registered types.
Definition: Types.cc:186
DLLEXPORT DataType addDataType(QString _name, QString _readableName)
Adds a datatype and returns the id for the new type.
Definition: Types.cc:128
DLLEXPORT bool typeExists(QString _name)
Check if a type with the given name exists.
Definition: Types.cc:180
QString iconName
The icon of the datatype.
Definition: DataTypes.hh:164
DLLEXPORT QString typeName(DataType _id)
Get the name of a type with given id.
Definition: Types.cc:165
ACG::Vec3d Vector
Standard Type for 3d Vector used for scripting.
Definition: DataTypes.hh:187
DLLEXPORT QString typeIconName(QString _name)
Get a string with the filename of the icon for the DataType name.
Definition: Types.cc:201
std::vector< int > IdList
Standard Type for id Lists used for scripting.
Definition: DataTypes.hh:192
ACG::Vec4d Vector4
Standard Type for 4d Vector used for scripting.
Definition: DataTypes.hh:190
std::ostream & operator<<(std::ostream &_o, const Timer &_t)
Definition: Timer.hh:201
DLLEXPORT void setDataTypeName(DataType _id, QString _name)
Set DataType Human readable name.
Definition: Types.cc:291
QString readableName
Human readable name.
Definition: DataTypes.hh:169
const DataType DATA_ALL(UINT_MAX)
Identifier for all available objects.
QString name
The name of the datatype.
Definition: DataTypes.hh:161
DLLEXPORT std::vector< TypeInfo >::const_iterator typesBegin()
Get iterator pointing to the first element in the types list.
Definition: Types.cc:191
#define DLLEXPORT
DLLEXPORT void registerTypes()
Definition: Types.cc:433
STL namespace.
Predefined datatypes.
Definition: DataTypes.hh:96
DLLEXPORT std::vector< TypeInfo >::const_iterator typesEnd()
Get iterator pointing to the last element in the types list.
Definition: Types.cc:196