LCOV - code coverage report
Current view: top level - alma/Enumerations - CSwitchingMode.cc (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 22 91 24.2 %
Date: 2024-12-11 20:54:31 Functions: 4 12 33.3 %

          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 CSwitchingMode.cpp
      34             :  */
      35             : #include <sstream>
      36             : #include <alma/Enumerations/CSwitchingMode.h>
      37             : #include <string>
      38             : using namespace std;
      39             : 
      40           0 : int CSwitchingMode::version() {
      41           0 :         return SwitchingModeMod::version;
      42             :         }
      43             :         
      44           0 : string CSwitchingMode::revision () {
      45           0 :         return SwitchingModeMod::revision;
      46             : }
      47             : 
      48           0 : unsigned int CSwitchingMode::size() {
      49           0 :         return 7;
      50             :         }
      51             :         
      52             :         
      53             : const std::string& CSwitchingMode::sNO_SWITCHING = "NO_SWITCHING";
      54             :         
      55             : const std::string& CSwitchingMode::sLOAD_SWITCHING = "LOAD_SWITCHING";
      56             :         
      57             : const std::string& CSwitchingMode::sPOSITION_SWITCHING = "POSITION_SWITCHING";
      58             :         
      59             : const std::string& CSwitchingMode::sPHASE_SWITCHING = "PHASE_SWITCHING";
      60             :         
      61             : const std::string& CSwitchingMode::sFREQUENCY_SWITCHING = "FREQUENCY_SWITCHING";
      62             :         
      63             : const std::string& CSwitchingMode::sNUTATOR_SWITCHING = "NUTATOR_SWITCHING";
      64             :         
      65             : const std::string& CSwitchingMode::sCHOPPER_WHEEL = "CHOPPER_WHEEL";
      66             :         
      67        8230 : const std::vector<std::string> CSwitchingMode::names() {
      68        8230 :     std::vector<std::string> enumSet;
      69             :     
      70        8230 :     enumSet.insert(enumSet.end(), CSwitchingMode::sNO_SWITCHING);
      71             :     
      72        8230 :     enumSet.insert(enumSet.end(), CSwitchingMode::sLOAD_SWITCHING);
      73             :     
      74        8230 :     enumSet.insert(enumSet.end(), CSwitchingMode::sPOSITION_SWITCHING);
      75             :     
      76        8230 :     enumSet.insert(enumSet.end(), CSwitchingMode::sPHASE_SWITCHING);
      77             :     
      78        8230 :     enumSet.insert(enumSet.end(), CSwitchingMode::sFREQUENCY_SWITCHING);
      79             :     
      80        8230 :     enumSet.insert(enumSet.end(), CSwitchingMode::sNUTATOR_SWITCHING);
      81             :     
      82        8230 :     enumSet.insert(enumSet.end(), CSwitchingMode::sCHOPPER_WHEEL);
      83             :         
      84        8230 :     return enumSet;
      85           0 : }
      86             : 
      87         117 : std::string CSwitchingMode::name(const SwitchingModeMod::SwitchingMode& f) {
      88         117 :     switch (f) {
      89             :     
      90         117 :     case SwitchingModeMod::NO_SWITCHING:
      91         117 :       return CSwitchingMode::sNO_SWITCHING;
      92             :     
      93           0 :     case SwitchingModeMod::LOAD_SWITCHING:
      94           0 :       return CSwitchingMode::sLOAD_SWITCHING;
      95             :     
      96           0 :     case SwitchingModeMod::POSITION_SWITCHING:
      97           0 :       return CSwitchingMode::sPOSITION_SWITCHING;
      98             :     
      99           0 :     case SwitchingModeMod::PHASE_SWITCHING:
     100           0 :       return CSwitchingMode::sPHASE_SWITCHING;
     101             :     
     102           0 :     case SwitchingModeMod::FREQUENCY_SWITCHING:
     103           0 :       return CSwitchingMode::sFREQUENCY_SWITCHING;
     104             :     
     105           0 :     case SwitchingModeMod::NUTATOR_SWITCHING:
     106           0 :       return CSwitchingMode::sNUTATOR_SWITCHING;
     107             :     
     108           0 :     case SwitchingModeMod::CHOPPER_WHEEL:
     109           0 :       return CSwitchingMode::sCHOPPER_WHEEL;
     110             :         
     111             :     }
     112             :     // Impossible siutation but....who knows with C++ enums
     113           0 :     throw badInt((int) f);
     114             : }
     115             : 
     116       15505 : SwitchingModeMod::SwitchingMode CSwitchingMode::newSwitchingMode(const std::string& name) {
     117             :                 
     118       15505 :     if (name == CSwitchingMode::sNO_SWITCHING) {
     119       15505 :         return SwitchingModeMod::NO_SWITCHING;
     120             :     }
     121             :         
     122           0 :     if (name == CSwitchingMode::sLOAD_SWITCHING) {
     123           0 :         return SwitchingModeMod::LOAD_SWITCHING;
     124             :     }
     125             :         
     126           0 :     if (name == CSwitchingMode::sPOSITION_SWITCHING) {
     127           0 :         return SwitchingModeMod::POSITION_SWITCHING;
     128             :     }
     129             :         
     130           0 :     if (name == CSwitchingMode::sPHASE_SWITCHING) {
     131           0 :         return SwitchingModeMod::PHASE_SWITCHING;
     132             :     }
     133             :         
     134           0 :     if (name == CSwitchingMode::sFREQUENCY_SWITCHING) {
     135           0 :         return SwitchingModeMod::FREQUENCY_SWITCHING;
     136             :     }
     137             :         
     138           0 :     if (name == CSwitchingMode::sNUTATOR_SWITCHING) {
     139           0 :         return SwitchingModeMod::NUTATOR_SWITCHING;
     140             :     }
     141             :         
     142           0 :     if (name == CSwitchingMode::sCHOPPER_WHEEL) {
     143           0 :         return SwitchingModeMod::CHOPPER_WHEEL;
     144             :     }
     145             :     
     146           0 :     throw badString(name);
     147             : }
     148             : 
     149           0 : SwitchingModeMod::SwitchingMode CSwitchingMode::literal(const std::string& name) {
     150             :                 
     151           0 :     if (name == CSwitchingMode::sNO_SWITCHING) {
     152           0 :         return SwitchingModeMod::NO_SWITCHING;
     153             :     }
     154             :         
     155           0 :     if (name == CSwitchingMode::sLOAD_SWITCHING) {
     156           0 :         return SwitchingModeMod::LOAD_SWITCHING;
     157             :     }
     158             :         
     159           0 :     if (name == CSwitchingMode::sPOSITION_SWITCHING) {
     160           0 :         return SwitchingModeMod::POSITION_SWITCHING;
     161             :     }
     162             :         
     163           0 :     if (name == CSwitchingMode::sPHASE_SWITCHING) {
     164           0 :         return SwitchingModeMod::PHASE_SWITCHING;
     165             :     }
     166             :         
     167           0 :     if (name == CSwitchingMode::sFREQUENCY_SWITCHING) {
     168           0 :         return SwitchingModeMod::FREQUENCY_SWITCHING;
     169             :     }
     170             :         
     171           0 :     if (name == CSwitchingMode::sNUTATOR_SWITCHING) {
     172           0 :         return SwitchingModeMod::NUTATOR_SWITCHING;
     173             :     }
     174             :         
     175           0 :     if (name == CSwitchingMode::sCHOPPER_WHEEL) {
     176           0 :         return SwitchingModeMod::CHOPPER_WHEEL;
     177             :     }
     178             :     
     179           0 :     throw badString(name);
     180             : }
     181             : 
     182        8230 : SwitchingModeMod::SwitchingMode CSwitchingMode::from_int(unsigned int i) {
     183        8230 :         vector<string> names_ = names();
     184        8230 :         if (i >= names_.size()) throw badInt(i);
     185       16460 :         return newSwitchingMode(names_.at(i));
     186        8230 : }
     187             : 
     188           0 : string CSwitchingMode::badString(const string& name) {
     189           0 :         return "'"+name+"' does not correspond to any literal in the enumeration 'SwitchingMode'.";
     190             : }
     191             : 
     192           0 : string CSwitchingMode::badInt(unsigned int i) {
     193           0 :         ostringstream oss ;
     194           0 :         oss << "'" << i << "' is out of range for the enumeration 'SwitchingMode'.";
     195           0 :         return oss.str();
     196           0 : }
     197             : 
     198             : namespace SwitchingModeMod {
     199           0 :         std::ostream & operator << ( std::ostream & out, const SwitchingMode& value) {
     200           0 :                 out << CSwitchingMode::name(value);
     201           0 :                 return out;
     202             :         }
     203             : 
     204           0 :         std::istream & operator >> ( std::istream & in , SwitchingMode& value ) {
     205           0 :                 in.clear();
     206           0 :                 string s ; 
     207           0 :                 in >> s;
     208             :                 try {
     209           0 :                 value = CSwitchingMode::literal(s);
     210             :                 }
     211           0 :                 catch (string & m) {
     212           0 :                 in.setstate(ios::failbit);
     213           0 :                 }
     214           0 :                 return in;
     215           0 :         }
     216             : }
     217             : 

Generated by: LCOV version 1.16