Changeset 286 for XMLIO_V2/dev/common/src/xmlio/object_factory_impl.hpp
- Timestamp:
- 10/21/11 19:01:35 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XMLIO_V2/dev/common/src/xmlio/object_factory_impl.hpp
r266 r286 31 31 return (U::AllMapObj[CObjectFactory::CurrContext].find(id) != 32 32 U::AllMapObj[CObjectFactory::CurrContext].end()); 33 } 34 35 template <typename U> 36 bool CObjectFactory::HasObject(const StdString & context, const StdString & id) 37 { 38 if (U::AllMapObj.find(context) == U::AllMapObj.end()) return false ; 39 else return (U::AllMapObj[context].find(id) != U::AllMapObj[context].end()); 33 40 } 34 41 … … 73 80 74 81 template <typename U> 82 boost::shared_ptr<U> CObjectFactory::GetObject(const StdString & context, const StdString & id) 83 { 84 if (!CObjectFactory::HasObject<U>(context,id)) 85 ERROR("CObjectFactory::GetObject(const StdString & id)", 86 << "[ id = " << id << ", U = " << U::GetName() <<", context = "<<context<< " ] " 87 << " object is not referenced !"); 88 return (U::AllMapObj[CObjectFactory::CurrContext][id]); 89 } 90 91 template <typename U> 75 92 boost::shared_ptr<U> CObjectFactory::CreateObject(const StdString & id) 76 93 { … … 80 97 if (id.size() == 0) 81 98 { 82 boost::shared_ptr<U> value(new U );99 boost::shared_ptr<U> value(new U(CObjectFactory::GenUId<U>())); 83 100 U::AllVectObj[CObjectFactory::CurrContext].insert 84 101 (U::AllVectObj[CObjectFactory::CurrContext].end(), value); 102 U::AllMapObj[CObjectFactory::CurrContext].insert(std::make_pair(value->getId(), value)); 85 103 return (value); 86 104 } … … 105 123 return (U::AllVectObj[context]); 106 124 } 107 125 126 template <typename U> 127 StdString CObjectFactory::GenUId(void) 128 { 129 long int seed ; 130 131 xios_map<StdString,long int>::iterator it ; 132 it=U::GenId.find(CObjectFactory::CurrContext); 133 if (it==U::GenId.end()) 134 { 135 seed=0 ; 136 U::GenId[CObjectFactory::CurrContext]=seed ; 137 } 138 else 139 { 140 seed=it->second ; 141 seed++ ; 142 it->second=seed ; 143 } 144 145 StdOStringStream oss ; 146 oss<<"__"<<U::GetName()<<"_undef_id_"<<seed ; 147 return StdString(oss.str()) ; 148 } 149 108 150 } // namespace xmlioserver 109 151
Note: See TracChangeset
for help on using the changeset viewer.