casa
$Rev:20696$
|
00001 /* 00002 * ALMA - Atacama Large Millimeter Array 00003 * (c) European Southern Observatory, 2002 00004 * (c) Associated Universities Inc., 2002 00005 * Copyright by ESO (in the framework of the ALMA collaboration), 00006 * Copyright by AUI (in the framework of the ALMA collaboration), 00007 * All rights reserved. 00008 * 00009 * This library is free software; you can redistribute it and/or 00010 * modify it under the terms of the GNU Lesser General Public 00011 * License as published by the Free software Foundation; either 00012 * version 2.1 of the License, or (at your option) any later version. 00013 * 00014 * This library is distributed in the hope that it will be useful, 00015 * but WITHOUT ANY WARRANTY, without even the implied warranty of 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00017 * Lesser General Public License for more details. 00018 * 00019 * You should have received a copy of the GNU Lesser General Public 00020 * License along with this library; if not, write to the Free Software 00021 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 00022 * MA 02111-1307 USA 00023 * 00024 * File EntityId.h 00025 */ 00026 00027 #ifndef EntityId_CLASS 00028 #define EntityId_CLASS 00029 00030 #include <iostream> 00031 #include <string> 00032 using namespace std; 00033 00034 #ifndef WITHOUT_ACS 00035 #include <asdmIDLTypesC.h> 00036 using asdmIDLTypes::IDLEntityId; 00037 #endif 00038 00039 #include <StringTokenizer.h> 00040 #include <InvalidArgumentException.h> 00041 using asdm::StringTokenizer; 00042 using asdm::InvalidArgumentException; 00043 00044 #include "EndianStream.h" 00045 using asdm::EndianOSStream; 00046 using asdm::EndianIStream; 00047 00048 namespace asdm { 00049 00050 class EntityId; 00051 ostream & operator << ( ostream &, const EntityId & ); 00052 istream & operator >> ( istream &, EntityId&); 00053 00062 class EntityId { 00063 friend ostream & operator << ( ostream &, const EntityId & ); 00064 friend istream & operator >> ( istream &, EntityId&); 00065 00066 public: 00067 static EntityId getEntityId(StringTokenizer &t) 00068 throw (InvalidArgumentException) ; 00069 static string validate(string x); 00070 00071 EntityId(); 00072 EntityId(const EntityId &); 00073 EntityId(const string &id) throw (InvalidArgumentException); 00074 #ifndef WITHOUT_ACS 00075 EntityId(IDLEntityId &) throw (InvalidArgumentException); 00076 #endif 00077 virtual ~EntityId(); 00078 00079 EntityId& operator = (const EntityId &); 00080 00081 bool equals(const EntityId &) const; 00082 bool operator == (const EntityId&) const; 00083 bool operator != (const EntityId&) const; 00084 00085 string toString() const; 00086 #ifndef WITHOUT_ACS 00087 IDLEntityId toIDLEntityId() const; 00088 #endif 00089 00093 void toBin(EndianOSStream& eoss) const; 00094 00102 static EntityId fromBin(EndianIStream& eis); 00103 00104 bool isNull() const; 00105 00106 string getId() const; 00107 void setId(string e); 00108 00109 private: 00110 string id; 00111 00112 }; 00113 00114 // EntityId constructors 00115 inline EntityId::EntityId() : id("") { } 00116 00117 inline EntityId::EntityId(const EntityId &t) : id(t.id) { } 00118 00119 // EntityId destructor 00120 inline EntityId::~EntityId() { } 00121 00122 inline EntityId& EntityId::operator = ( const EntityId &x ) { 00123 id = x.id; 00124 return *this; 00125 } 00126 00127 inline bool EntityId::isNull() const { 00128 return id.length() == 0; 00129 } 00130 00131 inline bool EntityId::equals(const EntityId &x) const { 00132 return id == x.id; 00133 } 00134 00135 inline bool EntityId::operator == (const EntityId &x) const { 00136 return id == x.id; 00137 } 00138 00139 inline bool EntityId::operator != (const EntityId &x) const { 00140 return id != x.id; 00141 } 00142 00143 inline string EntityId::toString() const { 00144 return id; 00145 } 00146 00147 #ifndef WITHOUT_ACS 00148 inline IDLEntityId EntityId::toIDLEntityId() const { 00149 IDLEntityId x; 00150 x.value = CORBA::string_dup(id.c_str()); 00151 return x; 00152 } 00153 #endif 00154 00155 inline string EntityId::getId() const { 00156 return id; 00157 } 00158 00159 inline void EntityId::setId(string s) { 00160 id = s; 00161 } 00162 00163 // Friend functions 00164 00165 inline ostream & operator << ( ostream &o, const EntityId &x ) { 00166 o << x.id; 00167 return o; 00168 } 00169 00170 inline istream & operator >> ( istream &i, EntityId &x ) { 00171 i >> x.id; 00172 return i; 00173 } 00174 00175 } // End namespace asdm 00176 00177 #endif /* EntityId_CLASS */