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 CInvalidatingCondition.cpp 34 : */ 35 : #include <sstream> 36 : #include <alma/Enumerations/CInvalidatingCondition.h> 37 : #include <string> 38 : using namespace std; 39 : 40 0 : int CInvalidatingCondition::version() { 41 0 : return InvalidatingConditionMod::version; 42 : } 43 : 44 0 : string CInvalidatingCondition::revision () { 45 0 : return InvalidatingConditionMod::revision; 46 : } 47 : 48 0 : unsigned int CInvalidatingCondition::size() { 49 0 : return 5; 50 : } 51 : 52 : 53 : const std::string& CInvalidatingCondition::sANTENNA_DISCONNECT = "ANTENNA_DISCONNECT"; 54 : 55 : const std::string& CInvalidatingCondition::sANTENNA_MOVE = "ANTENNA_MOVE"; 56 : 57 : const std::string& CInvalidatingCondition::sANTENNA_POWER_DOWN = "ANTENNA_POWER_DOWN"; 58 : 59 : const std::string& CInvalidatingCondition::sRECEIVER_EXCHANGE = "RECEIVER_EXCHANGE"; 60 : 61 : const std::string& CInvalidatingCondition::sRECEIVER_POWER_DOWN = "RECEIVER_POWER_DOWN"; 62 : 63 0 : const std::vector<std::string> CInvalidatingCondition::names() { 64 0 : std::vector<std::string> enumSet; 65 : 66 0 : enumSet.insert(enumSet.end(), CInvalidatingCondition::sANTENNA_DISCONNECT); 67 : 68 0 : enumSet.insert(enumSet.end(), CInvalidatingCondition::sANTENNA_MOVE); 69 : 70 0 : enumSet.insert(enumSet.end(), CInvalidatingCondition::sANTENNA_POWER_DOWN); 71 : 72 0 : enumSet.insert(enumSet.end(), CInvalidatingCondition::sRECEIVER_EXCHANGE); 73 : 74 0 : enumSet.insert(enumSet.end(), CInvalidatingCondition::sRECEIVER_POWER_DOWN); 75 : 76 0 : return enumSet; 77 : } 78 : 79 0 : std::string CInvalidatingCondition::name(const InvalidatingConditionMod::InvalidatingCondition& f) { 80 0 : switch (f) { 81 : 82 0 : case InvalidatingConditionMod::ANTENNA_DISCONNECT: 83 0 : return CInvalidatingCondition::sANTENNA_DISCONNECT; 84 : 85 0 : case InvalidatingConditionMod::ANTENNA_MOVE: 86 0 : return CInvalidatingCondition::sANTENNA_MOVE; 87 : 88 0 : case InvalidatingConditionMod::ANTENNA_POWER_DOWN: 89 0 : return CInvalidatingCondition::sANTENNA_POWER_DOWN; 90 : 91 0 : case InvalidatingConditionMod::RECEIVER_EXCHANGE: 92 0 : return CInvalidatingCondition::sRECEIVER_EXCHANGE; 93 : 94 0 : case InvalidatingConditionMod::RECEIVER_POWER_DOWN: 95 0 : return CInvalidatingCondition::sRECEIVER_POWER_DOWN; 96 : 97 : } 98 : // Impossible siutation but....who knows with C++ enums 99 0 : throw badInt((int) f); 100 : } 101 : 102 0 : InvalidatingConditionMod::InvalidatingCondition CInvalidatingCondition::newInvalidatingCondition(const std::string& name) { 103 : 104 0 : if (name == CInvalidatingCondition::sANTENNA_DISCONNECT) { 105 0 : return InvalidatingConditionMod::ANTENNA_DISCONNECT; 106 : } 107 : 108 0 : if (name == CInvalidatingCondition::sANTENNA_MOVE) { 109 0 : return InvalidatingConditionMod::ANTENNA_MOVE; 110 : } 111 : 112 0 : if (name == CInvalidatingCondition::sANTENNA_POWER_DOWN) { 113 0 : return InvalidatingConditionMod::ANTENNA_POWER_DOWN; 114 : } 115 : 116 0 : if (name == CInvalidatingCondition::sRECEIVER_EXCHANGE) { 117 0 : return InvalidatingConditionMod::RECEIVER_EXCHANGE; 118 : } 119 : 120 0 : if (name == CInvalidatingCondition::sRECEIVER_POWER_DOWN) { 121 0 : return InvalidatingConditionMod::RECEIVER_POWER_DOWN; 122 : } 123 : 124 0 : throw badString(name); 125 : } 126 : 127 0 : InvalidatingConditionMod::InvalidatingCondition CInvalidatingCondition::literal(const std::string& name) { 128 : 129 0 : if (name == CInvalidatingCondition::sANTENNA_DISCONNECT) { 130 0 : return InvalidatingConditionMod::ANTENNA_DISCONNECT; 131 : } 132 : 133 0 : if (name == CInvalidatingCondition::sANTENNA_MOVE) { 134 0 : return InvalidatingConditionMod::ANTENNA_MOVE; 135 : } 136 : 137 0 : if (name == CInvalidatingCondition::sANTENNA_POWER_DOWN) { 138 0 : return InvalidatingConditionMod::ANTENNA_POWER_DOWN; 139 : } 140 : 141 0 : if (name == CInvalidatingCondition::sRECEIVER_EXCHANGE) { 142 0 : return InvalidatingConditionMod::RECEIVER_EXCHANGE; 143 : } 144 : 145 0 : if (name == CInvalidatingCondition::sRECEIVER_POWER_DOWN) { 146 0 : return InvalidatingConditionMod::RECEIVER_POWER_DOWN; 147 : } 148 : 149 0 : throw badString(name); 150 : } 151 : 152 0 : InvalidatingConditionMod::InvalidatingCondition CInvalidatingCondition::from_int(unsigned int i) { 153 0 : vector<string> names_ = names(); 154 0 : if (i >= names_.size()) throw badInt(i); 155 0 : return newInvalidatingCondition(names_.at(i)); 156 : } 157 : 158 0 : string CInvalidatingCondition::badString(const string& name) { 159 0 : return "'"+name+"' does not correspond to any literal in the enumeration 'InvalidatingCondition'."; 160 : } 161 : 162 0 : string CInvalidatingCondition::badInt(unsigned int i) { 163 0 : ostringstream oss ; 164 0 : oss << "'" << i << "' is out of range for the enumeration 'InvalidatingCondition'."; 165 0 : return oss.str(); 166 : } 167 : 168 : namespace InvalidatingConditionMod { 169 0 : std::ostream & operator << ( std::ostream & out, const InvalidatingCondition& value) { 170 0 : out << CInvalidatingCondition::name(value); 171 0 : return out; 172 : } 173 : 174 0 : std::istream & operator >> ( std::istream & in , InvalidatingCondition& value ) { 175 0 : in.clear(); 176 0 : string s ; 177 0 : in >> s; 178 : try { 179 0 : value = CInvalidatingCondition::literal(s); 180 : } 181 0 : catch (string & m) { 182 0 : in.setstate(ios::failbit); 183 : } 184 0 : return in; 185 : } 186 : } 187 :