LCOV - code coverage report
Current view: top level - alma/Enumerations - CNetSideband.cc (source / functions) Hit Total Coverage
Test: ctest_coverage.info Lines: 35 65 53.8 %
Date: 2023-11-06 10:06:49 Functions: 5 12 41.7 %

          Line data    Source code
       1             : 
       2             : /*
       3             :  * ALMA - Atacama Large Millimeter Array
       4             :  * (c) European Southern Observatory, 2002
       5             :  * (c) Associated Universities Inc., 2002
       6             :  * Copyright by ESO (in the framework of the ALMA collaboration),
       7             :  * Copyright by AUI (in the framework of the ALMA collaboration),
       8             :  * All rights reserved.
       9             :  * 
      10             :  * This library is free software; you can redistribute it and/or
      11             :  * modify it under the terms of the GNU Lesser General Public
      12             :  * License as published by the Free software Foundation; either
      13             :  * version 2.1 of the License, or (at your option) any later version.
      14             :  * 
      15             :  * This library is distributed in the hope that it will be useful,
      16             :  * but WITHOUT ANY WARRANTY, without even the implied warranty of
      17             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      18             :  * Lesser General Public License for more details.
      19             :  * 
      20             :  * You should have received a copy of the GNU Lesser General Public
      21             :  * License along with this library; if not, write to the Free Software
      22             :  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
      23             :  * MA 02111-1307  USA
      24             :  * 
      25             :  * /////////////////////////////////////////////////////////////////
      26             :  * // WARNING!  DO NOT MODIFY THIS FILE!                          //
      27             :  * //  ---------------------------------------------------------  //
      28             :  * // | This is generated code!  Do not modify this file.       | //
      29             :  * // | Any changes will be lost when the file is re-generated. | //
      30             :  * //  ---------------------------------------------------------  //
      31             :  * /////////////////////////////////////////////////////////////////
      32             :  *
      33             :  * File CNetSideband.cpp
      34             :  */
      35             : #include <sstream>
      36             : #include <alma/Enumerations/CNetSideband.h>
      37             : #include <string>
      38             : using namespace std;
      39             : 
      40           0 : int CNetSideband::version() {
      41           0 :         return NetSidebandMod::version;
      42             :         }
      43             :         
      44           0 : string CNetSideband::revision () {
      45           0 :         return NetSidebandMod::revision;
      46             : }
      47             : 
      48           0 : unsigned int CNetSideband::size() {
      49           0 :         return 4;
      50             :         }
      51             :         
      52             :         
      53             : const std::string& CNetSideband::sNOSB = "NOSB";
      54             :         
      55             : const std::string& CNetSideband::sLSB = "LSB";
      56             :         
      57             : const std::string& CNetSideband::sUSB = "USB";
      58             :         
      59             : const std::string& CNetSideband::sDSB = "DSB";
      60             :         
      61        2611 : const std::vector<std::string> CNetSideband::names() {
      62        2611 :     std::vector<std::string> enumSet;
      63             :     
      64        2611 :     enumSet.insert(enumSet.end(), CNetSideband::sNOSB);
      65             :     
      66        2611 :     enumSet.insert(enumSet.end(), CNetSideband::sLSB);
      67             :     
      68        2611 :     enumSet.insert(enumSet.end(), CNetSideband::sUSB);
      69             :     
      70        2611 :     enumSet.insert(enumSet.end(), CNetSideband::sDSB);
      71             :         
      72        2611 :     return enumSet;
      73             : }
      74             : 
      75         619 : std::string CNetSideband::name(const NetSidebandMod::NetSideband& f) {
      76         619 :     switch (f) {
      77             :     
      78           0 :     case NetSidebandMod::NOSB:
      79           0 :       return CNetSideband::sNOSB;
      80             :     
      81         571 :     case NetSidebandMod::LSB:
      82         571 :       return CNetSideband::sLSB;
      83             :     
      84          48 :     case NetSidebandMod::USB:
      85          48 :       return CNetSideband::sUSB;
      86             :     
      87           0 :     case NetSidebandMod::DSB:
      88           0 :       return CNetSideband::sDSB;
      89             :         
      90             :     }
      91             :     // Impossible siutation but....who knows with C++ enums
      92           0 :     throw badInt((int) f);
      93             : }
      94             : 
      95        4579 : NetSidebandMod::NetSideband CNetSideband::newNetSideband(const std::string& name) {
      96             :                 
      97        4579 :     if (name == CNetSideband::sNOSB) {
      98        2075 :         return NetSidebandMod::NOSB;
      99             :     }
     100             :         
     101        2504 :     if (name == CNetSideband::sLSB) {
     102        1186 :         return NetSidebandMod::LSB;
     103             :     }
     104             :         
     105        1318 :     if (name == CNetSideband::sUSB) {
     106         406 :         return NetSidebandMod::USB;
     107             :     }
     108             :         
     109         912 :     if (name == CNetSideband::sDSB) {
     110         912 :         return NetSidebandMod::DSB;
     111             :     }
     112             :     
     113           0 :     throw badString(name);
     114             : }
     115             : 
     116        8724 : NetSidebandMod::NetSideband CNetSideband::literal(const std::string& name) {
     117             :                 
     118        8724 :     if (name == CNetSideband::sNOSB) {
     119         437 :         return NetSidebandMod::NOSB;
     120             :     }
     121             :         
     122        8287 :     if (name == CNetSideband::sLSB) {
     123        3766 :         return NetSidebandMod::LSB;
     124             :     }
     125             :         
     126        4521 :     if (name == CNetSideband::sUSB) {
     127        3676 :         return NetSidebandMod::USB;
     128             :     }
     129             :         
     130         845 :     if (name == CNetSideband::sDSB) {
     131         845 :         return NetSidebandMod::DSB;
     132             :     }
     133             :     
     134           0 :     throw badString(name);
     135             : }
     136             : 
     137        2611 : NetSidebandMod::NetSideband CNetSideband::from_int(unsigned int i) {
     138        5222 :         vector<string> names_ = names();
     139        2611 :         if (i >= names_.size()) throw badInt(i);
     140        5222 :         return newNetSideband(names_.at(i));
     141             : }
     142             : 
     143           0 : string CNetSideband::badString(const string& name) {
     144           0 :         return "'"+name+"' does not correspond to any literal in the enumeration 'NetSideband'.";
     145             : }
     146             : 
     147           0 : string CNetSideband::badInt(unsigned int i) {
     148           0 :         ostringstream oss ;
     149           0 :         oss << "'" << i << "' is out of range for the enumeration 'NetSideband'.";
     150           0 :         return oss.str();
     151             : }
     152             : 
     153             : namespace NetSidebandMod {
     154           0 :         std::ostream & operator << ( std::ostream & out, const NetSideband& value) {
     155           0 :                 out << CNetSideband::name(value);
     156           0 :                 return out;
     157             :         }
     158             : 
     159           0 :         std::istream & operator >> ( std::istream & in , NetSideband& value ) {
     160           0 :                 in.clear();
     161           0 :                 string s ; 
     162           0 :                 in >> s;
     163             :                 try {
     164           0 :                 value = CNetSideband::literal(s);
     165             :                 }
     166           0 :                 catch (string & m) {
     167           0 :                 in.setstate(ios::failbit);
     168             :                 }
     169           0 :                 return in;
     170             :         }
     171             : }
     172             : 

Generated by: LCOV version 1.16