Line data Source code
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 PartId.h 25 : */ 26 : 27 : #ifndef PartId_CLASS 28 : #define PartId_CLASS 29 : 30 : #include <string> 31 : 32 : #include <alma/ASDM/InvalidArgumentException.h> 33 : 34 : #include <alma/ASDM/EndianStream.h> 35 : 36 : namespace asdm { 37 : 38 : /** 39 : * description 40 : * 41 : * @version 1.00 Jan. 7, 2005 42 : * @author Allen Farris 43 : */ 44 : class PartId { 45 : 46 : public: 47 : static std::string validate(std::string x); 48 : 49 : PartId(); 50 : PartId(const PartId &); 51 : PartId(const std::string &id); 52 : virtual ~PartId(); 53 : 54 : bool equals(const PartId &) const; 55 : 56 : std::string toString() const; 57 : 58 : void setId(const std::string &s); 59 : 60 : /** 61 : * Write the binary representation of this to a EndianOSStream. 62 : */ 63 : void toBin(EndianOSStream& eoss) const; 64 : 65 : /** 66 : * Read the binary representation of a PartId from a EndianIStream 67 : * and use the read value to set an PartId. 68 : * @param eis the EndianStream to be read 69 : * @return a PartId 70 : * @throw InvalidArgumentException 71 : */ 72 : static PartId fromBin(EndianIStream& eis); 73 : private: 74 : std::string id; 75 : 76 : }; 77 : 78 : // PartId constructors 79 34063 : inline PartId::PartId() { } 80 : 81 122415 : inline PartId::PartId(const PartId &x) : id(x.id) { } 82 : 83 : // PartId destructor 84 0 : inline PartId::~PartId() { } 85 : 86 : inline bool PartId::equals(const PartId &x) const { 87 : return id == x.id; 88 : } 89 : 90 46798 : inline std::string PartId::toString() const { 91 46798 : return id; 92 : } 93 : 94 : } // End namespace asdm 95 : 96 : #endif /* PartId_CLASS */