Main Page · Modules · All Classes · Class Hierarchy
MSData.hpp
1 /*
2  * This file is part of the AiBO+ project
3  *
4  * Copyright (C) 2005-2016 Csaba Kertész (csaba.kertesz@gmail.com)
5  *
6  * AiBO+ is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * AiBO+ is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
19  *
20  */
21 
22 #pragma once
23 
29 #include <MCDefs.hpp>
30 
31 #include <qmap.h>
32 #include <qstringlist.h>
33 
35 #define MSDATA_FUNCTIONS(data_class_name) \
36 MSData& operator=(MSData& data) \
37 { \
38  data_class_name& OldData = static_cast<data_class_name&>(data); \
39  \
40  if (&OldData == this) \
41  return *static_cast<MSData*>(this); \
42  *this = OldData; \
43  return *this; \
44 }; \
45  \
46 MSData& operator=(const MSData& data) \
47 { \
48  return operator=(const_cast<MSData&>(data)); \
49 };
50 
54 struct MSData
55 {
57 
58 
65  explicit MSData(const QString& type_name);
66 
74  MSData(const MSData& other);
75 
77  virtual ~MSData() {};
78 
88  QString GetTypeName() const;
89 
102  void* operator[](const QString& variable) const;
103 
113  const QMap<QString, void*>& GetVariableMap() const;
114 
130  virtual MSData& operator=(MSData& data);
131 
147  virtual MSData& operator=(const MSData& data);
148 
149 protected:
151  QMap<QString, void*> VariableMap;
153  QString TypeName;
154 };
155 
virtual MSData & operator=(MSData &data)
Copy assignment operator.
Definition: MSData.cpp:60
QMap< QString, void * > VariableMap
Variable map.
Definition: MSData.hpp:151
virtual ~MSData()
Class destructor.
Definition: MSData.hpp:77
#define MC_DISABLE_DEFAULT_CTOR(class_name)
Helper macro to disable the default constructor of a class.
Definition: MCDefs.hpp:611
const QMap< QString, void * > & GetVariableMap() const
Get the variable map.
Definition: MSData.cpp:54
Base class for the data exchange of the elements.
Definition: MSData.hpp:54
MSData(const QString &type_name)
Class constructor.
Definition: MSData.cpp:26
QString TypeName
Type name.
Definition: MSData.hpp:153
QString GetTypeName() const
Get the type name.
Definition: MSData.cpp:42
void * operator[](const QString &variable) const
operator[] to resolve variable pointers
Definition: MSData.cpp:48