00001 00002 // 00003 // This file is part of the MADELINE 2 program 00004 // written by Edward H. Trager, Ritu Khanna and Adrian Marrs 00005 // Copyright (c) 2005 by the 00006 // Regents of the University of Michigan. 00007 // All Rights Reserved. 00008 // 00009 // The latest version of this program is available from: 00010 // 00011 // http://eyegene.ophthy.med.umich.edu/madeline/ 00012 // 00013 // Released under the GNU General Public License. 00014 // A copy of the GPL is included in the distribution 00015 // package of this software, or see: 00016 // 00017 // http://www.gnu.org/copyleft/ 00018 // 00019 // ... for licensing details. 00020 // 00022 // 00023 // 2007.04.26.ET 00024 // 00025 // Last updated 2011.11.18.ET 00026 // 00027 00028 // 00029 // Consultand.h 00030 // 00031 #ifndef Consultand_INCLUDED 00032 #define Consultand_INCLUDED 00033 00034 #include "Boolean.h" 00035 00036 class ConsultandMapLoader; 00038 00040 class Consultand : public Boolean 00041 { 00042 public: 00043 00044 enum CONSULTAND{ NOT_CONSULTAND, IS_CONSULTAND, MISSING }; 00045 private: 00046 00047 friend class ConsultandMapLoader; 00048 static std::map<std::string,bool> _lookupTable; 00049 public: 00050 00051 // 00052 // Constructors: 00053 // 00054 // Note: Boolean value true indicates a Consultand 00055 // Boolean value false indicates not a Consultand 00056 // 00057 Consultand() : Boolean() { } 00058 Consultand(const char *value){ set(value); } 00059 Consultand(const std::string &value){ set( value.c_str() ); } 00060 // 00061 // Static Methods: 00062 // 00063 static void addLookupTableEntry(std::string label, bool value); 00064 00065 // 00066 // Methods required by Variable virtual base class: 00067 // 00068 void set( const char *value ); 00069 void set( const std::string &value); 00070 const std::string get( void ) const { if(isMissing()) return "."; if(_value) return "Y"; else return "N";} 00071 void set( const bool value ) { Boolean::set(value); } 00072 00073 // 00074 // Additional Setters/Getters not present in virtual base class: 00075 // 00076 void set(CONSULTAND consultand); 00077 const CONSULTAND getEnum( void ) const { if(_isMissing) return Consultand::MISSING; if(_value) return Consultand::IS_CONSULTAND; else return NOT_CONSULTAND; } 00078 00079 }; 00080 00081 // 00082 // Consultand Friend class that initializes the lookup table: 00083 // 00084 class ConsultandMapLoader 00085 { 00086 public: 00087 static ConsultandMapLoader consultandMapLoader; 00088 ConsultandMapLoader(){ 00089 Consultand::_lookupTable["Y"] = true; 00090 Consultand::_lookupTable["y"] = true; 00091 Consultand::_lookupTable["N"] = false; 00092 Consultand::_lookupTable["n"] = false; 00093 Consultand::_lookupTable["yes"] = true; 00094 Consultand::_lookupTable["no" ] = false; 00095 Consultand::_lookupTable["Yes"] = true; 00096 Consultand::_lookupTable["No" ] = false; 00097 Consultand::_lookupTable["YES"] = true; 00098 Consultand::_lookupTable["NO" ] = false; 00099 Consultand::_lookupTable["C"] = true; 00100 Consultand::_lookupTable["c"] = true; 00101 Consultand::_lookupTable["consultand"] = true; 00102 Consultand::_lookupTable["Consultand"] = true; 00103 Consultand::_lookupTable["CONSULTAND"] = true; 00104 } 00105 }; 00106 00107 #endif