Changeset 120 for XMLIO_V2/dev/dev_rv/src/XMLIO/abstract_object.hpp
- Timestamp:
- 09/08/10 15:02:31 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XMLIO_V2/dev/dev_rv/src/XMLIO/abstract_object.hpp
r112 r120 1 1 #ifndef __XMLIO_OBJECT__ 2 #define __XMLIO_OBJECT__ 3 4 // Classes utilisées issues de la STL 5 using std::pair; 6 using std::string; 7 using std::ostream; 8 using std::ostringstream; 9 10 // Classes XMLIOSERVER 11 using XMLIOSERVER::XMLIOException; 12 using XMLIOSERVER::XMLIOUndefinedValueException; 2 #define __XMLIO_OBJECT__ 13 3 14 4 namespace XMLIOSERVER 15 5 { 16 class AbstractObject 6 class AbstractObject 17 7 { 18 8 public : 19 9 10 const std::string& getId(void) const throw (XMLIOUndefinedValueException) 11 { 12 if (!hasId()) // Si l'identifiant de l'objet n'est pas défini. 13 throw XMLIOSERVER::XMLIOUndefinedValueException("Appel de la méthode AbstractObject::getId invalide."); 14 return (id); 15 } 16 17 bool hasId(void) const { return(IdDefined); } 18 void resetId(void) { IdDefined = false ;} 19 void setId(const std::string& _id) { id = _id ; IdDefined = true ;} 20 21 bool operator==(const AbstractObject& other) const 22 { 23 // Si l'un ou l'autre des objets n'a pas d'identifiant, les objets ne sont pas "égaux". 24 if(!this->hasId() || !other.hasId()) return false; 25 return (id.compare(other.id) == 0); 26 } 27 28 std::string printId(void) const 29 { if(hasId()) return (" id=\""+getId()+"\""); return (""); } 30 31 virtual ~AbstractObject(void) 32 {/* Ne rien faire de plus */} 33 34 protected : 35 20 36 AbstractObject(void) : IdDefined(false) 21 37 {/* Ne rien faire de plus */} 22 23 AbstractObject(const string& _id) : id(_id), IdDefined(true) 24 {/* Ne rien faire de plus */} 25 26 const string& getId(void) const throw (XMLIOUndefinedValueException) 27 { if (!IdDefined) throw XMLIOUndefinedValueException("Appel de la méthode AbstractObject::getId invalide."); return (id); } 28 29 bool hasId(void) const { return(IdDefined); } 30 void resetId(void) { IdDefined = false ;} 31 void setId(const string& _id) { id = _id ; IdDefined = true ;} 32 33 bool operator==(const AbstractObject& other) 34 { 35 // Si l'un ou l'autre des objets n'a pas d'identifiant, les objets ne sont pas "égaux". 36 if(!this->hasId() or !other.hasId()) return false; 37 return (id.compare(other.id) == 0); 38 } 39 40 string printId(void) const 41 { if(hasId()) return (" id=\""+getId()+"\""); return (""); } 42 43 virtual ~AbstractObject(void) 38 39 AbstractObject(const std::string& _id) : id(_id), IdDefined(true) 44 40 {/* Ne rien faire de plus */} 45 46 protected :47 41 48 49 42 private : 50 51 st ring id ;43 44 std::string id ; 52 45 bool IdDefined ; 53 46 54 47 };// class AbstractObject 55 48 56 49 }// namespace XMLIOSERVER 57 50 58 #endif // __XMLIO_OBJECT__ 51 #endif // __XMLIO_OBJECT__
Note: See TracChangeset
for help on using the changeset viewer.