Object.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2006-2011, SRI International (R)
00003  *
00004  * This program is free software: you can redistribute it and/or modify
00005  * it under the terms of the GNU Lesser General Public License as published by
00006  * the Free Software Foundation, either version 3 of the License, or
00007  * (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU Lesser General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Lesser General Public License
00015  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016  */
00017 
00018 #pragma once
00019 
00020 #ifndef __ObjectKarto_Object_h__
00021 #define __ObjectKarto_Object_h__
00022 
00023 #include <OpenKarto/Identifier.h>
00024 #include <OpenKarto/Parameter.h>
00025 #include <OpenKarto/List.h>
00026 #include <OpenKarto/Meta.h>
00027 
00028 namespace karto
00029 {
00030 
00032 
00033 
00037 
00041   #define KARTO_TYPECHECKCAST(__Name__) \
00042     inline kt_bool Is##__Name__(Object* pObject) \
00043     { \
00044       return dynamic_cast<__Name__ *>(pObject) != NULL;\
00045     } 
00046 
00050 
00054   class KARTO_EXPORT Object : public Referenced
00055   {
00056     KARTO_RTTI();
00057 
00058   public:
00062     Object();
00063 
00068     Object(const Identifier& rIdentifier);
00069 
00070   protected:
00071     //@cond EXCLUDE
00075     virtual ~Object();
00076     //@endcond
00077     
00078   public:
00083     inline const Identifier& GetIdentifier() const 
00084     {
00085       return m_Identifier; 
00086     }
00087     
00093     inline AbstractParameter* GetParameter(const String& rParameterName) const
00094     {
00095       return m_pParameterSet->GetParameter(rParameterName);
00096     }
00097 
00103     template<typename T>
00104     inline Parameter<T>* GetParameter(const String& rParameterName) const
00105     {
00106       return dynamic_cast<Parameter<T>*>(m_pParameterSet->GetParameter(rParameterName));
00107     }
00108    
00114     template<typename T>
00115     inline void SetParameters(const karto::String& rParameterName, const T& rValue)
00116     {
00117       AbstractParameter* pAbstractParameters = GetParameter(rParameterName);
00118       if (pAbstractParameters != NULL)
00119       {
00120         pAbstractParameters->SetValueFromString(StringHelper::ToString(rValue));
00121       }
00122       else
00123       {
00124         String errorMessage;
00125         errorMessage.Append("Parameter does not exist: ");
00126         errorMessage.Append(rParameterName);
00127         errorMessage.Append(String::NewLine());
00128         errorMessage.Append("Valid parameters are: ");
00129         errorMessage.Append(String::NewLine());
00130         const ParameterList& rParameters = m_pParameterSet->GetParameters();
00131         karto_const_forEach(ParameterList, &rParameters)
00132         {
00133           errorMessage.Append("\t" + (*iter)->GetName());
00134           errorMessage.Append(String::NewLine());
00135         }
00136         throw Exception(errorMessage);
00137       }
00138     }
00139 
00144     inline ParameterSet* GetParameterSet()
00145     {
00146       return m_pParameterSet;
00147     }
00148     
00153     inline ParameterList GetParameters()
00154     {
00155       return m_pParameterSet->GetParameters();
00156     }    
00157     
00158   private:
00159     // restrict the following functions
00160     Object(const Object&);
00161     const Object& operator=(const Object&);
00162 
00163   private:
00164     Identifier m_Identifier;
00165 
00166     ParameterSetPtr m_pParameterSet;
00167   }; // class Object
00168 
00172   KARTO_TYPE(Object);
00173 
00177   typedef SmartPointer<Object> ObjectPtr;
00178 
00182   typedef List<ObjectPtr> ObjectList;
00183 
00187 
00191   const kt_objecttype ObjectType_None                                                                   = 0x00000000;
00192 
00196   const kt_objecttype ObjectType_Sensor                                                         = 0x00001000;
00197 
00201   const kt_objecttype ObjectType_SensorData                                     = 0x00002000;
00202 
00206   const kt_objecttype ObjectType_CustomItem                                     = 0x00004000;
00207 
00211   const kt_objecttype ObjectType_Grid                                           = 0x00008000;
00212 
00216   const kt_objecttype ObjectType_Message                                        = 0x00010000;
00217 
00221   const kt_objecttype ObjectType_Object                                                         = 0x00020000;
00222 
00226   const kt_objecttype ObjectType_Misc                                                                   = 0x10000000;
00227 
00231   const kt_objecttype ObjectType_Drive                                                          = ObjectType_Sensor | 0x01;
00232 
00236   const kt_objecttype ObjectType_LaserRangeFinder                       = ObjectType_Sensor | 0x02;
00237 
00241   const kt_objecttype ObjectType_Camera                                                         = ObjectType_Sensor | 0x04;
00242 
00246   const kt_objecttype ObjectType_DrivePose                                              = ObjectType_SensorData | 0x01;
00247 
00251   const kt_objecttype ObjectType_LaserRangeScan             = ObjectType_SensorData | 0x02;
00252 
00256   const kt_objecttype ObjectType_LocalizedObject                = ObjectType_SensorData | 0x04;
00257 
00261   const kt_objecttype ObjectType_LocalizedRangeScan             = ObjectType_SensorData | 0x08;
00262 
00266   const kt_objecttype ObjectType_LocalizedPointScan             = ObjectType_SensorData | 0x10;
00267 
00271   const kt_objecttype ObjectType_LocalizedLaserScan             = ObjectType_SensorData | 0x20;
00272 
00276   const kt_objecttype ObjectType_DefaultCustomItem    = ObjectType_CustomItem | 0x01;
00277 
00281   const kt_objecttype ObjectType_Rfid                 = ObjectType_CustomItem | 0x02;
00282 
00286   const kt_objecttype ObjectType_CameraImage              = ObjectType_SensorData | 0x40;
00287 
00291   const kt_objecttype ObjectType_OccupancyGrid            = ObjectType_Grid | 0x01;
00292 
00296   const kt_objecttype ObjectType_OccupancyGridTile        = ObjectType_Grid | 0x02;
00297 
00301   const kt_objecttype ObjectType_Header                                                         = ObjectType_Misc | 0x01;
00302 
00306   const kt_objecttype ObjectType_Image                                                          = ObjectType_Misc | 0x02;
00307 
00311   const kt_objecttype ObjectType_ModuleParameters                 = ObjectType_Object | 0x01;
00312 
00316   const kt_objecttype ObjectType_DatasetInfo                        = ObjectType_Object | 0x02;
00317 
00321   const kt_objecttype ObjectType_Module               = ObjectType_Object | 0x04;
00322 
00326   const kt_objecttype ObjectType_TiledOccupancyGrid   = ObjectType_Object | 0x08;
00327 
00331   const kt_objecttype ObjectType_Int32sMessage        = ObjectType_Message | 0x01;
00332 
00336   const kt_objecttype ObjectType_Int64sMessage        = ObjectType_Message | 0x02;
00337 
00341   const kt_objecttype ObjectType_DoubleMessage        = ObjectType_Message | 0x04;
00342 
00346   const kt_objecttype ObjectType_StringMessage        = ObjectType_Message | 0x08;
00347 
00351   const kt_objecttype ObjectType_DatasetObjectMessage = ObjectType_Message | 0x10;
00352 
00356   const kt_objecttype ObjectType_ScansPoseUpdateMessage = ObjectType_Message | 0x20;
00357 
00359 
00360 }
00361 
00362 
00363 #endif // __ObjectKarto_Object_h__


nav2d_karto
Author(s): Sebastian Kasperski
autogenerated on Sun Apr 2 2017 04:05:23