Changeset 1545 for XIOS/dev/branch_openmp/src/object_factory_impl.hpp
- Timestamp:
- 06/18/18 20:32:55 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/branch_openmp/src/object_factory_impl.hpp
r1460 r1545 13 13 ERROR("CObjectFactory::GetObjectNum(void)", 14 14 << "please define current context id !"); 15 //return (U::AllVectObj[CObjectFactory::CurrContext].size());16 15 if(U::AllVectObj_ptr == NULL) return 0; 17 16 return (*U::AllVectObj_ptr)[*CObjectFactory::CurrContext_ptr].size(); … … 24 23 ERROR("CObjectFactory::GetObjectIdNum(void)", 25 24 << "please define current context id !"); 26 //return (U::AllMapObj[CObjectFactory::CurrContext].size());27 25 if(U::AllMapObj_ptr == NULL) return 0; 28 26 return (*U::AllMapObj_ptr)[*CObjectFactory::CurrContext_ptr].size(); … … 35 33 ERROR("CObjectFactory::HasObject(const StdString & id)", 36 34 << "[ id = " << id << " ] please define current context id !"); 37 //return (U::AllMapObj[CObjectFactory::CurrContext].find(id) !=38 // U::AllMapObj[CObjectFactory::CurrContext].end());39 35 if(U::AllMapObj_ptr == NULL) return false; 40 36 return ((*U::AllMapObj_ptr)[*CObjectFactory::CurrContext_ptr].find(id) != … … 46 42 bool CObjectFactory::HasObject(const StdString & context, const StdString & id) 47 43 { 48 49 // if (U::AllMapObj.find(context) == U::AllMapObj.end()) return false ;50 // else return (U::AllMapObj[context].find(id) != U::AllMapObj[context].end());51 44 if(U::AllMapObj_ptr == NULL) return false; 52 45 … … 56 49 57 50 template <typename U> 58 boost::shared_ptr<U> CObjectFactory::GetObject(const U * const object)51 std::shared_ptr<U> CObjectFactory::GetObject(const U * const object) 59 52 { 60 if(U::AllVectObj_ptr == NULL) return ( boost::shared_ptr<U>());53 if(U::AllVectObj_ptr == NULL) return (std::shared_ptr<U>()); 61 54 if (CurrContext_ptr->size() == 0) 62 55 ERROR("CObjectFactory::GetObject(const U * const object)", 63 56 << "please define current context id !"); 64 //std::vector<boost::shared_ptr<U> > & vect = U::AllVectObj[CObjectFactory::CurrContext]; 65 std::vector<boost::shared_ptr<U> > & vect = (*U::AllVectObj_ptr)[*CObjectFactory::CurrContext_ptr]; 57 std::vector<std::shared_ptr<U> > & vect = (*U::AllVectObj_ptr)[*CObjectFactory::CurrContext_ptr]; 66 58 67 typename std::vector< boost::shared_ptr<U> >::const_iterator59 typename std::vector<std::shared_ptr<U> >::const_iterator 68 60 it = vect.begin(), end = vect.end(); 69 61 70 62 for (; it != end; it++) 71 63 { 72 boost::shared_ptr<U> ptr = *it;64 std::shared_ptr<U> ptr = *it; 73 65 if (ptr.get() == object) 74 66 return (ptr); … … 78 70 << "[type = " << U::GetName() << ", adress = " << object << "] " 79 71 << "object was not found."); 80 return ( boost::shared_ptr<U>()); // jamais atteint72 return (std::shared_ptr<U>()); // jamais atteint 81 73 } 82 74 83 75 template <typename U> 84 boost::shared_ptr<U> CObjectFactory::GetObject(const StdString & id)76 std::shared_ptr<U> CObjectFactory::GetObject(const StdString & id) 85 77 { 86 if(U::AllMapObj_ptr == NULL) return ( boost::shared_ptr<U>());78 if(U::AllMapObj_ptr == NULL) return (std::shared_ptr<U>()); 87 79 if (CurrContext_ptr->size() == 0) 88 80 ERROR("CObjectFactory::GetObject(const StdString & id)", … … 92 84 << "[ id = " << id << ", U = " << U::GetName() << " ] " 93 85 << "object was not found."); 94 95 //cout<<"CObjectFactory::GetObject(const StdString & id)[ id = " << id << ", U = " << U::GetName() << " ] "<<endl;96 if(id == "src_domain_regular_read")97 {98 //cout<<"match"<<endl;99 }100 101 //return (U::AllMapObj[CObjectFactory::CurrContext][id]);102 86 return (*U::AllMapObj_ptr)[*CObjectFactory::CurrContext_ptr][id]; 103 87 } 104 88 105 89 template <typename U> 106 boost::shared_ptr<U> CObjectFactory::GetObject(const StdString & context, const StdString & id)90 std::shared_ptr<U> CObjectFactory::GetObject(const StdString & context, const StdString & id) 107 91 { 108 if(U::AllMapObj_ptr == NULL) return ( boost::shared_ptr<U>());92 if(U::AllMapObj_ptr == NULL) return (std::shared_ptr<U>()); 109 93 110 94 if (!CObjectFactory::HasObject<U>(context,id)) … … 112 96 << "[ id = " << id << ", U = " << U::GetName() <<", context = "<<context<< " ] " 113 97 << "object was not found."); 114 115 //cout<<"CObjectFactory::GetObject(const StdString & context, const StdString & id)[ id = " << id << ", U = " << U::GetName() << " ] "<<endl;116 if(id == "src_domain_regular_read")117 {118 //cout<<"match"<<endl;119 boost::shared_ptr<U> value;120 }121 //return (U::AllMapObj[context][id]);122 98 return (*U::AllMapObj_ptr)[context][id]; 123 99 } 124 100 125 101 template <typename U> 126 boost::shared_ptr<U> CObjectFactory::CreateObject(const StdString& id)102 std::shared_ptr<U> CObjectFactory::CreateObject(const StdString& id) 127 103 { 128 if(U::AllVectObj_ptr == NULL) U::AllVectObj_ptr = new xios_map<StdString, std::vector< boost::shared_ptr<U> > >;129 if(U::AllMapObj_ptr == NULL) U::AllMapObj_ptr = new xios_map<StdString, xios_map<StdString, boost::shared_ptr<U> > >;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> > >; 130 106 131 107 if (CurrContext_ptr->empty()) … … 139 115 else 140 116 { 141 boost::shared_ptr<U> value(new U(id.empty() ? CObjectFactory::GenUId<U>() : id)); 142 143 //U::AllVectObj[CObjectFactory::CurrContext].insert(U::AllVectObj[CObjectFactory::CurrContext].end(), value); 144 //U::AllMapObj[CObjectFactory::CurrContext].insert(std::make_pair(value->getId(), value)); 117 std::shared_ptr<U> value(new U(id.empty() ? CObjectFactory::GenUId<U>() : id)); 145 118 146 119 (*U::AllVectObj_ptr)[*CObjectFactory::CurrContext_ptr].insert((*U::AllVectObj_ptr)[*CObjectFactory::CurrContext_ptr].end(), value); 147 120 (*U::AllMapObj_ptr) [*CObjectFactory::CurrContext_ptr].insert(std::make_pair(value->getId(), value)); 148 //cout<<"CObjectFactory::CreateObject(const StdString& id) [ id = " << id << " ]" <<endl;149 121 150 122 return value; … … 153 125 154 126 template <typename U> 155 const std::vector< boost::shared_ptr<U> > &127 const std::vector<std::shared_ptr<U> > & 156 128 CObjectFactory::GetObjectVector(const StdString & context) 157 129 { 158 //return (U::AllVectObj[context]);159 130 return (*U::AllVectObj_ptr)[context]; 160 131 }
Note: See TracChangeset
for help on using the changeset viewer.