Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Class Members | File Members

Gender.h

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

Generated on Tue Feb 27 14:39:23 2007 for MINIMADELINE by  doxygen 1.4.4