- Timestamp:
- 05/16/17 17:54:30 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/branch_yushan_merged/src/object_factory_impl.hpp
r769 r1134 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 16 if(U::AllVectObj == NULL) return 0; 17 18 19 return (*U::AllVectObj)[*CObjectFactory::CurrContext_ptr].size(); 16 20 } 17 21 … … 19 23 int CObjectFactory::GetObjectIdNum(void) 20 24 { 21 if (CurrContext .size() == 0)25 if (CurrContext_ptr->size() == 0) 22 26 ERROR("CObjectFactory::GetObjectIdNum(void)", 23 27 << "please define current context id !"); 24 return (U::AllMapObj[CObjectFactory::CurrContext].size()); 28 if(U::AllMapObj == NULL) return 0; 29 30 31 32 return (* U::AllMapObj) [*CObjectFactory::CurrContext_ptr].size(); 25 33 } 26 34 … … 28 36 bool CObjectFactory::HasObject(const StdString & id) 29 37 { 30 if (CurrContext .size() == 0)38 if (CurrContext_ptr->size() == 0) 31 39 ERROR("CObjectFactory::HasObject(const StdString & id)", 32 40 << "[ id = " << id << " ] please define current context id !"); 33 return (U::AllMapObj[CObjectFactory::CurrContext].find(id) != 34 U::AllMapObj[CObjectFactory::CurrContext].end()); 41 42 if(U::AllMapObj == NULL) return false; 43 44 45 46 return ((*U::AllMapObj)[*CObjectFactory::CurrContext_ptr].find(id) != 47 (*U::AllMapObj)[*CObjectFactory::CurrContext_ptr].end()); 35 48 } 36 49 … … 38 51 bool CObjectFactory::HasObject(const StdString & context, const StdString & id) 39 52 { 40 if (U::AllMapObj.find(context) == U::AllMapObj.end()) return false ; 41 else return (U::AllMapObj[context].find(id) != U::AllMapObj[context].end()); 53 if(U::AllMapObj == NULL) return false; 54 55 if (U::AllMapObj->find(context) == U::AllMapObj->end()) return false ; 56 57 else 58 { 59 return ((*U::AllMapObj)[context].find(id) != (*U::AllMapObj)[context].end()); 60 } 61 42 62 } 43 63 … … 45 65 boost::shared_ptr<U> CObjectFactory::GetObject(const U * const object) 46 66 { 47 if (CurrContext.size() == 0) 67 if(U::AllVectObj == NULL) return (boost::shared_ptr<U>()); 68 69 if (CurrContext_ptr->size() == 0) 48 70 ERROR("CObjectFactory::GetObject(const U * const object)", 49 71 << "please define current context id !"); 50 72 std::vector<boost::shared_ptr<U> > & vect = 51 U::AllVectObj[CObjectFactory::CurrContext];73 (*U::AllVectObj)[*CObjectFactory::CurrContext_ptr]; 52 74 53 75 typename std::vector<boost::shared_ptr<U> >::const_iterator … … 70 92 boost::shared_ptr<U> CObjectFactory::GetObject(const StdString & id) 71 93 { 72 if (CurrContext.size() == 0) 94 if(U::AllMapObj == NULL) return (boost::shared_ptr<U>()); 95 96 if (CurrContext_ptr->size() == 0) 73 97 ERROR("CObjectFactory::GetObject(const StdString & id)", 74 98 << "[ id = " << id << " ] please define current context id !"); … … 77 101 << "[ id = " << id << ", U = " << U::GetName() << " ] " 78 102 << "object was not found."); 79 return ( U::AllMapObj[CObjectFactory::CurrContext][id]);103 return (*U::AllMapObj)[*CObjectFactory::CurrContext_ptr][id]; 80 104 } 81 105 … … 83 107 boost::shared_ptr<U> CObjectFactory::GetObject(const StdString & context, const StdString & id) 84 108 { 109 if(U::AllMapObj == NULL) return (boost::shared_ptr<U>()); 110 85 111 if (!CObjectFactory::HasObject<U>(context,id)) 86 112 ERROR("CObjectFactory::GetObject(const StdString & id)", 87 113 << "[ id = " << id << ", U = " << U::GetName() <<", context = "<<context<< " ] " 88 114 << "object was not found."); 89 return (U::AllMapObj[context][id]); 115 116 return (*U::AllMapObj)[context][id]; 90 117 } 91 118 … … 93 120 boost::shared_ptr<U> CObjectFactory::CreateObject(const StdString& id) 94 121 { 95 if (CurrContext.empty()) 122 if(U::AllVectObj == NULL) U::AllVectObj = new xios_map<StdString, std::vector<boost::shared_ptr<U> > >; 123 if(U::AllMapObj == NULL) U::AllMapObj = new xios_map<StdString, xios_map<StdString, boost::shared_ptr<U> > >; 124 125 126 if (CurrContext_ptr->empty()) 96 127 ERROR("CObjectFactory::CreateObject(const StdString& id)", 97 128 << "[ id = " << id << " ] please define current context id !"); … … 105 136 boost::shared_ptr<U> value(new U(id.empty() ? CObjectFactory::GenUId<U>() : id)); 106 137 107 U::AllVectObj[CObjectFactory::CurrContext].insert(U::AllVectObj[CObjectFactory::CurrContext].end(), value);108 U::AllMapObj[CObjectFactory::CurrContext].insert(std::make_pair(value->getId(), value));138 (* U::AllVectObj)[*CObjectFactory::CurrContext_ptr].insert((*U::AllVectObj)[*CObjectFactory::CurrContext_ptr].end(), value); 139 (* U::AllMapObj) [*CObjectFactory::CurrContext_ptr].insert(std::make_pair(value->getId(), value)); 109 140 110 141 return value; … … 116 147 CObjectFactory::GetObjectVector(const StdString & context) 117 148 { 118 return (U::AllVectObj[context]); 149 if(U::AllVectObj != NULL) 150 151 return (*U::AllVectObj)[context]; 119 152 } 120 153 … … 130 163 { 131 164 StdOStringStream oss; 132 oss << GetUIdBase<U>() << U::GenId[CObjectFactory::CurrContext]++; 165 if(U::GenId == NULL) U::GenId = new xios_map< StdString, long int >; 166 oss << GetUIdBase<U>() << (*U::GenId)[*CObjectFactory::CurrContext_ptr]++; 133 167 return oss.str(); 134 168 }
Note: See TracChangeset
for help on using the changeset viewer.