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

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

Mise à jour intermédiaire ...
A venir : commit d'une version stable intégrant l'écriture de fichiers NetCDF4.
(en cours de finalisation actuellement)

File size: 1.5 KB
Line 
1#ifndef __XMLIO_OBJECT__
2#define __XMLIO_OBJECT__
3
4namespace XMLIOSERVER
5{
6   class AbstractObject
7   {
8      public :
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
36         AbstractObject(void) : IdDefined(false)
37         {/* Ne rien faire de plus */}
38
39         AbstractObject(const std::string& _id) : id(_id), IdDefined(true)
40         {/* Ne rien faire de plus */}
41
42      private :
43
44         std::string id ;
45         bool IdDefined ;
46
47   };// class AbstractObject
48
49}// namespace XMLIOSERVER
50
51#endif // __XMLIO_OBJECT__
Note: See TracBrowser for help on using the repository browser.