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