Developer Documentation
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 // Types
45 //
46 //=============================================================================
47 
53 #pragma once
54 
55 //== includes =================================================================
56 
57 
59 #include <OpenFlipper/common/UpdateType.hh>
60 
61 #include <ACG/Math/Matrix4x4T.hh>
62 #include <ACG/Math/VectorT.hh>
63 #include <climits>
64 #include <QIcon>
65 #include <QMetaType>
66 
67 //== Global Typedefs =================================================================
68 
84  public:
85  DataType();
86  DataType(const unsigned int& _i);
87 
88  bool operator!=( const unsigned int& _i ) const;
89  bool operator!=( const DataType& _i ) const;
90 
91  bool operator==( const unsigned int& _i ) const;
92  bool operator==( const DataType& _i ) const;
93 
94  DataType& operator=( const unsigned int& _i );
95  DataType& operator=( const DataType& _i );
96 
97  bool operator<( const unsigned int& _i ) const;
98  bool operator<( const DataType& _i ) const;
99 
100  DataType& operator|=( const unsigned int& _i );
101  DataType& operator|=( const DataType& _i );
102 
103  bool operator&( const unsigned int& _i ) const;
104  bool operator&( const DataType& _i ) const;
105 
106  DataType operator!();
107 
108  bool contains( const DataType& _i ) const;
109 
110  DataType operator|( const DataType& _i ) const;
111 
112  DataType operator++(int _unused);
113 
114  DataType& operator++();
115 
120  unsigned int value() const;
121 
123  QString name() const;
124 
125  private:
126  unsigned int field;
127 };
128 
129 class TypeInfo {
130 
131  public:
132 
133  TypeInfo(DataType _type, QString _name, QString _iconName, QString _readableName ) :
134  type(_type),
135  name(_name),
136  iconName(_iconName),
137  readableName(_readableName)
138  {
139  // Use internal name if no external name is given
140  if ( _readableName == "" )
141  readableName = _name;
142  }
143 
146 
148  QString name;
149 
151  QString iconName;
152 
153  QIcon icon;
154 
156  QString readableName;
157 };
158 
160 const DataType DATA_ALL(UINT_MAX);
161 
163 const DataType DATA_UNKNOWN(0);
164 
166 const DataType DATA_GROUP(1);
167 
168 std::ostream &operator<<(std::ostream &stream, DataType type);
169 
170 
171 //== TYPEDEFS =================================================================
172 
175 
179 typedef std::vector< int > IdList;
182 
183 Q_DECLARE_METATYPE(IdList)
184 Q_DECLARE_METATYPE(DataType)
185 Q_DECLARE_METATYPE(QVector< int >)
186 Q_DECLARE_METATYPE(Vector)
187 Q_DECLARE_METATYPE(Vector4)
188 Q_DECLARE_METATYPE(Matrix4x4)
189 Q_DECLARE_METATYPE(UpdateType)
190 
191 
194 DLLEXPORT
195 void registerTypes();
196 
197 //================================================================================================
200 //================================================================================================
201 
207 DLLEXPORT
208 DataType addDataType(QString _name, QString _readableName);
209 
211 DLLEXPORT
212 DataType typeId(QString _name);
213 
219 DLLEXPORT
220 QString typeName(DataType _id);
221 
225 DLLEXPORT
226 bool typeExists( QString _name );
227 
235 DLLEXPORT
236 size_t typeCount();
237 
240 //================================================================================================
243 //================================================================================================
244 
246 DLLEXPORT
247 std::vector< TypeInfo >::const_iterator typesBegin();
248 
250 DLLEXPORT
251 std::vector< TypeInfo >::const_iterator typesEnd();
252 
255 //================================================================================================
258 //================================================================================================
259 
261 DLLEXPORT
262 QString dataTypeName( DataType _id );
263 
265 DLLEXPORT
266 QString dataTypeName( QString _typeName);
267 
269 DLLEXPORT
270 void setDataTypeName( DataType _id, QString _name );
271 
273 DLLEXPORT
274 void setDataTypeName( QString _typeName, QString _name );
275 
276 
279 //================================================================================================
282 //================================================================================================
283 
285 DLLEXPORT
286 QString typeIconName(QString _name);
287 
289 DLLEXPORT
290 QString typeIconName(DataType _id);
291 
297 DLLEXPORT
298 QIcon& typeIcon(DataType _id);
299 
301 DLLEXPORT
302 void setTypeIcon( DataType _id , QString _icon);
303 
305 DLLEXPORT
306 void setTypeIcon( QString _name , QString _icon );
307 
DLLEXPORT std::vector< TypeInfo >::const_iterator typesEnd()
Get iterator pointing to the last element in the types list.
Definition: Types.cc:185
DLLEXPORT QString dataTypeName(DataType _id)
Get DataType Human readable name ( this name might change. Use the typeName instead! ) ...
Definition: Types.cc:252
DLLEXPORT void setDataTypeName(DataType _id, QString _name)
Set DataType Human readable name.
Definition: Types.cc:280
ACG::Vec4d Vector4
Standard Type for 4d Vector used for scripting.
Definition: DataTypes.hh:177
#define DLLEXPORT
QString readableName
Human readable name.
Definition: DataTypes.hh:156
DLLEXPORT bool typeExists(QString _name)
Check if a type with the given name exists.
Definition: Types.cc:169
DataType type
The id of the datatype.
Definition: DataTypes.hh:145
QString name
The name of the datatype.
Definition: DataTypes.hh:148
const DataType DATA_GROUP(1)
Items used for Grouping.
Predefined datatypes.
Definition: DataTypes.hh:83
DLLEXPORT size_t typeCount()
Get the number of registered types.
Definition: Types.cc:175
DLLEXPORT DataType addDataType(QString _name, QString _readableName)
Adds a datatype and returns the id for the new type.
Definition: Types.cc:117
std::vector< int > IdList
Standard Type for id Lists used for scripting.
Definition: DataTypes.hh:179
ACG::Vec3d Vector
Standard Type for 3d Vector used for scripting.
Definition: DataTypes.hh:174
DLLEXPORT void registerTypes()
Definition: Types.cc:422
DLLEXPORT void setTypeIcon(DataType _id, QString _icon)
Set an Icon for a given DataType.
Definition: Types.cc:223
QString iconName
The icon of the datatype.
Definition: DataTypes.hh:151
Update type class.
Definition: UpdateType.hh:60
DLLEXPORT QString typeName(DataType _id)
Get the name of a type with given id.
Definition: Types.cc:154
DLLEXPORT QString typeIconName(QString _name)
Get a string with the filename of the icon for the DataType name.
Definition: Types.cc:190
ACG::Matrix4x4d Matrix4x4
Standard Type for a 4x4 Matrix used for scripting.
Definition: DataTypes.hh:181
DLLEXPORT std::vector< TypeInfo >::const_iterator typesBegin()
Get iterator pointing to the first element in the types list.
Definition: Types.cc:180
const DataType DATA_UNKNOWN(0)
None of the other Objects.
const DataType DATA_ALL(UINT_MAX)
Identifier for all available objects.
DLLEXPORT QIcon & typeIcon(DataType _id)
Get an QIcon associated with the given DataType.
Definition: Types.cc:212
DLLEXPORT DataType typeId(QString _name)
Given a dataType Identifier string this function will return the id of the datatype.
Definition: Types.cc:139