Ignore:
Timestamp:
01/23/19 10:31:44 (5 years ago)
Author:
yushan
Message:

dev on ADA. add flag switch _usingEP/_usingMPI

File:
1 edited

Legend:

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

    r1545 r1642  
    1010       int CObjectFactory::GetObjectNum(void) 
    1111   { 
    12       if (CurrContext_ptr->size() == 0) 
     12      if (CurrContext.size() == 0) 
    1313         ERROR("CObjectFactory::GetObjectNum(void)", 
    1414               << "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()); 
    1716   } 
    1817 
     
    2019      int CObjectFactory::GetObjectIdNum(void) 
    2120   { 
    22       if (CurrContext_ptr->size() == 0) 
     21      if (CurrContext.size() == 0) 
    2322         ERROR("CObjectFactory::GetObjectIdNum(void)", 
    2423               << "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()); 
    2725   } 
    2826 
     
    3028      bool CObjectFactory::HasObject(const StdString & id) 
    3129   { 
    32       if (CurrContext_ptr->size() == 0) 
     30      if (CurrContext.size() == 0) 
    3331         ERROR("CObjectFactory::HasObject(const StdString & id)", 
    3432               << "[ 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()); 
    3935   } 
    4036 
     
    4238      bool CObjectFactory::HasObject(const StdString & context, const StdString & id) 
    4339   { 
    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()); 
    4842   } 
    4943 
     
    5145      std::shared_ptr<U> CObjectFactory::GetObject(const U * const object) 
    5246   { 
    53       if(U::AllVectObj_ptr == NULL) return (std::shared_ptr<U>()); 
    54       if (CurrContext_ptr->size() == 0) 
     47      if (CurrContext.size() == 0) 
    5548         ERROR("CObjectFactory::GetObject(const U * const object)", 
    5649               << "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]; 
    5852 
    5953      typename std::vector<std::shared_ptr<U> >::const_iterator 
     
    7670      std::shared_ptr<U> CObjectFactory::GetObject(const StdString & id) 
    7771   { 
    78       if(U::AllMapObj_ptr  == NULL) return (std::shared_ptr<U>()); 
    79       if (CurrContext_ptr->size() == 0) 
     72      if (CurrContext.size() == 0) 
    8073         ERROR("CObjectFactory::GetObject(const StdString & id)", 
    8174               << "[ id = " << id << " ] please define current context id !"); 
     
    8477               << "[ id = " << id << ", U = " << U::GetName() << " ] " 
    8578               << "object was not found."); 
    86       return (*U::AllMapObj_ptr)[*CObjectFactory::CurrContext_ptr][id]; 
     79      return (U::AllMapObj[CObjectFactory::CurrContext][id]); 
    8780   } 
    8881 
     
    9083      std::shared_ptr<U> CObjectFactory::GetObject(const StdString & context, const StdString & id) 
    9184   { 
    92       if(U::AllMapObj_ptr  == NULL) return (std::shared_ptr<U>()); 
    93  
    9485      if (!CObjectFactory::HasObject<U>(context,id)) 
    9586         ERROR("CObjectFactory::GetObject(const StdString & id)", 
    9687               << "[ id = " << id << ", U = " << U::GetName() <<", context = "<<context<< " ] " 
    9788               << "object was not found."); 
    98       return (*U::AllMapObj_ptr)[context][id]; 
     89      return (U::AllMapObj[context][id]); 
    9990   } 
    10091 
     
    10293   std::shared_ptr<U> CObjectFactory::CreateObject(const StdString& id) 
    10394   { 
    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()) 
    10896         ERROR("CObjectFactory::CreateObject(const StdString& id)", 
    10997               << "[ id = " << id << " ] please define current context id !"); 
     
    117105         std::shared_ptr<U> value(new U(id.empty() ? CObjectFactory::GenUId<U>() : id)); 
    118106 
    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)); 
    121109 
    122110         return value; 
     
    128116         CObjectFactory::GetObjectVector(const StdString & context) 
    129117   { 
    130       return (*U::AllVectObj_ptr)[context]; 
     118      return (U::AllVectObj[context]); 
    131119   } 
    132120 
     
    142130   { 
    143131      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]++; 
    146133      return oss.str(); 
    147134   } 
Note: See TracChangeset for help on using the changeset viewer.