Dataset.cpp
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 #include <OpenKarto/Dataset.h>
00019 #include <OpenKarto/TypeCasts.h>
00020 
00021 namespace karto
00022 {
00023 
00027 
00028   struct DatasetPrivate
00029   {
00030     ObjectList m_Objects;
00031     SmartPointer<DatasetInfo> m_pDatasetInfo;
00032   };
00033 
00034   Dataset::Dataset()
00035     : m_pDatasetPrivate(new DatasetPrivate())
00036   {
00037     m_pDatasetPrivate->m_pDatasetInfo = NULL;
00038   }
00039 
00040   Dataset::~Dataset()
00041   {
00042     Clear();
00043 
00044     delete m_pDatasetPrivate;
00045   }
00046 
00047   void Dataset::Add(Object* pObject)
00048   {
00049     if (pObject != NULL)
00050     {
00051       if (IsDatasetInfo(pObject))
00052       {
00053         m_pDatasetPrivate->m_pDatasetInfo = dynamic_cast<DatasetInfo*>(pObject);
00054       }
00055       else
00056       {
00057         m_pDatasetPrivate->m_Objects.Add(pObject);
00058       }
00059     }
00060   }
00061 
00062   DatasetInfo* Dataset::GetDatasetInfo()
00063   {
00064     return m_pDatasetPrivate->m_pDatasetInfo;
00065   }
00066 
00067   void Dataset::Clear()
00068   {
00069     m_pDatasetPrivate->m_Objects.Clear();
00070     m_pDatasetPrivate->m_pDatasetInfo = NULL;
00071   }
00072 
00073   const ObjectList& Dataset::GetObjects() const
00074   {
00075     return m_pDatasetPrivate->m_Objects;
00076   }
00077 
00078   Object* Dataset::operator[](kt_int32u index) const
00079   {
00080     assert(index < m_pDatasetPrivate->m_Objects.Size());
00081     return m_pDatasetPrivate->m_Objects[index];
00082   }
00083 
00084 }


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