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

Generated by: LCOV version 1.16