casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EntityId.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 EntityId.h
25  */
26 
27 #ifndef EntityId_CLASS
28 #define EntityId_CLASS
29 
30 #include <iostream>
31 #include <string>
32 
33 #ifndef WITHOUT_ACS
34 #include <asdmIDLTypesC.h>
35 #endif
36 
39 
40 #include <alma/ASDM/EndianStream.h>
41 
42 namespace asdm {
43 
44 class EntityId;
45 std::ostream & operator << ( std::ostream &, const EntityId & );
46 std::istream & operator >> ( std::istream &, EntityId&);
47 
56 class EntityId {
57  friend std::ostream & operator << ( std::ostream &, const EntityId & );
58  friend std::istream & operator >> ( std::istream &, EntityId&);
59 
60 public:
62  throw (InvalidArgumentException) ;
63  static std::string validate(std::string x);
64 
65  EntityId();
66  EntityId(const EntityId &);
67  EntityId(const std::string &id) throw (InvalidArgumentException);
68 #ifndef WITHOUT_ACS
69  EntityId(asdmIDLTypes::IDLEntityId &) throw (InvalidArgumentException);
70 #endif
71  virtual ~EntityId();
72 
73  EntityId& operator = (const EntityId &);
74 
75  bool equals(const EntityId &) const;
76  bool operator == (const EntityId&) const;
77  bool operator != (const EntityId&) const;
78 
79  std::string toString() const;
80 #ifndef WITHOUT_ACS
81  asdmIDLTypes::IDLEntityId toIDLEntityId() const;
82 #endif
83 
87  void toBin(EndianOSStream& eoss) const;
88 
96  static EntityId fromBin(EndianIStream& eis);
97 
98  bool isNull() const;
99 
100  std::string getId() const;
101  void setId(std::string e);
102 
103 private:
104  std::string id;
105 
106 };
107 
108 // EntityId constructors
109 inline EntityId::EntityId() : id("") { }
110 
111 inline EntityId::EntityId(const EntityId &t) : id(t.id) { }
112 
113 // EntityId destructor
115 
117  id = x.id;
118  return *this;
119 }
120 
121 inline bool EntityId::isNull() const {
122  return id.length() == 0;
123 }
124 
125 inline bool EntityId::equals(const EntityId &x) const {
126  return id == x.id;
127 }
128 
129 inline bool EntityId::operator == (const EntityId &x) const {
130  return id == x.id;
131 }
132 
133 inline bool EntityId::operator != (const EntityId &x) const {
134  return id != x.id;
135 }
136 
137 inline std::string EntityId::toString() const {
138  return id;
139 }
140 
141 #ifndef WITHOUT_ACS
142 inline asdmIDLTypes::IDLEntityId EntityId::toIDLEntityId() const {
143  asdmIDLTypes::IDLEntityId x;
144  x.value = CORBA::string_dup(id.c_str());
145  return x;
146 }
147 #endif
148 
149 inline std::string EntityId::getId() const {
150  return id;
151 }
152 
153 inline void EntityId::setId(std::string s) {
154  id = s;
155 }
156 
157 // Friend functions
158 
159 inline std::ostream & operator << ( std::ostream &o, const EntityId &x ) {
160  o << x.id;
161  return o;
162 }
163 
164 inline std::istream & operator >> ( std::istream &i, EntityId &x ) {
165  i >> x.id;
166  return i;
167 }
168 
169 } // End namespace asdm
170 
171 #endif /* EntityId_CLASS */
bool operator!=(const EntityId &) const
Definition: EntityId.h:133
friend std::istream & operator>>(std::istream &, EntityId &)
friend std::ostream & operator<<(std::ostream &, const EntityId &)
Friend functions.
std::istream & operator>>(std::istream &, EntityId &)
Definition: EntityId.h:164
The StringTokenizer class is a translation into C++ of the Java class of the same name in Java&#39;s util...
std::string id
Definition: EntityId.h:104
static EntityId getEntityId(StringTokenizer &t)
virtual ~EntityId()
EntityId destructor.
Definition: EntityId.h:114
EntityId & operator=(const EntityId &)
Definition: EntityId.h:116
bool operator==(const EntityId &) const
Definition: EntityId.h:129
std::ostream & operator<<(std::ostream &, const EntityId &)
Friend functions.
Definition: EntityId.h:159
bool equals(const EntityId &) const
Definition: EntityId.h:125
std::string toString() const
Definition: EntityId.h:137
std::string getId() const
Definition: EntityId.h:149
bool isNull() const
Definition: EntityId.h:121
static EntityId fromBin(EndianIStream &eis)
Read the binary representation of an EntityId from a EndianIStream and use the read value to set an E...
The InvalidArgumentException class represents an exception when an attempt is made to access somethin...
void toBin(EndianOSStream &eoss) const
Write the binary representation of this to a EndianOSStream.
const Double e
e and functions thereof:
asdmIDLTypes::IDLEntityId toIDLEntityId() const
Definition: EntityId.h:142
static std::string validate(std::string x)
EntityId()
EntityId constructors.
Definition: EntityId.h:109
description
Definition: EntityId.h:56
void setId(std::string e)
Definition: EntityId.h:153