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.08.31.ET 00024 // 00025 00026 // 00027 // Affected.h 00028 // 00029 #ifndef Affected_INCLUDED 00030 #define Affected_INCLUDED 00031 00032 #include "String.h" 00033 #include "Boolean.h" 00034 #include <map> 00035 00036 #define BOOLEAN_AFFECTED "T" 00037 #define BOOLEAN_UNAFFECTED "F" 00038 00039 class Affected : public String { 00040 00041 private: 00042 00043 friend class AffectedMapLoader; 00044 static std::map<std::string,std::string> _lookupTable; 00045 00046 // Here is the "Boolean" attribute that the regular "String" 00047 // class lacks: this defaults to missing: 00048 Boolean _booleanValue; 00049 00050 public: 00051 00052 // 00053 // Constructors: 00054 // 00055 Affected() { _isMissing=true; } 00056 Affected( const std::string value ){ set(value); } 00057 Affected( const char* value ){ set(value); } 00058 00059 // 00060 // Set methods: 00061 // 00062 void set(const char *value); 00063 void set(const std::string value); 00064 00065 // 00066 // Get methods not present in base "String" class: 00067 // 00068 const bool getBoolean( void ) const; 00069 char getBooleanAsChar(void) const; 00070 00071 static void addAffectedBooleanMapping(std::string affectedValue,std::string booleanMapping); 00072 static bool isa(std::string inString); 00073 00074 }; 00075 00076 // 00077 // Affected Friend class that initializes the lookup table: 00078 // 00079 class AffectedMapLoader 00080 { 00081 public: 00082 static AffectedMapLoader affectedMapLoader; 00083 00084 AffectedMapLoader(){ 00085 Affected::_lookupTable["a"] = BOOLEAN_AFFECTED; 00086 Affected::_lookupTable["u"] = BOOLEAN_UNAFFECTED; 00087 Affected::_lookupTable["A"] = BOOLEAN_AFFECTED; 00088 Affected::_lookupTable["U"] = BOOLEAN_UNAFFECTED; 00089 } 00090 }; 00091 00092 std::ostream& operator<<(std::ostream& s,const Affected& n); 00093 00094 #endif
1.4.4