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

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

Réorganisation du code source (suppression des préfixes xmlio_ redondants)
Simplification de la gestion des groupes (ajout d'une macro dans le fichier d'entête declare_group.hpp).

File size: 1.6 KB
Line 
1#ifndef __XMLIO_OBJECT__
2#define __XMLIO_OBJECT__
3
4// Classes utilisées issues de la STL
5using std::pair;
6using std::string;
7using std::ostream;
8using std::ostringstream;
9
10// Classes XMLIOSERVER
11using XMLIOSERVER::XMLIOException;
12using XMLIOSERVER::XMLIOUndefinedValueException;
13
14namespace XMLIOSERVER
15{
16   class AbstractObject 
17   {
18      public :
19     
20         AbstractObject(void) : IdDefined(false)
21         {/* 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)
44         {/* Ne rien faire de plus */}
45     
46      protected :
47
48           
49      private :
50     
51         string id ;
52         bool IdDefined ;
53     
54   };// class AbstractObject
55   
56}// namespace XMLIOSERVER
57
58#endif // __XMLIO_OBJECT__   
Note: See TracBrowser for help on using the repository browser.