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

Twin.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 and Ritu Khanna
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.09.08.ET
00024 //
00025 
00026 //
00027 // Twin.h
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         // Constructors:
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         // Setters:
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                         // To distinguish between twin types with the same marker a twin type character is appended to the  markers
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                         // To distinguish between twin types with the same marker a twin type character is appended to the markers
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         // get():  Returns the original marker set by the user
00108         const std::string get(void) const { 
00109                 
00110                 if(_isMissing) return ".";
00111                 // Removes the twin type character that is appended to the marker
00112                 std::string temp = String::get();
00113                 return temp.erase(1);
00114                 
00115         }
00116         
00117         //
00118         // Get methods not present in base "String" class:
00119         //
00120         const std::string getTwinType( void ) const;
00121         const TWIN_TYPE getTwinTypeEnum( void ) const { return _twinType; }
00122         // Returns the marker that includes the distinguishing twin type character between twin types:
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

Generated on Fri Nov 18 16:24:39 2011 for MADELINE by  doxygen 1.4.4