casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Entity.h
Go to the documentation of this file.
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::EndianIStream;
00051 
00052 namespace asdm {
00053 
00054 class Entity;
00055 ostream & operator << ( ostream &, const Entity & );
00056 
00066 class Entity {
00067     friend ostream & operator << ( ostream &, const Entity & );
00068     friend istream & operator >> ( istream &, Entity & );
00069 
00070 public:
00071         static Entity getEntity(StringTokenizer &t);
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;
00089 #ifndef WITHOUT_ACS
00090         IDLEntity toIDLEntity() const;
00091 #endif
00092         void setFromXML(string xml);
00093         
00097         void toBin(EndianOSStream& eoss) const ;
00098         
00105         static Entity fromBin(EndianIStream& eis);
00106 
00107         
00108         EntityId getEntityId() const;
00109         string getEntityIdEncrypted() const;
00110         string getEntityTypeName() const;
00111         string getEntityVersion() const;
00112         string getInstanceVersion() const;
00113         void setEntityId(EntityId e);
00114         void setEntityIdEncrypted(string s);
00115         void setEntityTypeName(string s);
00116         void setEntityVersion(string s);
00117         void setInstanceVersion(string s);
00118 
00119 private:
00120         EntityId entityId;
00121         string entityIdEncrypted;
00122         string entityTypeName;
00123         string entityVersion;
00124         string instanceVersion;
00125 
00126         string getXMLValue(string xml, string parm) const;
00127         string validXML() const;
00128 
00129 };
00130 
00131 
00132 
00133 } // End namespace asdm
00134 
00135 #endif /* Entity_CLASS */