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  DataType(const DataType& _i ) = default;
88 
89  bool operator!=( const unsigned int& _i ) const;
90  bool operator!=( const DataType& _i ) const;
91 
92  bool operator==( const unsigned int& _i ) const;
93  bool operator==( const DataType& _i ) const;
94 
95  DataType& operator=( const unsigned int& _i );
96 
97  DataType& operator=( const DataType& _i ) = default;
98 
99  bool operator<( const unsigned int& _i ) const;
100  bool operator<( const DataType& _i ) const;
101 
102  DataType& operator|=( const unsigned int& _i );
103  DataType& operator|=( const DataType& _i );
104 
105  bool operator&( const unsigned int& _i ) const;
106  bool operator&( const DataType& _i ) const;
107 
108  DataType operator!();
109 
110  bool contains( const DataType& _i ) const;
111 
112  DataType operator|( const DataType& _i ) const;
113 
114  DataType operator++(int _unused);
115 
116  DataType& operator++();
117 
122  unsigned int value() const;
123 
125  QString name() const;
126 
127  private:
128  unsigned int field;
129 };
130 
131 class TypeInfo {
132 
133  public:
134 
135  TypeInfo(DataType _type, QString _name, QString _iconName, QString _readableName ) :
136  type(_type),
137  name(_name),
138  iconName(_iconName),
139  readableName(_readableName)
140  {
141  // Use internal name if no external name is given
142  if ( _readableName == "" )
143  readableName = _name;
144  }
145 
148 
150  QString name;
151 
153  QString iconName;
154 
155  QIcon icon;
156 
158  QString readableName;
159 };
160 
162 const DataType DATA_ALL(UINT_MAX);
163 
165 const DataType DATA_UNKNOWN(0);
166 
168 const DataType DATA_GROUP(1);
169 
170 std::ostream &operator<<(std::ostream &stream, DataType type);
171 
172 
173 //== TYPEDEFS =================================================================
174 
177 
181 typedef std::vector< int > IdList;
184 
185 Q_DECLARE_METATYPE(IdList)
186 Q_DECLARE_METATYPE(DataType)
187 Q_DECLARE_METATYPE(QVector< int >)
188 Q_DECLARE_METATYPE(Vector)
189 Q_DECLARE_METATYPE(Vector4)
190 Q_DECLARE_METATYPE(Matrix4x4)
191 Q_DECLARE_METATYPE(UpdateType)
192 
193 
196 DLLEXPORT
197 void registerTypes();
198 
199 //================================================================================================
202 //================================================================================================
203 
209 DLLEXPORT
210 DataType addDataType(QString _name, QString _readableName);
211 
213 DLLEXPORT
214 DataType typeId(QString _name);
215 
221 DLLEXPORT
222 QString typeName(DataType _id);
223 
227 DLLEXPORT
228 bool typeExists( QString _name );
229 
237 DLLEXPORT
238 size_t typeCount();
239 
242 //================================================================================================
245 //================================================================================================
246 
248 DLLEXPORT
249 std::vector< TypeInfo >::const_iterator typesBegin();
250 
252 DLLEXPORT
253 std::vector< TypeInfo >::const_iterator typesEnd();
254 
257 //================================================================================================
260 //================================================================================================
261 
263 DLLEXPORT
264 QString dataTypeName( DataType _id );
265 
267 DLLEXPORT
268 QString dataTypeName( QString _typeName);
269 
271 DLLEXPORT
272 void setDataTypeName( DataType _id, QString _name );
273 
275 DLLEXPORT
276 void setDataTypeName( QString _typeName, QString _name );
277 
278 
281 //================================================================================================
284 //================================================================================================
285 
287 DLLEXPORT
288 QString typeIconName(QString _name);
289 
291 DLLEXPORT
292 QString typeIconName(DataType _id);
293 
299 DLLEXPORT
300 QIcon& typeIcon(DataType _id);
301 
303 DLLEXPORT
304 void setTypeIcon( DataType _id , QString _icon);
305 
307 DLLEXPORT
308 void setTypeIcon( QString _name , QString _icon );
309 
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:179
#define DLLEXPORT
QString readableName
Human readable name.
Definition: DataTypes.hh:158
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:147
QString name
The name of the datatype.
Definition: DataTypes.hh:150
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:181
ACG::Vec3d Vector
Standard Type for 3d Vector used for scripting.
Definition: DataTypes.hh:176
DLLEXPORT void registerTypes()
Definition: Types.cc:417
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:153
Update type class.
Definition: UpdateType.hh:59
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:183
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