source: XMLIO_V2/dev/dev_rv/src/XMLIO/abstract_object.hpp @ 133

Last change on this file since 133 was 126, checked in by hozdoba, 14 years ago

Amélioration de quelques portions de code.
Ajout de contructeurs par copie.

File size: 1.8 KB
RevLine 
[112]1#ifndef __XMLIO_OBJECT__
[120]2#define __XMLIO_OBJECT__
[112]3
4namespace XMLIOSERVER
5{
[120]6   class AbstractObject
[112]7   {
8      public :
[120]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
[126]17         bool hasId(void) const { return (IdDefined); }
18
[112]19         void resetId(void) { IdDefined = false ;}
[120]20
[126]21         void setId(const std::string& _id)
22         { id = _id ; IdDefined = true ; }
23
[120]24         bool operator==(const AbstractObject& other) const
[112]25         {
26            // Si l'un ou l'autre des objets n'a pas d'identifiant, les objets ne sont pas "égaux".
[120]27            if(!this->hasId() || !other.hasId()) return false;
[112]28            return (id.compare(other.id) == 0);
29         }
[120]30
[126]31         bool operator!=(const AbstractObject& other) const
32         { return (!(*this == other)); }
33
[120]34         std::string printId(void) const
[126]35         {
36            if(this->hasId())
37               return (string(" id=\""+getId()+"\""));
38            return (string(""));
39         }
[120]40
[112]41         virtual ~AbstractObject(void)
[126]42         { /* Ne rien faire de plus */ }
[120]43
[112]44      protected :
45
[126]46         AbstractObject(void)
47            : IdDefined(false) // Sans identifiant.
48         { /* Ne rien faire de plus */ }
[120]49
[126]50         AbstractObject(const std::string& _id)
51            : id(_id), IdDefined(true)
52         { /* Ne rien faire de plus */ }
[120]53
[126]54         AbstractObject(const AbstractObject& _ao)
55            : id(_ao.id), IdDefined(_ao.IdDefined)
56         { /* Ne rien faire de plus */ }
57
[112]58      private :
[120]59
60         std::string id ;
[112]61         bool IdDefined ;
[120]62
[112]63   };// class AbstractObject
[120]64
[112]65}// namespace XMLIOSERVER
66
[120]67#endif // __XMLIO_OBJECT__
Note: See TracBrowser for help on using the repository browser.