tuchulcha  0.10.1
Graphical Workflow Configuration Editor
VarTypeMap.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2009 Jens-Malte Gottfried
2 
3  This file is part of Tuchulcha.
4 
5  Tuchulcha is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  Tuchulcha is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with Tuchulcha. If not, see <http://www.gnu.org/licenses/>.
17 */
24 #include "VarTypeMap.h"
25 #include <QMutexLocker>
26 
27 // initialize static variables
29 QMutex VarTypeMap::_lock;
30 
31 VarTypeMap::VarTypeMap() {
32  // add types
33  _typeMap["bool"] = QVariant::Bool;
34  _typeMap["int"] = QVariant::Int;
35  _typeMap["uint"] = QVariant::UInt;
36  _typeMap["char"] = QVariant::Char;
37  _typeMap["float"] = QVariant::Double;
38  _typeMap["double"] = QVariant::Double;
39  _typeMap["longlong"] = QVariant::LongLong;
40  _typeMap["ulonglong"] = QVariant::ULongLong;
41 }
42 
43 VarTypeMap::~VarTypeMap() {
44 }
45 
47  QMutexLocker locker(&_lock);
48  if(!_address)
49  _address = new VarTypeMap;
50  return *_address;
51 }
52 
53 QVariant::Type VarTypeMap::operator[](QString type) const {
54  QMap<QString, QVariant::Type>::const_iterator found;
55  found = _typeMap.find(type);
56  if (found == _typeMap.end())
57  return QVariant::String;
58  else
59  return found.value();
60 }
61 
static VarTypeMap * _address
pointer to the singleMapper instance
Definition: VarTypeMap.h:46
QVariant::Type operator[](QString type) const
return type map
Definition: VarTypeMap.cpp:53
Mapping of types given as string to QVariant::type.
QMap< QString, QVariant::Type > _typeMap
mapping from given type values to QVariant types
Definition: VarTypeMap.h:44
Convert parameter types into Qt versions.
Definition: VarTypeMap.h:36
static VarTypeMap & instance()
return reference to an VarTypeMap instance
Definition: VarTypeMap.cpp:46
static QMutex _lock
Mutex to avoid multiple creation.
Definition: VarTypeMap.h:48