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 if (!this->hasId()) 00055 XIOS_ERROR("undefined_object_id", 00056 << " L'identifiant de l'objet est requis mais n'est pas défini !"); 00057 return (this->id.get()); 00058 } 00059 00060 // --------------------------- Tests sur l'objet ---------------------------- 00061 00062 //- Indique si l'objet est identifié. 00063 bool CObject::hasId(void) const 00064 { 00065 return (!this->id); 00066 } 00067 00068 // ------------------------------- Mutateurs -------------------------------- 00069 00070 //- Supprime l'identifiant de l'objet, rendant ce dernier anonyme. 00071 void CObject::resetId(void) 00072 { 00073 this->id = boost::none; 00074 } 00075 00076 //- Assigne un identifiant à l'objet courant. 00077 void CObject::setId(const std::string & id) 00078 { 00079 this->id = id ; 00080 } 00081 00082 // ----------------------- Opérateurs de comparaison ------------------------ 00083 00084 //- Indique si deux objets sont identiques. 00085 bool CObject::operator==(const CObject & other) const 00086 { 00087 if(!this->hasId() || !other.hasId()) return (false); 00088 return (this->id.get().compare(other.id.get()) == 0); 00089 } 00090 00091 //- Indique si deux objets sont différents. 00092 bool CObject::operator!=(const CObject & other) const 00093 { 00094 return (!(*this == other)); 00095 } 00096 00097 // --------------------------- Flux de sortie ------------------------------- 00098 00099 //- Opérateur de flux de sortie ascii. 00100 std::ostream & operator << (std::ostream & _os, const CObject & _object) 00101 { 00102 _os << _object.toString(); 00103 return (_os); 00104 } 00105 00106 } // namespace xmlioserver