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 // Sampled.h 00028 // 00029 #ifndef Sampled_INCLUDED 00030 #define Sampled_INCLUDED 00031 00032 #include "Boolean.h" 00033 00034 class SampledMapLoader; 00036 00038 class Sampled : public Boolean 00039 { 00040 public: 00041 00042 enum SAMPLED{ NOT_SAMPLED, IS_SAMPLED, MISSING }; 00043 private: 00044 00045 friend class SampledMapLoader; 00046 static std::map<std::string,bool> _lookupTable; 00047 public: 00048 00049 // 00050 // Constructors: 00051 // 00052 // Note: Boolean value true indicates a Sampled 00053 // Boolean value false indicates not a Sampled 00054 // 00055 Sampled() : Boolean() { } 00056 Sampled(const char *value){ set(value); } 00057 Sampled(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(SAMPLED sampled); 00075 const SAMPLED getEnum( void ) const { if(_isMissing) return Sampled::MISSING; if(_value) return Sampled::IS_SAMPLED; else return Sampled::NOT_SAMPLED; } 00076 00077 }; 00078 00079 // 00080 // Sampled Friend class that initializes the lookup table: 00081 // 00082 class SampledMapLoader 00083 { 00084 public: 00085 static SampledMapLoader sampledMapLoader; 00086 SampledMapLoader(){ 00087 Sampled::_lookupTable["N"] = false; 00088 Sampled::_lookupTable["Y"] = true; 00089 Sampled::_lookupTable["y"] = true; 00090 Sampled::_lookupTable["n"] = false; 00091 Sampled::_lookupTable["yes"] = true; 00092 Sampled::_lookupTable["no" ] = false; 00093 Sampled::_lookupTable["Yes"] = true; 00094 Sampled::_lookupTable["No" ] = false; 00095 Sampled::_lookupTable["YES"] = true; 00096 Sampled::_lookupTable["NO" ] = false; 00097 Sampled::_lookupTable["s"] = true; 00098 Sampled::_lookupTable["u"] = false; 00099 Sampled::_lookupTable["S"] = true; 00100 Sampled::_lookupTable["U"] = false; 00101 Sampled::_lookupTable["sampled" ] = true; 00102 Sampled::_lookupTable["unsampled"] = false; 00103 Sampled::_lookupTable["Sampled" ] = true; 00104 Sampled::_lookupTable["Unsampled"] = false; 00105 Sampled::_lookupTable["SAMPLED" ] = true; 00106 Sampled::_lookupTable["UNSAMPLED"] = false; 00107 } 00108 }; 00109 00110 #endif