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 // Carrier.h 00030 // 00031 #ifndef Carrier_INCLUDED 00032 #define Carrier_INCLUDED 00033 00034 #include "Boolean.h" 00035 00036 class CarrierMapLoader; 00038 00040 class Carrier : public Boolean 00041 { 00042 public: 00043 00044 enum CARRIER{ NOT_CARRIER, IS_CARRIER, MISSING }; 00045 private: 00046 00047 friend class CarrierMapLoader; 00048 static std::map<std::string,bool> _lookupTable; 00049 public: 00050 00051 // 00052 // Constructors: 00053 // 00054 // Note: Boolean value true indicates a Carrier 00055 // Boolean value false indicates not a Carrier 00056 // 00057 Carrier() : Boolean() { } 00058 Carrier(const char *value){ set(value); } 00059 Carrier(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(CARRIER carrier); 00077 const CARRIER getEnum( void ) const { if(_isMissing) return Carrier::MISSING; if(_value) return Carrier::IS_CARRIER; else return Carrier::NOT_CARRIER; } 00078 00079 }; 00080 00081 // 00082 // Sampled Friend class that initializes the lookup table: 00083 // 00084 class CarrierMapLoader 00085 { 00086 public: 00087 static CarrierMapLoader carrierMapLoader; 00088 CarrierMapLoader(){ 00089 Carrier::_lookupTable["N"] = false; 00090 Carrier::_lookupTable["Y"] = true; 00091 Carrier::_lookupTable["y"] = true; 00092 Carrier::_lookupTable["n"] = false; 00093 Carrier::_lookupTable["yes"] = true; 00094 Carrier::_lookupTable["no" ] = false; 00095 Carrier::_lookupTable["Yes"] = true; 00096 Carrier::_lookupTable["No" ] = false; 00097 Carrier::_lookupTable["YES"] = true; 00098 Carrier::_lookupTable["NO" ] = false; 00099 Carrier::_lookupTable["c"] = true; 00100 Carrier::_lookupTable["C"] = true; 00101 Carrier::_lookupTable["carrier"] = true; 00102 Carrier::_lookupTable["Carrier"] = true; 00103 Carrier::_lookupTable["CARRIER"] = true; 00104 } 00105 }; 00106 00107 #endif