72 #include <QCoreApplication>
78 static int nextTypeId_ = 2;
82 static std::map< DataType, QString > typeToString;
86 static std::map< QString , size_t > stringToTypeInfo;
90 static std::map< DataType , size_t > typeToTypeInfo;
92 static QIcon dummyIcon;
94 static std::vector< TypeInfo > types;
100 stream << type.
value() ;
105 void initializeTypes() {
106 stringToTypeInfo[
"Unknown"] = types.size();
108 typeToTypeInfo[
test] = types.size();
109 types.push_back(
TypeInfo(
DATA_UNKNOWN ,
"Unknown" ,
"Unknown.png", QCoreApplication::translate(
"Types",
"Unknown")) );
111 stringToTypeInfo[
"Group"] = types.size();
113 types.push_back(
TypeInfo(
DATA_GROUP ,
"Group" ,
"group.png", QCoreApplication::translate(
"Types",
"Group")) );
115 stringToTypeInfo[
"All"] = types.size();
116 typeToTypeInfo[
DATA_ALL] = types.size();
117 types.push_back(
TypeInfo(
DATA_ALL ,
"All" ,
"Unknown.png", QCoreApplication::translate(
"Types",
"All")) );
133 std::cerr <<
"Redefinition of existing data type!" << std::endl;
137 int type = nextTypeId_;
139 stringToTypeInfo[ _name ] = types.size();
140 typeToTypeInfo[ type ] = types.size();
141 types.push_back(
TypeInfo(type, _name,
"Unknown.png", _readableName ));
143 typeToString[type] = _name;
152 std::map<QString, size_t>::iterator index = stringToTypeInfo.find( _name );
154 if ( index != stringToTypeInfo.end() )
155 return types[ index->second ].type;
158 std::cerr <<
"Unknown Data type with name " << _name.toStdString() << std::endl;
167 std::map<DataType, QString>::iterator name = typeToString.find(_id);
169 if ( name != typeToString.end() )
173 std::cerr <<
"Unable to retrieve typeName for id " << _id << std::endl;
181 return ( stringToTypeInfo.find( _name ) != stringToTypeInfo.end() );
192 return types.begin();
196 std::vector< TypeInfo >::const_iterator
typesEnd() {
203 std::map<QString, size_t>::iterator index = stringToTypeInfo.find( _name );
205 if ( index != stringToTypeInfo.end() )
206 return types[ index->second ].iconName;
208 return "Unknown.png";
214 std::map<DataType, size_t>::iterator index = typeToTypeInfo.find(_id);
216 if ( index != typeToTypeInfo.end() )
217 return types[ index->second ].iconName;
219 return "Unknown.png";
225 std::map<DataType, size_t>::iterator index = typeToTypeInfo.find(_id);
227 if ( index != typeToTypeInfo.end() )
228 return types[ index->second ].icon;
236 if ( OpenFlipper::Options::gui() ) {
237 std::map<DataType, size_t>::iterator index = typeToTypeInfo.find(_id);
239 if ( index != typeToTypeInfo.end() ) {
240 types[ index->second ].iconName = _icon;
241 types[ index->second ].icon = QIcon( OpenFlipper::Options::iconDirStr() + QDir::separator() + _icon );
243 std::cerr <<
"Could not set icon for DataType. Type not found!" << std::endl;
250 if ( OpenFlipper::Options::gui() ) {
251 std::map<QString, size_t>::iterator index = stringToTypeInfo.find( _name );
253 if ( index != stringToTypeInfo.end() ) {
254 types[ index->second ].iconName = _icon;
255 types[ index->second ].icon = QIcon( OpenFlipper::Options::iconDirStr() + QDir::separator() + _icon );
257 std::cerr <<
"Could not set icon for DataType. Type not found!" << std::endl;
265 std::map<DataType, size_t>::iterator index = typeToTypeInfo.find(_id);
267 if ( index != typeToTypeInfo.end() )
268 return types[ index->second ].readableName ;
270 std::cerr <<
"Could not get human name for DataType. Type not found!" << std::endl;
272 return QString(QCoreApplication::translate(
"Types",
"Unknown Type"));
278 std::map<QString, size_t>::iterator index = stringToTypeInfo.find( _typeName );
280 if ( index != stringToTypeInfo.end() )
281 return types[ index->second ].readableName ;
283 std::cerr <<
"Could not get human name for DataType. Type not found!" << std::endl;
285 return QString(QCoreApplication::translate(
"Types",
"Unknown Type"));
293 std::map<DataType, size_t>::iterator index = typeToTypeInfo.find(_id);
295 if ( index != typeToTypeInfo.end() )
296 types[ index->second ].readableName = _name;
298 std::cerr <<
"Could not set human name for DataType. Type not found!" << std::endl;
304 std::map<QString, size_t>::iterator index = stringToTypeInfo.find( _typeName );
306 if ( index != stringToTypeInfo.end() )
307 types[ index->second ].readableName = _name;
309 std::cerr <<
"Could not set human name for DataType. Type not found!" << std::endl;
313 DataType::DataType():
318 DataType::DataType(
const unsigned int& _i):
325 bool DataType::operator!=(
const unsigned int& _i )
const{
326 return (_i != field);
329 bool DataType::operator!=(
const DataType& _i )
const{
330 return (field != _i.field);
335 bool DataType::operator==(
const unsigned int& _i )
const {
336 return (_i == field);
339 bool DataType::operator==(
const DataType& _i )
const{
340 return (_i.field == field);
345 DataType& DataType::operator=(
const unsigned int& _i ) {
357 bool DataType::operator<(
const unsigned int& _i )
const {
361 bool DataType::operator<(
const DataType& _i )
const {
362 return (field < _i.field);
367 bool DataType::operator&(
const unsigned int& _i )
const {
371 bool DataType::operator&(
const DataType& _i )
const {
372 return (field & _i.field);
379 inv.field = !inv.field;
385 bool DataType::contains(
const DataType& _i )
const{
387 return ( (_i.field & field) == _i.field);
392 DataType& DataType::operator|=(
const unsigned int& _i ) {
405 return (field | _i.field);
410 DataType DataType::operator++(
int ) {
434 qRegisterMetaType<IdList>(
"IdList");
435 qRegisterMetaType<DataType>(
"DataType");
436 qRegisterMetaType< QVector< int > >(
"QVector<int>");
437 qRegisterMetaType<Vector>(
"Vector");
438 qRegisterMetaType<Vector4>(
"Vector4");
439 qRegisterMetaType<Matrix4x4>(
"Matrix4x4");
440 qRegisterMetaType<UpdateType>(
"UpdateType");
441 qRegisterMetaType<Logtype>(
"LogType");
const DataType DATA_UNKNOWN(0)
None of the other Objects.
QString typeIconName(QString _name)
Get the icon of a given dataType.
const DataType DATA_GROUP(1)
Items used for Grouping.
bool typeExists(QString _name)
Check if a type with the given name exists.
DataType addDataType(QString _name, QString _readableName)
Adds a datatype and returns the id for the new type.
QString dataTypeName(DataType _id)
Get DataType Human readable name ( this name might change. Use the typeName insted! ) ...
std::vector< TypeInfo >::const_iterator typesBegin()
Get iterator pointing to the first element in the tyoes list.
size_t typeCount()
Return the number of registered types.
QIcon & typeIcon(DataType _id)
get the icon of a given dataType
void setTypeIcon(DataType _id, QString _icon)
Set the icon for a given dataType.
std::ostream & operator<<(std::ostream &_o, const Timer &_t)
void setDataTypeName(DataType _id, QString _name)
Set the icon for a given dataType.
DataType typeId(QString _name)
Get the id of a type with given name.
const DataType DATA_ALL(UINT_MAX)
Identifier for all available objects.
std::vector< TypeInfo >::const_iterator typesEnd()
Get iterator pointing to the last element in the tyoes list.
unsigned int value() const
QString typeName(DataType _id)
Get the name of a type with given id.
QString name() const
Return the name of this type as text.