Changeset 1601 for XIOS/dev/dev_trunk_omp/src/object_factory_impl.hpp
- Timestamp:
- 11/19/18 15:52:54 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/dev_trunk_omp/src/object_factory_impl.hpp
r1542 r1601 10 10 int CObjectFactory::GetObjectNum(void) 11 11 { 12 if (CurrContext .size() == 0)12 if (CurrContext_ptr->size() == 0) 13 13 ERROR("CObjectFactory::GetObjectNum(void)", 14 14 << "please define current context id !"); 15 return (U::AllVectObj[CObjectFactory::CurrContext].size()); 15 if(U::AllVectObj_ptr == NULL) return 0; 16 return (*U::AllVectObj_ptr)[*CObjectFactory::CurrContext_ptr].size(); 16 17 } 17 18 … … 19 20 int CObjectFactory::GetObjectIdNum(void) 20 21 { 21 if (CurrContext .size() == 0)22 if (CurrContext_ptr->size() == 0) 22 23 ERROR("CObjectFactory::GetObjectIdNum(void)", 23 24 << "please define current context id !"); 24 return (U::AllMapObj[CObjectFactory::CurrContext].size()); 25 if(U::AllMapObj_ptr == NULL) return 0; 26 return (*U::AllMapObj_ptr)[*CObjectFactory::CurrContext_ptr].size(); 25 27 } 26 28 … … 28 30 bool CObjectFactory::HasObject(const StdString & id) 29 31 { 30 if (CurrContext .size() == 0)32 if (CurrContext_ptr->size() == 0) 31 33 ERROR("CObjectFactory::HasObject(const StdString & id)", 32 34 << "[ id = " << id << " ] please define current context id !"); 33 return (U::AllMapObj[CObjectFactory::CurrContext].find(id) != 34 U::AllMapObj[CObjectFactory::CurrContext].end()); 35 if(U::AllMapObj_ptr == NULL) return false; 36 return ((*U::AllMapObj_ptr)[*CObjectFactory::CurrContext_ptr].find(id) != 37 (*U::AllMapObj_ptr)[*CObjectFactory::CurrContext_ptr].end()); 38 35 39 } 36 40 … … 38 42 bool CObjectFactory::HasObject(const StdString & context, const StdString & id) 39 43 { 40 if (U::AllMapObj.find(context) == U::AllMapObj.end()) return false ; 41 else return (U::AllMapObj[context].find(id) != U::AllMapObj[context].end()); 44 if(U::AllMapObj_ptr == NULL) return false; 45 46 if (U::AllMapObj_ptr->find(context) == U::AllMapObj_ptr->end()) return false ; 47 else return ((*U::AllMapObj_ptr)[context].find(id) != (*U::AllMapObj_ptr)[context].end()); 42 48 } 43 49 … … 45 51 std::shared_ptr<U> CObjectFactory::GetObject(const U * const object) 46 52 { 47 if (CurrContext.size() == 0) 53 if(U::AllVectObj_ptr == NULL) return (std::shared_ptr<U>()); 54 if (CurrContext_ptr->size() == 0) 48 55 ERROR("CObjectFactory::GetObject(const U * const object)", 49 56 << "please define current context id !"); 50 std::vector<std::shared_ptr<U> > & vect = 51 U::AllVectObj[CObjectFactory::CurrContext]; 57 std::vector<std::shared_ptr<U> > & vect = (*U::AllVectObj_ptr)[*CObjectFactory::CurrContext_ptr]; 52 58 53 59 typename std::vector<std::shared_ptr<U> >::const_iterator … … 70 76 std::shared_ptr<U> CObjectFactory::GetObject(const StdString & id) 71 77 { 72 if (CurrContext.size() == 0) 78 if(U::AllMapObj_ptr == NULL) return (std::shared_ptr<U>()); 79 if (CurrContext_ptr->size() == 0) 73 80 ERROR("CObjectFactory::GetObject(const StdString & id)", 74 81 << "[ id = " << id << " ] please define current context id !"); … … 77 84 << "[ id = " << id << ", U = " << U::GetName() << " ] " 78 85 << "object was not found."); 79 return ( U::AllMapObj[CObjectFactory::CurrContext][id]);86 return (*U::AllMapObj_ptr)[*CObjectFactory::CurrContext_ptr][id]; 80 87 } 81 88 … … 83 90 std::shared_ptr<U> CObjectFactory::GetObject(const StdString & context, const StdString & id) 84 91 { 92 if(U::AllMapObj_ptr == NULL) return (std::shared_ptr<U>()); 93 85 94 if (!CObjectFactory::HasObject<U>(context,id)) 86 95 ERROR("CObjectFactory::GetObject(const StdString & id)", 87 96 << "[ id = " << id << ", U = " << U::GetName() <<", context = "<<context<< " ] " 88 97 << "object was not found."); 89 return ( U::AllMapObj[context][id]);98 return (*U::AllMapObj_ptr)[context][id]; 90 99 } 91 100 … … 93 102 std::shared_ptr<U> CObjectFactory::CreateObject(const StdString& id) 94 103 { 95 if (CurrContext.empty()) 104 if(U::AllVectObj_ptr == NULL) U::AllVectObj_ptr = new xios_map<StdString, std::vector<std::shared_ptr<U> > >; 105 if(U::AllMapObj_ptr == NULL) U::AllMapObj_ptr = new xios_map<StdString, xios_map<StdString, std::shared_ptr<U> > >; 106 107 if (CurrContext_ptr->empty()) 96 108 ERROR("CObjectFactory::CreateObject(const StdString& id)", 97 109 << "[ id = " << id << " ] please define current context id !"); … … 105 117 std::shared_ptr<U> value(new U(id.empty() ? CObjectFactory::GenUId<U>() : id)); 106 118 107 U::AllVectObj[CObjectFactory::CurrContext].insert(U::AllVectObj[CObjectFactory::CurrContext].end(), value);108 U::AllMapObj[CObjectFactory::CurrContext].insert(std::make_pair(value->getId(), value));119 (*U::AllVectObj_ptr)[*CObjectFactory::CurrContext_ptr].insert((*U::AllVectObj_ptr)[*CObjectFactory::CurrContext_ptr].end(), value); 120 (*U::AllMapObj_ptr) [*CObjectFactory::CurrContext_ptr].insert(std::make_pair(value->getId(), value)); 109 121 110 122 return value; … … 116 128 CObjectFactory::GetObjectVector(const StdString & context) 117 129 { 118 return ( U::AllVectObj[context]);130 return (*U::AllVectObj_ptr)[context]; 119 131 } 120 132 … … 130 142 { 131 143 StdOStringStream oss; 132 oss << GetUIdBase<U>() << U::GenId[CObjectFactory::CurrContext]++; 144 if(U::GenId_ptr == NULL) U::GenId_ptr = new xios_map< StdString, long int >; 145 oss << GetUIdBase<U>() << (*U::GenId_ptr)[*CObjectFactory::CurrContext_ptr]++; 133 146 return oss.str(); 134 147 }
Note: See TracChangeset
for help on using the changeset viewer.