Entity.h

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 Entity.h 00025 */ 00026 00027 #ifndef Entity_CLASS 00028 #define Entity_CLASS 00029 00030 #include <iostream> 00031 #include <string> 00032 using namespace std; 00033 00034 #ifndef WITHOUT_ACS 00035 #include <asdmIDLTypesC.h> 00036 using asdmIDLTypes::IDLEntity; 00037 #endif 00038 00039 #include <EntityId.h> 00040 00041 #include <StringTokenizer.h> 00042 #include <InvalidArgumentException.h> 00043 #include <InvalidDataException.h> 00044 using asdm::StringTokenizer; 00045 using asdm::InvalidArgumentException; 00046 using asdm::InvalidDataException; 00047 00048 #include "EndianStream.h" 00049 using asdm::EndianOSStream; 00050 using asdm::EndianISStream; 00051 00052 namespace asdm { 00053 00054 class Entity; 00055 ostream & operator << ( ostream &, const Entity & ); 00056 00065 class Entity { 00066 friend ostream & operator << ( ostream &, const Entity & ); 00067 friend istream & operator >> ( istream &, Entity&); 00068 00069 public: 00070 static Entity getEntity(StringTokenizer &t) throw(InvalidArgumentException); 00071 00072 Entity(); 00073 Entity(const string &s); 00074 #ifndef WITHOUT_ACS 00075 Entity(IDLEntity &); 00076 #endif 00077 Entity(string entityId, string entityIdEncrypted, string entityTypeName, 00078 string entityVersion, string instanceVersion); 00079 virtual ~Entity(); 00080 00081 bool operator == (const Entity &) const; 00082 bool equals(const Entity &) const; 00083 bool operator != (const Entity &) const; 00084 00085 bool isNull() const; 00086 00087 string toString() const; 00088 string toXML() const throw(InvalidDataException); 00089 #ifndef WITHOUT_ACS 00090 IDLEntity toIDLEntity() const; 00091 #endif 00092 void setFromXML(string xml) throw(InvalidArgumentException); 00093 00097 void toBin(EndianOSStream& eoss); 00098 00105 static Entity fromBin(EndianISStream& eiss); 00106 00107 EntityId getEntityId() const; 00108 string getEntityIdEncrypted() const; 00109 string getEntityTypeName() const; 00110 string getEntityVersion() const; 00111 string getInstanceVersion() const; 00112 void setEntityId(EntityId e); 00113 void setEntityIdEncrypted(string s); 00114 void setEntityTypeName(string s); 00115 void setEntityVersion(string s); 00116 void setInstanceVersion(string s); 00117 00118 private: 00119 EntityId entityId; 00120 string entityIdEncrypted; 00121 string entityTypeName; 00122 string entityVersion; 00123 string instanceVersion; 00124 00125 string getXMLValue(string xml, string parm) const; 00126 string validXML() const; 00127 00128 }; 00129 00130 // Entity constructors 00131 inline Entity::Entity(const string &s) { 00132 setFromXML(s); 00133 } 00134 00135 // Entity destructor 00136 inline Entity::~Entity() { } 00137 00138 inline bool Entity::isNull() const { 00139 return entityId.isNull(); 00140 } 00141 00142 inline string Entity::toString() const { 00143 return toXML(); 00144 } 00145 00146 inline bool Entity::equals(const Entity &x) const { 00147 return *this == x; 00148 } 00149 00150 // Getters and Setters 00151 00152 inline EntityId Entity::getEntityId() const { 00153 return entityId; 00154 } 00155 00156 inline string Entity::getEntityIdEncrypted() const { 00157 return entityIdEncrypted; 00158 } 00159 00160 inline string Entity::getEntityTypeName() const { 00161 return entityTypeName; 00162 } 00163 00164 inline string Entity::getEntityVersion() const { 00165 return entityVersion; 00166 } 00167 00168 inline string Entity::getInstanceVersion() const { 00169 return instanceVersion; 00170 } 00171 00172 inline void Entity::setEntityId(EntityId e) { 00173 entityId = e; 00174 } 00175 00176 inline void Entity::setEntityIdEncrypted(string s) { 00177 entityIdEncrypted = s; 00178 } 00179 00180 inline void Entity::setEntityTypeName(string s) { 00181 entityTypeName = s; 00182 } 00183 00184 inline void Entity::setEntityVersion(string s) { 00185 entityVersion = s; 00186 } 00187 00188 inline void Entity::setInstanceVersion(string s) { 00189 instanceVersion = s; 00190 } 00191 00192 // Friend functions 00193 00194 inline ostream & operator << ( ostream &o, const Entity &x ) { 00195 o << x.toXML(); 00196 return o; 00197 } 00198 00199 } // End namespace asdm 00200 00201 #endif /* Entity_CLASS */

Generated on Tue Nov 18 17:43:40 2008 for ASDM C++ Implementation by doxygen 1.3.8