casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EntityRef.h
Go to the documentation of this file.
1 /*
2  * ALMA - Atacama Large Millimeter Array
3  * (c) European Southern Observatory, 2002
4  * (c) Associated Universities Inc., 2002
5  * Copyright by ESO (in the framework of the ALMA collaboration),
6  * Copyright by AUI (in the framework of the ALMA collaboration),
7  * All rights reserved.
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY, without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
22  * MA 02111-1307 USA
23  *
24  * File EntityRef.h
25  */
26 
27 #ifndef EntityRef_CLASS
28 #define EntityRef_CLASS
29 
30 #include <iostream>
31 #include <string>
32 #include <vector>
33 
34 #include <alma/ASDM/EntityId.h>
35 #include <alma/ASDM/PartId.h>
36 
37 #ifndef WITHOUT_ACS
38 #include <asdmIDLTypesC.h>
39 #endif
40 
44 
45 namespace asdm {
46 
47 class EntityRef;
48 std::ostream & operator << ( std::ostream &, const EntityRef & );
49 
58 class EntityRef {
59  friend std::ostream & operator << ( std::ostream &, const EntityRef & );
60 
61 public:
63 
64  EntityRef();
65  EntityRef(const std::string &s);
66 #ifndef WITHOUT_ACS
67  EntityRef(asdmIDLTypes::IDLEntityRef &);
68 #endif
69  EntityRef(std::string entityId, std::string partId, std::string entityTypeName,
70  std::string instanceVersion);
71  virtual ~EntityRef();
72 
73  bool operator == (const EntityRef &) const;
74  bool equals(const EntityRef &) const;
75  bool operator != (const EntityRef &) const;
76 
77  bool isNull() const;
78 
79  std::string toString() const;
80  std::string toXML() const throw(InvalidDataException);
81 #ifndef WITHOUT_ACS
82  asdmIDLTypes::IDLEntityRef toIDLEntityRef() const;
83 #endif
84  void setFromXML(std::string xml) ;
85 
89  void toBin(EndianOSStream& eoss) const ;
90 
94  static void toBin(const std::vector<EntityRef>& entityRef, EndianOSStream& eoss);
95 
102  static EntityRef fromBin(EndianIStream& eis);
109  static std::vector<EntityRef> from1DBin(EndianIStream & eis);
110 
111  EntityId getEntityId() const;
112  PartId getPartId() const;
113  std::string getEntityTypeName() const;
114  std::string getInstanceVersion() const;
115  void setEntityId(EntityId e);
116  void setPartId(PartId s);
117  void setEntityTypeName(std::string s);
118  void setInstanceVersion(std::string s);
119 
120 private:
123  std::string entityTypeName;
124  std::string instanceVersion;
125 
126  std::string getXMLValue(std::string xml, std::string parm) const;
127  std::string validXML() const;
128 
129 };
130 
131 // EntityRef constructors
132 inline EntityRef::EntityRef(const std::string &s) {
133  setFromXML(s);
134 }
135 
136 // EntityRef destructor
138 
139 inline bool EntityRef::isNull() const {
140  return entityId.isNull();
141 }
142 
143 inline std::string EntityRef::toString() const {
144  return toXML();
145 }
146 
147 inline bool EntityRef::equals(const EntityRef &x) const {
148  return *this == x;
149 }
150 
151 // Getters and Setters
152 
154  return entityId;
155 }
156 
157 inline PartId EntityRef::getPartId() const {
158  return partId;
159 }
160 
161 inline std::string EntityRef::getEntityTypeName() const {
162  return entityTypeName;
163 }
164 
165 inline std::string EntityRef::getInstanceVersion() const {
166  return instanceVersion;
167 }
168 
170  entityId = e;
171 }
172 
173 inline void EntityRef::setPartId(PartId p) {
174  partId = p;
175 }
176 
177 inline void EntityRef::setEntityTypeName(std::string s) {
178  entityTypeName = s;
179 }
180 
181 inline void EntityRef::setInstanceVersion(std::string s) {
182  instanceVersion = s;
183 }
184 
185 // Friend functions
186 
187 inline std::ostream & operator << ( std::ostream &o, const EntityRef &x ) {
188  o << x.toXML();
189  return o;
190 }
191 
192 } // End namespace asdm
193 
194 #endif /* EntityRef_CLASS */
asdmIDLTypes::IDLEntityRef toIDLEntityRef() const
EntityId entityId
Definition: EntityRef.h:121
std::string entityTypeName
Definition: EntityRef.h:123
bool equals(const EntityRef &) const
Definition: EntityRef.h:147
The InvalidDataException class represents an exception when an error occurs in converting a numeric v...
std::string validXML() const
std::string toXML() const
void setInstanceVersion(std::string s)
Definition: EntityRef.h:181
std::string getXMLValue(std::string xml, std::string parm) const
The StringTokenizer class is a translation into C++ of the Java class of the same name in Java&#39;s util...
void setPartId(PartId s)
Definition: EntityRef.h:173
static EntityRef getEntityRef(StringTokenizer &t)
static std::vector< EntityRef > from1DBin(EndianIStream &eis)
Read the binary representation of a vector of EntityRef from an EndianIStream and use the read value ...
void setFromXML(std::string xml)
The EntityRef class is an identification of a persistant entity in the ALMA archive.
Definition: EntityRef.h:58
bool operator!=(const EntityRef &) const
bool isNull() const
Definition: EntityRef.h:139
std::string instanceVersion
Definition: EntityRef.h:124
virtual ~EntityRef()
EntityRef destructor.
Definition: EntityRef.h:137
std::ostream & operator<<(std::ostream &, const EntityId &)
Friend functions.
Definition: EntityId.h:159
friend std::ostream & operator<<(std::ostream &, const EntityRef &)
Friend functions.
void setEntityTypeName(std::string s)
Definition: EntityRef.h:177
description
Definition: PartId.h:44
bool isNull() const
Definition: EntityId.h:121
EntityId getEntityId() const
Getters and Setters.
Definition: EntityRef.h:153
std::string getEntityTypeName() const
Definition: EntityRef.h:161
void setEntityId(EntityId e)
Definition: EntityRef.h:169
void toBin(EndianOSStream &eoss) const
Write the binary representation of this to a EndianOSStream.
The InvalidArgumentException class represents an exception when an attempt is made to access somethin...
std::string toString() const
Definition: EntityRef.h:143
const Double e
e and functions thereof:
PartId getPartId() const
Definition: EntityRef.h:157
std::string getInstanceVersion() const
Definition: EntityRef.h:165
description
Definition: EntityId.h:56
static EntityRef fromBin(EndianIStream &eis)
Read the binary representation of an EntityRef from a EndianIStream and use the read value to set an ...
bool operator==(const EntityRef &) const