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 // 2005.03.07.ET.RK 00024 // 00025 00026 // 00027 // LivingDead.h 00028 // 00029 #ifndef LivingDead_INCLUDED 00030 #define LivingDead_INCLUDED 00031 00032 #include "Boolean.h" 00033 00034 class LivingDeadMapLoader; 00036 00038 class LivingDead : public Boolean 00039 { 00040 public: 00041 00042 enum LIVINGDEAD{ ALIVE, DEAD, MISSING };/*< Enumeration of living status values */ 00043 private: 00044 00045 friend class LivingDeadMapLoader; 00046 static std::map<std::string,bool> _lookupTable; 00047 public: 00048 00049 // 00050 // Constructors: 00051 // 00052 // Note: Boolean value true indicates Dead living status 00053 // Boolean value false indicates Alive living status 00054 // 00055 LivingDead() : Boolean() { } 00056 LivingDead(const char *value){ set(value); } 00057 LivingDead(const std::string &value){ set( value.c_str() ); } 00058 // 00059 // Static Methods: 00060 // 00061 static void addLookupTableEntry(std::string label, bool value); 00062 00063 // 00064 // Methods required by Variable virtual base class: 00065 // 00066 void set( const char *value ); 00067 void set( const std::string &value); 00068 const std::string get( void ) const { if(isMissing()) return "."; if(_value) return "Y"; else return "N";} 00069 void set( const bool value ) { Boolean::set(value); } 00070 00071 // 00072 // Additional Setters/Getters not present in virtual base class: 00073 // 00074 void set(LIVINGDEAD livingdead); 00075 const LIVINGDEAD getEnum( void ) const { if(_isMissing) return LivingDead::MISSING; if(_value) return LivingDead::DEAD; else return LivingDead::ALIVE; } 00076 00077 }; 00078 00079 // 00080 // LivingDead Friend class that initializes the lookup table: 00081 // 00082 class LivingDeadMapLoader 00083 { 00084 public: 00085 static LivingDeadMapLoader livingdeadMapLoader; 00086 LivingDeadMapLoader(){ 00087 LivingDead::_lookupTable["N"] = false; 00088 LivingDead::_lookupTable["Y"] = true; 00089 LivingDead::_lookupTable["y"] = true; 00090 LivingDead::_lookupTable["n"] = false; 00091 LivingDead::_lookupTable["yes"] = true; 00092 LivingDead::_lookupTable["no" ] = false; 00093 LivingDead::_lookupTable["Yes"] = true; 00094 LivingDead::_lookupTable["No" ] = false; 00095 LivingDead::_lookupTable["YES"] = true; 00096 LivingDead::_lookupTable["NO" ] = false; 00097 LivingDead::_lookupTable["dead" ] = true; 00098 LivingDead::_lookupTable["alive" ] = false; 00099 LivingDead::_lookupTable["deceased"] = true; 00100 LivingDead::_lookupTable["living" ] = false; 00101 LivingDead::_lookupTable["Dead" ] = true; 00102 LivingDead::_lookupTable["Alive" ] = false; 00103 LivingDead::_lookupTable["Deceased"] = true; 00104 LivingDead::_lookupTable["Living" ] = false; 00105 LivingDead::_lookupTable["DEAD" ] = true; 00106 LivingDead::_lookupTable["ALIVE" ] = false; 00107 LivingDead::_lookupTable["DECEASED"] = true; 00108 LivingDead::_lookupTable["LIVING" ] = false; 00109 } 00110 }; 00111 00112 #endif