00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
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
00125 inline EntityRef::EntityRef(const string &s) {
00126 setFromXML(s);
00127 }
00128
00129
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
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
00179
00180 inline ostream & operator << ( ostream &o, const EntityRef &x ) {
00181 o << x.toXML();
00182 return o;
00183 }
00184
00185 }
00186
00187 #endif