Object.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2011, SRI International (R)
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #pragma once
19 
20 #ifndef __ObjectKarto_Object_h__
21 #define __ObjectKarto_Object_h__
22 
23 #include <OpenKarto/Identifier.h>
24 #include <OpenKarto/Parameter.h>
25 #include <OpenKarto/List.h>
26 #include <OpenKarto/Meta.h>
27 
28 namespace karto
29 {
30 
32 
33 
37 
41  #define KARTO_TYPECHECKCAST(__Name__) \
42  inline kt_bool Is##__Name__(Object* pObject) \
43  { \
44  return dynamic_cast<__Name__ *>(pObject) != NULL;\
45  }
46 
50 
55  {
56  KARTO_RTTI();
57 
58  public:
62  Object();
63 
68  Object(const Identifier& rIdentifier);
69 
70  protected:
71  //@cond EXCLUDE
75  virtual ~Object();
76  //@endcond
77 
78  public:
83  inline const Identifier& GetIdentifier() const
84  {
85  return m_Identifier;
86  }
87 
93  inline AbstractParameter* GetParameter(const String& rParameterName) const
94  {
95  return m_pParameterSet->GetParameter(rParameterName);
96  }
97 
103  template<typename T>
104  inline Parameter<T>* GetParameter(const String& rParameterName) const
105  {
106  return dynamic_cast<Parameter<T>*>(m_pParameterSet->GetParameter(rParameterName));
107  }
108 
114  template<typename T>
115  inline void SetParameters(const karto::String& rParameterName, const T& rValue)
116  {
117  AbstractParameter* pAbstractParameters = GetParameter(rParameterName);
118  if (pAbstractParameters != NULL)
119  {
120  pAbstractParameters->SetValueFromString(StringHelper::ToString(rValue));
121  }
122  else
123  {
124  String errorMessage;
125  errorMessage.Append("Parameter does not exist: ");
126  errorMessage.Append(rParameterName);
127  errorMessage.Append(String::NewLine());
128  errorMessage.Append("Valid parameters are: ");
129  errorMessage.Append(String::NewLine());
130  const ParameterList& rParameters = m_pParameterSet->GetParameters();
131  karto_const_forEach(ParameterList, &rParameters)
132  {
133  errorMessage.Append("\t" + (*iter)->GetName());
134  errorMessage.Append(String::NewLine());
135  }
136  throw Exception(errorMessage);
137  }
138  }
139 
145  {
146  return m_pParameterSet;
147  }
148 
154  {
155  return m_pParameterSet->GetParameters();
156  }
157 
158  private:
159  // restrict the following functions
160  Object(const Object&);
161  const Object& operator=(const Object&);
162 
163  private:
165 
167  }; // class Object
168 
173 
178 
183 
187 
191  const kt_objecttype ObjectType_None = 0x00000000;
192 
196  const kt_objecttype ObjectType_Sensor = 0x00001000;
197 
202 
207 
211  const kt_objecttype ObjectType_Grid = 0x00008000;
212 
216  const kt_objecttype ObjectType_Message = 0x00010000;
217 
221  const kt_objecttype ObjectType_Object = 0x00020000;
222 
226  const kt_objecttype ObjectType_Misc = 0x10000000;
227 
231  const kt_objecttype ObjectType_Drive = ObjectType_Sensor | 0x01;
232 
236  const kt_objecttype ObjectType_LaserRangeFinder = ObjectType_Sensor | 0x02;
237 
241  const kt_objecttype ObjectType_Camera = ObjectType_Sensor | 0x04;
242 
246  const kt_objecttype ObjectType_DrivePose = ObjectType_SensorData | 0x01;
247 
251  const kt_objecttype ObjectType_LaserRangeScan = ObjectType_SensorData | 0x02;
252 
256  const kt_objecttype ObjectType_LocalizedObject = ObjectType_SensorData | 0x04;
257 
261  const kt_objecttype ObjectType_LocalizedRangeScan = ObjectType_SensorData | 0x08;
262 
266  const kt_objecttype ObjectType_LocalizedPointScan = ObjectType_SensorData | 0x10;
267 
271  const kt_objecttype ObjectType_LocalizedLaserScan = ObjectType_SensorData | 0x20;
272 
276  const kt_objecttype ObjectType_DefaultCustomItem = ObjectType_CustomItem | 0x01;
277 
281  const kt_objecttype ObjectType_Rfid = ObjectType_CustomItem | 0x02;
282 
286  const kt_objecttype ObjectType_CameraImage = ObjectType_SensorData | 0x40;
287 
291  const kt_objecttype ObjectType_OccupancyGrid = ObjectType_Grid | 0x01;
292 
296  const kt_objecttype ObjectType_OccupancyGridTile = ObjectType_Grid | 0x02;
297 
301  const kt_objecttype ObjectType_Header = ObjectType_Misc | 0x01;
302 
306  const kt_objecttype ObjectType_Image = ObjectType_Misc | 0x02;
307 
311  const kt_objecttype ObjectType_ModuleParameters = ObjectType_Object | 0x01;
312 
316  const kt_objecttype ObjectType_DatasetInfo = ObjectType_Object | 0x02;
317 
321  const kt_objecttype ObjectType_Module = ObjectType_Object | 0x04;
322 
326  const kt_objecttype ObjectType_TiledOccupancyGrid = ObjectType_Object | 0x08;
327 
331  const kt_objecttype ObjectType_Int32sMessage = ObjectType_Message | 0x01;
332 
336  const kt_objecttype ObjectType_Int64sMessage = ObjectType_Message | 0x02;
337 
341  const kt_objecttype ObjectType_DoubleMessage = ObjectType_Message | 0x04;
342 
346  const kt_objecttype ObjectType_StringMessage = ObjectType_Message | 0x08;
347 
351  const kt_objecttype ObjectType_DatasetObjectMessage = ObjectType_Message | 0x10;
352 
356  const kt_objecttype ObjectType_ScansPoseUpdateMessage = ObjectType_Message | 0x20;
357 
359 
360 }
361 
362 
363 #endif // __ObjectKarto_Object_h__
ParameterSetPtr m_pParameterSet
Definition: Object.h:166
void Append(const String &rString)
Definition: String.cpp:82
const kt_objecttype ObjectType_LocalizedPointScan
Definition: Object.h:266
const kt_objecttype ObjectType_LaserRangeFinder
Definition: Object.h:236
Parameter< T > * GetParameter(const String &rParameterName) const
Definition: Object.h:104
const kt_objecttype ObjectType_ModuleParameters
Definition: Object.h:311
virtual void SetValueFromString(const karto::String &rStringValue)=0
const kt_objecttype ObjectType_LocalizedLaserScan
Definition: Object.h:271
const kt_objecttype ObjectType_Image
Definition: Object.h:306
#define KARTO_EXPORT
Definition: Macros.h:78
const kt_objecttype ObjectType_Int64sMessage
Definition: Object.h:336
const Identifier & GetIdentifier() const
Definition: Object.h:83
SmartPointer< Object > ObjectPtr
Definition: Object.h:177
void SetParameters(const karto::String &rParameterName, const T &rValue)
Definition: Object.h:115
const kt_objecttype ObjectType_Object
Definition: Object.h:221
const kt_objecttype ObjectType_Sensor
Definition: Object.h:196
const kt_objecttype ObjectType_Module
Definition: Object.h:321
const kt_objecttype ObjectType_ScansPoseUpdateMessage
Definition: Object.h:356
const kt_objecttype ObjectType_CustomItem
Definition: Object.h:206
const kt_objecttype ObjectType_TiledOccupancyGrid
Definition: Object.h:326
const kt_objecttype ObjectType_LocalizedObject
Definition: Object.h:256
Identifier m_Identifier
Definition: Object.h:164
const kt_objecttype ObjectType_DefaultCustomItem
Definition: Object.h:276
const kt_objecttype ObjectType_Rfid
Definition: Object.h:281
const kt_objecttype ObjectType_Header
Definition: Object.h:301
const kt_objecttype ObjectType_Misc
Definition: Object.h:226
const kt_objecttype ObjectType_DrivePose
Definition: Object.h:246
const kt_objecttype ObjectType_LocalizedRangeScan
Definition: Object.h:261
kt_int32u kt_objecttype
Definition: Types.h:165
List< ObjectPtr > ObjectList
Definition: Object.h:182
#define KARTO_RTTI()
Definition: Meta.h:198
static String NewLine()
Definition: String.cpp:117
static String ToString(const char *value)
const kt_objecttype ObjectType_StringMessage
Definition: Object.h:346
const kt_objecttype ObjectType_DatasetInfo
Definition: Object.h:316
ParameterList GetParameters()
Definition: Object.h:153
const kt_objecttype ObjectType_Message
Definition: Object.h:216
const kt_objecttype ObjectType_DatasetObjectMessage
Definition: Object.h:351
KARTO_TYPE(Grid< kt_int8u >)
const kt_objecttype ObjectType_CameraImage
Definition: Object.h:286
const kt_objecttype ObjectType_SensorData
Definition: Object.h:201
const kt_objecttype ObjectType_None
Definition: Object.h:191
const kt_objecttype ObjectType_Grid
Definition: Object.h:211
const kt_objecttype ObjectType_Drive
Definition: Object.h:231
const kt_objecttype ObjectType_Camera
Definition: Object.h:241
const kt_objecttype ObjectType_Int32sMessage
Definition: Object.h:331
ParameterSet * GetParameterSet()
Definition: Object.h:144
const kt_objecttype ObjectType_OccupancyGridTile
Definition: Object.h:296
Definition: Any.cpp:20
AbstractParameter * GetParameter(const String &rParameterName) const
Definition: Object.h:93
const kt_objecttype ObjectType_DoubleMessage
Definition: Object.h:341
#define karto_const_forEach(listtype, list)
Definition: Macros.h:136
const kt_objecttype ObjectType_OccupancyGrid
Definition: Object.h:291
const kt_objecttype ObjectType_LaserRangeScan
Definition: Object.h:251


nav2d_karto
Author(s): Sebastian Kasperski
autogenerated on Thu Jun 6 2019 19:20:24