XMLIOSERVER 0.4
Serveur d'Entrées/Sorties parallèles
|
00001 /* ************************************************************************** * 00002 * Copyright © IPSL/LSCE, XMLIOServer, Avril 2010 - Octobre 2011 * 00003 * ************************************************************************** */ 00004 00013 #ifndef __XIOS_NO_EXTERN 00014 00015 // Boost headers 00016 #include <boost/none.hpp> 00017 00018 #endif // __XIOS_NO_EXTERN 00019 00020 // XMLIOServer headers 00021 #include "xmlioserver_spl.hpp" 00022 #include "object.hpp" 00023 00024 // /////////////////////////////// Définitions ////////////////////////////// // 00025 00026 namespace xmlioserver { 00027 00028 // ------------------------------ Constructeurs ----------------------------- 00029 00030 //- Constructeur simple d'un objet anonyme (ie sans identifiant). 00031 CObject::CObject(void) : id() 00032 { /* Ne rien faire de plus */ } 00033 00034 //- Constructeur simple d'un objet identifié. 00035 CObject::CObject(const std::string & id) : id(id) 00036 { /* Ne rien faire de plus */ } 00037 00038 //- Constructeur par copie. 00039 CObject::CObject(const CObject & object) 00040 : id(object.id) 00041 { /* Ne rien faire de plus */ } 00042 00043 // ------------------------------- Destructeur ------------------------------ 00044 00045 //- Destructeur de l'objet. 00046 CObject::~CObject(void) 00047 { /* Ne rien faire de plus */ } 00048 00049 // ------------------------------- Accesseurs ------------------------------- 00050 00051 //- Retourne l'identifiant de l'objet. 00052 const std::string & CObject::getId(void) const 00053 { 00054 return (this->id.get()); 00055 } 00056 00057 // --------------------------- Tests sur l'objet ---------------------------- 00058 00059 //- Indique si l'objet est identifié. 00060 bool CObject::hasId(void) const 00061 { 00062 return (this->id); 00063 } 00064 00065 // ------------------------------- Mutateurs -------------------------------- 00066 00067 //- Supprime l'identifiant de l'objet, rendant ce dernier anonyme. 00068 void CObject::resetId(void) 00069 { 00070 this->id = boost::none; 00071 } 00072 00073 //- Assigne un identifiant à l'objet courant. 00074 void CObject::setId(const std::string & id) 00075 { 00076 this->id = id ; 00077 } 00078 00079 // ----------------------- Opérateurs de comparaison ------------------------ 00080 00081 //- Indique si deux objets sont identiques. 00082 bool CObject::operator==(const CObject & other) const 00083 { 00084 if(!this->hasId() || !other.hasId()) return (false); 00085 return (this->id.get().compare(other.id.get()) == 0); 00086 } 00087 00088 //- Indique si deux objets sont différents. 00089 bool CObject::operator!=(const CObject & other) const 00090 { 00091 return (!(*this == other)); 00092 } 00093 00094 // --------------------------- Flux de sortie ------------------------------- 00095 00096 //- Opérateur de flux de sortie ascii. 00097 std::ostream & operator << (std::ostream & _os, const CObject & _object) 00098 { 00099 _os << _object.toString(); 00100 return (_os); 00101 } 00102 00103 } // namespace xmlioserver