Changeset 91 for XMLIO_V2/dev/dev_rv/xmlio_object_template.hpp
- Timestamp:
- 06/03/10 12:24:27 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XMLIO_V2/dev/dev_rv/xmlio_object_template.hpp
r88 r91 24 24 // Ajout d'un nouvel objet si l'identifiant n'est pas répertorié. 25 25 T identified_object(_id); 26 ObjectTemplate<T>:: CurrListObj.addObject(identified_object);26 ObjectTemplate<T>::AllListObj[CurrContext].addObject(identified_object); 27 27 ObjectTemplate<T>::GetObject(_id).registerAllAttributes(); 28 28 return (ObjectTemplate<T>::GetObject(_id)); … … 35 35 } 36 36 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]); } 39 39 40 static const StrHashMap<T> GetCurrentListObject(void) { return (CurrListObj); } 40 static bool HasObject(const string _id) 41 { return (ObjectTemplate<T>::AllListObj[CurrContext].hasMappedValue(_id)); } 41 42 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; } 43 47 44 48 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_TEST68 69 49 70 50 virtual ~ObjectTemplate(void) … … 79 59 80 60 private : 81 static StrHashMap<T> CurrListObj; 61 62 static string CurrContext; 63 static HashMap<string, StrHashMap<T> > AllListObj; 82 64 83 65 };// class ObjectTemplate 84 66 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; 86 69 87 70 }// namespace XMLIOSERVER
Note: See TracChangeset
for help on using the changeset viewer.