00001 // ////////////////////////////////////////////////////////////////////// 00002 // Import section 00003 // ////////////////////////////////////////////////////////////////////// 00004 // STL 00005 #include <cassert> 00006 #include <sstream> 00007 // Boost (STL Extension) 00008 #include <boost/functional/hash/hash.hpp> 00009 // Airinv 00010 #include <airinv/bom/BomAbstract.hpp> 00011 #include <airinv/factory/FacBomAbstract.hpp> 00012 00013 namespace AIRINV { 00014 00015 // ////////////////////////////////////////////////////////////////////// 00016 FacBomAbstract::~FacBomAbstract() { 00017 clean (); 00018 } 00019 00020 // ////////////////////////////////////////////////////////////////////// 00021 void FacBomAbstract::clean() { 00022 for (BomPool_T::iterator itBom = _pool.begin(); 00023 itBom != _pool.end(); itBom++) { 00024 BomAbstract* currentBom_ptr = *itBom; 00025 assert (currentBom_ptr != NULL); 00026 00027 delete (currentBom_ptr); currentBom_ptr = NULL; 00028 } 00029 00030 // Empty the pool of Factories 00031 _pool.clear(); 00032 } 00033 00034 // ////////////////////////////////////////////////////////////////////// 00035 std::size_t FacBomAbstract::getID (const BomAbstract* iBomAbstract_ptr) { 00036 const void* lPtr = iBomAbstract_ptr; 00037 boost::hash<const void*> ptr_hash; 00038 const std::size_t lID = ptr_hash (lPtr); 00039 return lID; 00040 } 00041 00042 // ////////////////////////////////////////////////////////////////////// 00043 std::size_t FacBomAbstract::getID (const BomAbstract& iBomAbstract) { 00044 return getID (&iBomAbstract); 00045 } 00046 00047 // ////////////////////////////////////////////////////////////////////// 00048 std::string FacBomAbstract::getIDString(const BomAbstract* iBomAbstract_ptr) { 00049 const std::size_t lID = getID (iBomAbstract_ptr); 00050 std::ostringstream oStr; 00051 oStr << lID; 00052 return oStr.str(); 00053 } 00054 00055 // ////////////////////////////////////////////////////////////////////// 00056 std::string FacBomAbstract::getIDString (const BomAbstract& iBomAbstract) { 00057 return getIDString (&iBomAbstract); 00058 } 00059 00060 }