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

Generated on Thu Nov 29 16:46:46 2007 for ASDM C++ Implementation by  doxygen 1.5.1