00001 /*========================================================================= 00002 00003 Program: F.R.E.E. - flexible registration evaluation engine 00004 Version: v.1.0.0 00005 Date: $Date: 2006/09/01 12:00:00 $ 00006 Module: $RCSfile: freSmartCollectionBase.cxx,v $ 00007 Language: C++ 00008 00009 00010 00011 Copyright (c) 2007 Ralf o Floca (Department of Medical Informatics, 00012 Institute for Medical Biometry and Informatics, University of Heidelberg, 00013 Germany). All rights reserved. 00014 See FREECopyright.txt or http://www.mi.med.uni-hd.de/free/copyright.htm 00015 for details. 00016 00017 This software is distributed WITHOUT ANY WARRANTY; without even 00018 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00019 PURPOSE. See the above copyright notices for more information. 00020 00021 =========================================================================*/ 00022 00023 #ifndef __freSmartCollectionBase_txx 00024 #define __freSmartCollectionBase_txx 00025 00026 #include "freSmartCollectionBase.h" 00027 00028 namespace FREE 00029 { 00030 00031 template <class TElement> 00032 SmartCollectionBase< TElement>& 00033 SmartCollectionBase< TElement>:: 00034 operator = (const SmartCollectionBase& rCollection) 00035 { 00036 Superclass::operator = (rCollection); 00037 return *this; 00038 }; 00039 00041 template <class TElement> 00042 SmartCollectionBase< TElement>& 00043 SmartCollectionBase< TElement>:: 00044 operator + (const SmartCollectionBase& collection) 00045 { 00046 Superclass::operator + (collection); 00047 return *this; 00048 }; 00049 00050 template <class TElement> 00051 typename SmartCollectionBase< TElement>::ElementType* 00052 SmartCollectionBase< TElement>:: 00053 GetElement(const ElementsCountType& index) const 00054 { 00055 if ((index>=0)&(index<this->m_Elements.size())) 00056 { 00057 return (this->m_Elements[index]).GetPointer(); 00058 }; 00059 return NULL; 00060 }; 00061 00062 template <class TElement> 00063 typename SmartCollectionBase< TElement>::ElementsCountType 00064 SmartCollectionBase< TElement>:: 00065 AddElement(ElementType* pElement) 00066 { 00067 if (!pElement) throwExceptionMacro("Error; passed element is NULL."); 00068 00069 StorageType smartPointer = pElement; 00070 this->m_Elements.push_back(pElement); 00071 return this->m_Elements.size()-1; 00072 }; 00073 00074 template <class TElement> 00075 typename SmartCollectionBase< TElement>::ElementsCountType 00076 SmartCollectionBase< TElement>:: 00077 AddElement(const ElementType& element) 00078 { 00079 StorageType smpNew = ElementType::New(); 00080 *(smpNew.GetPointer()) = element; 00081 return AddElement(smpNew); 00082 } 00083 00084 }//end of namespace FREE 00085 00086 #endif
1.5.3 written by Dimitri van Heesch,
© 1997-2000