Ignore:
Timestamp:
05/16/17 17:54:30 (7 years ago)
Author:
yushan
Message:

branch merged with trunk r1130

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/branch_yushan_merged/src/object_factory_impl.hpp

    r769 r1134  
    1010       int CObjectFactory::GetObjectNum(void) 
    1111   { 
    12       if (CurrContext.size() == 0) 
     12      if (CurrContext_ptr->size() == 0) 
    1313         ERROR("CObjectFactory::GetObjectNum(void)", 
    1414               << "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(); 
    1620   } 
    1721 
     
    1923      int CObjectFactory::GetObjectIdNum(void) 
    2024   { 
    21       if (CurrContext.size() == 0) 
     25      if (CurrContext_ptr->size() == 0) 
    2226         ERROR("CObjectFactory::GetObjectIdNum(void)", 
    2327               << "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(); 
    2533   } 
    2634 
     
    2836      bool CObjectFactory::HasObject(const StdString & id) 
    2937   { 
    30       if (CurrContext.size() == 0) 
     38      if (CurrContext_ptr->size() == 0) 
    3139         ERROR("CObjectFactory::HasObject(const StdString & id)", 
    3240               << "[ 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()); 
    3548   } 
    3649 
     
    3851      bool CObjectFactory::HasObject(const StdString & context, const StdString & id) 
    3952   { 
    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          
    4262   } 
    4363 
     
    4565      boost::shared_ptr<U> CObjectFactory::GetObject(const U * const object) 
    4666   { 
    47       if (CurrContext.size() == 0) 
     67      if(U::AllVectObj == NULL) return (boost::shared_ptr<U>()); 
     68    
     69      if (CurrContext_ptr->size() == 0) 
    4870         ERROR("CObjectFactory::GetObject(const U * const object)", 
    4971               << "please define current context id !"); 
    5072      std::vector<boost::shared_ptr<U> > & vect = 
    51                      U::AllVectObj[CObjectFactory::CurrContext]; 
     73                     (*U::AllVectObj)[*CObjectFactory::CurrContext_ptr]; 
    5274 
    5375      typename std::vector<boost::shared_ptr<U> >::const_iterator 
     
    7092      boost::shared_ptr<U> CObjectFactory::GetObject(const StdString & id) 
    7193   { 
    72       if (CurrContext.size() == 0) 
     94      if(U::AllMapObj  == NULL) return (boost::shared_ptr<U>()); 
     95 
     96      if (CurrContext_ptr->size() == 0) 
    7397         ERROR("CObjectFactory::GetObject(const StdString & id)", 
    7498               << "[ id = " << id << " ] please define current context id !"); 
     
    77101               << "[ id = " << id << ", U = " << U::GetName() << " ] " 
    78102               << "object was not found."); 
    79       return (U::AllMapObj[CObjectFactory::CurrContext][id]); 
     103      return (*U::AllMapObj)[*CObjectFactory::CurrContext_ptr][id]; 
    80104   } 
    81105 
     
    83107      boost::shared_ptr<U> CObjectFactory::GetObject(const StdString & context, const StdString & id) 
    84108   { 
     109      if(U::AllMapObj  == NULL) return (boost::shared_ptr<U>()); 
     110 
    85111      if (!CObjectFactory::HasObject<U>(context,id)) 
    86112         ERROR("CObjectFactory::GetObject(const StdString & id)", 
    87113               << "[ id = " << id << ", U = " << U::GetName() <<", context = "<<context<< " ] " 
    88114               << "object was not found."); 
    89       return (U::AllMapObj[context][id]); 
     115 
     116      return (*U::AllMapObj)[context][id]; 
    90117   } 
    91118 
     
    93120   boost::shared_ptr<U> CObjectFactory::CreateObject(const StdString& id) 
    94121   { 
    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()) 
    96127         ERROR("CObjectFactory::CreateObject(const StdString& id)", 
    97128               << "[ id = " << id << " ] please define current context id !"); 
     
    105136         boost::shared_ptr<U> value(new U(id.empty() ? CObjectFactory::GenUId<U>() : id)); 
    106137 
    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)); 
    109140 
    110141         return value; 
     
    116147         CObjectFactory::GetObjectVector(const StdString & context) 
    117148   { 
    118       return (U::AllVectObj[context]); 
     149      if(U::AllVectObj != NULL)  
     150       
     151      return (*U::AllVectObj)[context]; 
    119152   } 
    120153 
     
    130163   { 
    131164      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]++; 
    133167      return oss.str(); 
    134168   } 
Note: See TracChangeset for help on using the changeset viewer.