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 // Last updated 2011.11.18.ET 00026 // 00027 00028 // 00029 // Gender.h 00030 // 00031 #ifndef Gender_INCLUDED 00032 #define Gender_INCLUDED 00033 #define BOOLEAN_MALE false 00034 #define BOOLEAN_FEMALE true 00035 00036 00037 #include "Boolean.h" 00038 00039 class GenderMapLoader; 00041 class Gender : public Boolean 00042 { 00043 public: 00044 00045 enum GENDER{ MALE, FEMALE, MISSING }; 00046 private: 00047 00048 friend class GenderMapLoader; 00049 static std::map<std::string,bool> _lookupTable; 00050 public: 00051 00052 // 00053 // Constructors: 00054 // 00055 // Note: Boolean value true indicates Female 00056 // Boolean value false indicates Male 00057 // 00058 Gender() : Boolean() { } 00059 Gender(const char *value){ set(value); } 00060 Gender(const std::string &value){ set( value.c_str() ); } 00061 // 00062 // Static Methods: 00063 // 00064 static void addLookupTableEntry(std::string label, bool value); 00065 00066 // 00067 // Methods required by Variable virtual base class: 00068 // 00069 void set( const char *value ); 00070 void set( const std::string &value); 00071 const std::string get( void ) const { if(isMissing()) return "."; if(_value) return "F"; else return "M";} 00072 void set( const bool value ) { Boolean::set(value); } 00073 00074 // 00075 // Additional Setters/Getters not present in virtual base class: 00076 // 00077 void set(GENDER gender); 00078 const GENDER getEnum( void ) const { if(_isMissing) return Gender::MISSING; if(_value) return Gender::FEMALE; else return MALE; } 00079 00080 static bool isA(std::string inString); 00081 }; 00082 00083 // 00084 // Gender Friend class that initializes the lookup table: 00085 // 00086 class GenderMapLoader 00087 { 00088 public: 00089 static GenderMapLoader genderMapLoader; 00090 GenderMapLoader(){ 00091 Gender::_lookupTable["f"] = BOOLEAN_FEMALE; 00092 Gender::_lookupTable["m"] = BOOLEAN_MALE; 00093 Gender::_lookupTable["F"] = BOOLEAN_FEMALE; 00094 Gender::_lookupTable["M"] = BOOLEAN_MALE; 00095 Gender::_lookupTable["male" ] = BOOLEAN_MALE; 00096 Gender::_lookupTable["female"] = BOOLEAN_FEMALE; 00097 Gender::_lookupTable["Male" ] = BOOLEAN_MALE; 00098 Gender::_lookupTable["Female"] = BOOLEAN_FEMALE; 00099 Gender::_lookupTable["MALE" ] = BOOLEAN_MALE; 00100 Gender::_lookupTable["FEMALE"] = BOOLEAN_FEMALE; 00101 Gender::_lookupTable["♀"] = BOOLEAN_FEMALE; 00102 Gender::_lookupTable["♂"] = BOOLEAN_MALE; 00103 Gender::_lookupTable["女"] = BOOLEAN_FEMALE; 00104 Gender::_lookupTable["男"] = BOOLEAN_MALE; 00105 Gender::_lookupTable["雌"] = BOOLEAN_FEMALE; 00106 Gender::_lookupTable["雄"] = BOOLEAN_MALE; 00107 } 00108 }; 00109 00110 #endif