Ignore:
Timestamp:
06/03/10 12:24:27 (14 years ago)
Author:
hozdoba
Message:

Corrections de plusieurs problÚmes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XMLIO_V2/dev/dev_rv/xmlio_object_template.hpp

    r88 r91  
    2424            // Ajout d'un nouvel objet si l'identifiant n'est pas répertorié. 
    2525            T identified_object(_id); 
    26             ObjectTemplate<T>::CurrListObj.addObject(identified_object); 
     26            ObjectTemplate<T>::AllListObj[CurrContext].addObject(identified_object); 
    2727            ObjectTemplate<T>::GetObject(_id).registerAllAttributes(); 
    2828            return (ObjectTemplate<T>::GetObject(_id)); 
     
    3535         } 
    3636          
    37          static T& GetObject(const string _id) throw (XMLIOUndefinedValueException) { return (ObjectTemplate<T>::CurrListObj[_id]); } 
    38          static bool HasObject(const string _id) { return (ObjectTemplate<T>::CurrListObj.hasMappedValue(_id)); } 
     37         static T& GetObject(const string _id) throw (XMLIOUndefinedValueException) 
     38         { return (ObjectTemplate<T>::AllListObj[CurrContext][_id]); } 
    3939          
    40          static const StrHashMap<T> GetCurrentListObject(void) { return (CurrListObj); } 
     40         static bool HasObject(const string _id) 
     41         { return (ObjectTemplate<T>::AllListObj[CurrContext].hasMappedValue(_id)); } 
    4142          
    42          virtual void registerAllAttributes(void) {}; 
     43         static const StrHashMap<T> GetCurrentListObject(void) { return (AllListObj[CurrContext]); } 
     44                 
     45         static void SetContext(const string& id) 
     46         { ObjectTemplate<T>::CurrContext = id; }  
    4347          
    4448         virtual const char* getName(void) const {return ("ObjectTemplate"); } 
    45           
    46          /// POUR TESTS /// 
    47           
    48 #define   OBJECTTEMPLATE_TEST(DESC, SIZE, VECTORSIZE) \ 
    49          if(ObjectTemplate<T>::CurrListObj.getSize() != SIZE or ObjectTemplate<T>::CurrListObj.getVectorSize() != VECTORSIZE) \ 
    50          { log << "Test de la classe ObjectTemplate > " << DESC << "... echec !" << std::endl; return (false); } 
    51              
    52          static bool CLASS_TEST(ostream& log = std::clog) 
    53          { 
    54             //////////////////////////////////////////////////////////////////// 
    55             T& obj0= ObjectTemplate<T>::CreateObject("toto"); 
    56             T& obj1= ObjectTemplate<T>::CreateObject("tata"); 
    57             OBJECTTEMPLATE_TEST("Ajout d'objets identifiés au conteneur", 2, 2); 
    58             T& obj2= ObjectTemplate<T>::CreateObject("tata"); 
    59             OBJECTTEMPLATE_TEST("Ajout d'objets identifiés déjà existants au conteneur", 2, 2);             
    60             T& obj3= ObjectTemplate<T>::CreateObject(); 
    61             OBJECTTEMPLATE_TEST("Ajout d'objets non-identifiés au conteneur", 2, 3); 
    62             //////////////////////////////////////////////////////////////////// 
    63              
    64             log << "Test  ObjectTemplate ... ok !" << std::endl; 
    65             return (true);       
    66          };    
    67 #undef   OBJECTTEMPLATE_TEST 
    68           
    6949          
    7050         virtual ~ObjectTemplate(void) 
     
    7959          
    8060      private : 
    81          static StrHashMap<T> CurrListObj; 
     61          
     62         static string CurrContext; 
     63         static HashMap<string, StrHashMap<T> > AllListObj; 
    8264       
    8365   };// class ObjectTemplate 
    8466    
    85    template <class T> StrHashMap<T> ObjectTemplate<T>::CurrListObj ; 
     67   template <class T> string ObjectTemplate<T>::CurrContext ; 
     68   template <class T> HashMap<string, StrHashMap<T> > ObjectTemplate<T>::AllListObj; 
    8669    
    8770}// namespace XMLIOSERVER 
Note: See TracChangeset for help on using the changeset viewer.