LCOV - code coverage report
Current view: top level - alma/Enumerations - CTimeSampling.cc (source / functions) Hit Total Coverage
Test: ctest_coverage.info Lines: 20 51 39.2 %
Date: 2023-11-06 10:06:49 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 CTimeSampling.cpp
      34             :  */
      35             : #include <sstream>
      36             : #include <alma/Enumerations/CTimeSampling.h>
      37             : #include <string>
      38             : using namespace std;
      39             : 
      40           0 : int CTimeSampling::version() {
      41           0 :         return TimeSamplingMod::version;
      42             :         }
      43             :         
      44           0 : string CTimeSampling::revision () {
      45           0 :         return TimeSamplingMod::revision;
      46             : }
      47             : 
      48           0 : unsigned int CTimeSampling::size() {
      49           0 :         return 2;
      50             :         }
      51             :         
      52             :         
      53             : const std::string& CTimeSampling::sSUBINTEGRATION = "SUBINTEGRATION";
      54             :         
      55             : const std::string& CTimeSampling::sINTEGRATION = "INTEGRATION";
      56             :         
      57        8163 : const std::vector<std::string> CTimeSampling::names() {
      58        8163 :     std::vector<std::string> enumSet;
      59             :     
      60        8163 :     enumSet.insert(enumSet.end(), CTimeSampling::sSUBINTEGRATION);
      61             :     
      62        8163 :     enumSet.insert(enumSet.end(), CTimeSampling::sINTEGRATION);
      63             :         
      64        8163 :     return enumSet;
      65             : }
      66             : 
      67         749 : std::string CTimeSampling::name(const TimeSamplingMod::TimeSampling& f) {
      68         749 :     switch (f) {
      69             :     
      70         105 :     case TimeSamplingMod::SUBINTEGRATION:
      71         105 :       return CTimeSampling::sSUBINTEGRATION;
      72             :     
      73         644 :     case TimeSamplingMod::INTEGRATION:
      74         644 :       return CTimeSampling::sINTEGRATION;
      75             :         
      76             :     }
      77             :     // Impossible siutation but....who knows with C++ enums
      78           0 :     throw badInt((int) f);
      79             : }
      80             : 
      81       15790 : TimeSamplingMod::TimeSampling CTimeSampling::newTimeSampling(const std::string& name) {
      82             :                 
      83       15790 :     if (name == CTimeSampling::sSUBINTEGRATION) {
      84       11075 :         return TimeSamplingMod::SUBINTEGRATION;
      85             :     }
      86             :         
      87        4715 :     if (name == CTimeSampling::sINTEGRATION) {
      88        4715 :         return TimeSamplingMod::INTEGRATION;
      89             :     }
      90             :     
      91           0 :     throw badString(name);
      92             : }
      93             : 
      94           0 : TimeSamplingMod::TimeSampling CTimeSampling::literal(const std::string& name) {
      95             :                 
      96           0 :     if (name == CTimeSampling::sSUBINTEGRATION) {
      97           0 :         return TimeSamplingMod::SUBINTEGRATION;
      98             :     }
      99             :         
     100           0 :     if (name == CTimeSampling::sINTEGRATION) {
     101           0 :         return TimeSamplingMod::INTEGRATION;
     102             :     }
     103             :     
     104           0 :     throw badString(name);
     105             : }
     106             : 
     107        8163 : TimeSamplingMod::TimeSampling CTimeSampling::from_int(unsigned int i) {
     108       16326 :         vector<string> names_ = names();
     109        8163 :         if (i >= names_.size()) throw badInt(i);
     110       16326 :         return newTimeSampling(names_.at(i));
     111             : }
     112             : 
     113           0 : string CTimeSampling::badString(const string& name) {
     114           0 :         return "'"+name+"' does not correspond to any literal in the enumeration 'TimeSampling'.";
     115             : }
     116             : 
     117           0 : string CTimeSampling::badInt(unsigned int i) {
     118           0 :         ostringstream oss ;
     119           0 :         oss << "'" << i << "' is out of range for the enumeration 'TimeSampling'.";
     120           0 :         return oss.str();
     121             : }
     122             : 
     123             : namespace TimeSamplingMod {
     124           0 :         std::ostream & operator << ( std::ostream & out, const TimeSampling& value) {
     125           0 :                 out << CTimeSampling::name(value);
     126           0 :                 return out;
     127             :         }
     128             : 
     129           0 :         std::istream & operator >> ( std::istream & in , TimeSampling& value ) {
     130           0 :                 in.clear();
     131           0 :                 string s ; 
     132           0 :                 in >> s;
     133             :                 try {
     134           0 :                 value = CTimeSampling::literal(s);
     135             :                 }
     136           0 :                 catch (string & m) {
     137           0 :                 in.setstate(ios::failbit);
     138             :                 }
     139           0 :                 return in;
     140             :         }
     141             : }
     142             : 

Generated by: LCOV version 1.16