LCOV - code coverage report
Current view: top level - alma/ASDM - EntityId.h (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 14 15 93.3 %
Date: 2024-11-06 17:42:47 Functions: 7 9 77.8 %

          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 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             : 
      37             : #include <alma/ASDM/StringTokenizer.h>
      38             : #include <alma/ASDM/InvalidArgumentException.h>
      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             : 
      48             : /**
      49             :  * description
      50             :  * 
      51             :  * @version 1.00 Jan. 7, 2005
      52             :  * @author Allen Farris
      53             :  * @author Michel Caillat, added == and =! operators. June 2005.
      54             :  * 
      55             :  */
      56             : class EntityId {
      57             :     friend std::ostream & operator << ( std::ostream &, const EntityId & );
      58             :         friend std::istream & operator >> ( std::istream &, EntityId&);
      59             : 
      60             : public:
      61             :         static EntityId getEntityId(StringTokenizer &t);
      62             :         static std::string validate(std::string x);
      63             : 
      64             :         EntityId();
      65             :         EntityId(const EntityId &);
      66             :         EntityId(const std::string &id);
      67             : #ifndef WITHOUT_ACS
      68             :         EntityId(asdmIDLTypes::IDLEntityId &);
      69             : #endif
      70             :         virtual ~EntityId();
      71             : 
      72             :         EntityId& operator = (const EntityId &);
      73             : 
      74             :         bool equals(const EntityId &) const;
      75             :         bool operator == (const EntityId&) const;
      76             :         bool operator != (const EntityId&) const;   
      77             : 
      78             :         std::string toString() const;
      79             : #ifndef WITHOUT_ACS
      80             :     asdmIDLTypes::IDLEntityId toIDLEntityId() const;
      81             : #endif
      82             : 
      83             :         /**
      84             :          * Write the binary representation of this to a EndianOSStream.
      85             :          */             
      86             :         void toBin(EndianOSStream& eoss) const;
      87             :         
      88             :         /**
      89             :          * Read the binary representation of an EntityId from a EndianIStream
      90             :          * and use the read value to set an  EntityId.
      91             :          * @param eis the EndianStream to be read
      92             :          * @return an EntityId
      93             :          * @throw InvalidArgumentException
      94             :          */
      95             :         static EntityId fromBin(EndianIStream& eis);
      96             :         
      97             :         bool isNull() const;
      98             : 
      99             :         std::string getId() const;
     100             :         void setId(std::string e);
     101             : 
     102             : private:
     103             :         std::string id;
     104             : 
     105             : };
     106             : 
     107             : // EntityId constructors
     108       55677 : inline EntityId::EntityId() : id("") { }
     109             : 
     110      133811 : inline EntityId::EntityId(const EntityId &t) : id(t.id) { }
     111             : 
     112             : // EntityId destructor
     113           0 : inline EntityId::~EntityId() { }
     114             : 
     115       47101 : inline EntityId& EntityId::operator = ( const EntityId &x ) {
     116       47101 :         id = x.id;
     117       47101 :         return *this;
     118             : }
     119             : 
     120       12140 : inline bool EntityId::isNull() const {
     121       12140 :         return id.length() == 0;        
     122             : }
     123             : 
     124             : inline bool EntityId::equals(const EntityId &x) const {
     125             :         return id == x.id;
     126             : }
     127             : 
     128             : inline bool EntityId::operator == (const EntityId &x) const {
     129             :         return id == x.id;      
     130             : }
     131             : 
     132             : inline bool EntityId::operator != (const EntityId &x) const {
     133             :         return id != x.id;      
     134             : }
     135             : 
     136       16384 : inline std::string EntityId::toString() const {
     137       16384 :         return id;
     138             : }
     139             : 
     140             : #ifndef WITHOUT_ACS
     141             : inline asdmIDLTypes::IDLEntityId EntityId::toIDLEntityId() const {
     142             :     asdmIDLTypes::IDLEntityId x;
     143             :         x.value = CORBA::string_dup(id.c_str());
     144             :         return x;
     145             : }
     146             : #endif
     147             : 
     148       64450 : inline std::string EntityId::getId() const {
     149       64450 :         return id;
     150             : }
     151             : 
     152       13208 : inline void EntityId::setId(std::string s) {
     153       13208 :         id = s;
     154       13208 : }
     155             : 
     156             : // Friend functions
     157             : 
     158             : inline std::ostream & operator << ( std::ostream &o, const EntityId &x ) {
     159             :         o << x.id;
     160             :         return o;
     161             : }
     162             : 
     163             : inline std::istream & operator >> ( std::istream &i, EntityId &x ) {
     164             :         i >> x.id;
     165             :         return i;
     166             : }
     167             : 
     168             : } // End namespace asdm
     169             : 
     170             : #endif /* EntityId_CLASS */

Generated by: LCOV version 1.16