MRXT: The Multi-Robot eXploration Tool
Multi-Robot autonomous exploration and mapping simulator.
|
00001 #include "landmarksData.h" 00002 00003 #include <assert.h> 00004 #include <string.h> 00005 00006 landmarksData::landmarksData(): 00007 nLandmarks(0), 00008 marksReserved(0), 00009 landmarks(0) 00010 { 00011 00012 } 00013 00014 landmarksData::landmarksData(int nl): 00015 nLandmarks(0), 00016 marksReserved(nl), 00017 landmarks(new landmark[nl]()) 00018 { 00019 00020 } 00021 00022 landmarksData::landmarksData(const landmarksData& lmd): 00023 nLandmarks(lmd.nLandmarks), 00024 marksReserved(lmd.marksReserved), 00025 landmarks(new landmark[marksReserved]()) 00026 { 00027 for (int i = 0; i< nLandmarks; i++){ 00028 landmarks[i] = lmd.landmarks[i]; 00029 } 00030 } 00031 00032 landmarksData::~landmarksData(){ 00033 if (landmarks) delete[] landmarks; 00034 } 00035 00036 landmarksData& landmarksData::operator= (const landmarksData &lmd){ 00037 if (marksReserved != lmd.marksReserved){ 00038 if (landmarks) delete[] landmarks; 00039 marksReserved = lmd.marksReserved; 00040 landmarks = new landmark[marksReserved](); 00041 } 00042 nLandmarks = lmd.nLandmarks; 00043 for (int i = 0; i< nLandmarks; i++) 00044 landmarks[i] = lmd.landmarks[i]; 00045 00046 // return the existing object 00047 return *this; 00048 } 00049 00050 void landmarksData::reserve(int nl){ 00051 nLandmarks = 0; 00052 marksReserved = nl; 00053 if (landmarks) delete[] landmarks; 00054 landmarks = new landmark[nl](); 00055 }