00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef Twin_INCLUDED
00031 #define Twin_INCLUDED
00032
00033 #include "String.h"
00034 #include "Warning.h"
00035
00036 class Twin : public String
00037 {
00038 public:
00039
00040 enum TWIN_TYPE{ MONOZYGOTIC_TWIN, DIZYGOTIC_TWIN, ZYGOSITY_UNKNOWN_TWIN ,MISSING_TWIN};
00041
00042 private:
00043
00044 TWIN_TYPE _twinType;
00045 bool _validateTwinMarker(std::string twinMarker);
00046
00047 public:
00048
00049
00050
00051 Twin() { _isMissing = true; }
00052 Twin( const char *twinMarker, TWIN_TYPE twinType) { set(twinMarker, twinType); }
00053 Twin( const std::string twinMarker, TWIN_TYPE twinType) { set(twinMarker, twinType); }
00054
00055
00056
00057
00058 void set(const char *twinMarker,TWIN_TYPE twinType){
00059
00060 if(twinType == Twin::ZYGOSITY_UNKNOWN_TWIN || twinType == Twin::MISSING_TWIN || _validateTwinMarker(twinMarker)){
00061 _twinType = twinType;
00062
00063 std::string temp = twinMarker;
00064 if(twinMarker == ".");
00065 else{
00066 temp+= getTwinType();
00067 String::set(temp);
00068 _isMissing = false;
00069 }
00070 }else{
00071 _isMissing=true;
00072 _value = ".";
00073 Warning("Twin::set()",
00074 "%s is an invalid TwinMarker and has been set to Missing. Allowed TwinMarkers are [A-Za-z]",
00075 twinMarker
00076 );
00077 }
00078
00079 }
00080
00081 void set(const std::string &twinMarker, TWIN_TYPE twinType){
00082
00083 if(twinType == Twin::ZYGOSITY_UNKNOWN_TWIN || twinType == Twin::MISSING_TWIN || _validateTwinMarker(twinMarker)){
00084 std::string temp = twinMarker;
00085
00086 _twinType = twinType;
00087
00088 if(twinMarker == ".");
00089 else{
00090 _isMissing = false;
00091 temp += getTwinType();
00092
00093 }
00094 String::set(temp);
00095 }else{
00096 _isMissing=true;
00097 _value=".";
00098
00099 Warning("Twin::set()",
00100 "%s is an invalid TwinMarker and has been set to Missing. Allowed TwinMarkers are [A-Za-z]",
00101 twinMarker.c_str()
00102 );
00103 }
00104
00105 }
00106
00107
00108 const std::string get(void) const {
00109
00110 if(_isMissing) return ".";
00111
00112 std::string temp = String::get();
00113 return temp.erase(1);
00114
00115 }
00116
00117
00118
00119
00120 const std::string getTwinType( void ) const;
00121 const TWIN_TYPE getTwinTypeEnum( void ) const { return _twinType; }
00122
00123 const std::string getMarker( void ) const { return String::get(); }
00124
00125 static bool isa(std::string inString);
00126
00127 };
00128
00129
00130
00131
00132 #endif