Warning, file /geant4/examples/extended/medical/dna/moleculardna/include/MoleculeList.hh was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030 #ifndef MOLECULAR_MOLECULE_LIST_HH
0031 #define MOLECULAR_MOLECULE_LIST_HH
0032
0033 #include "DNAHashing.hh"
0034
0035 #include "globals.hh"
0036
0037 typedef enum molecule
0038 {
0039 UNSPECIFIED,
0040 SUGAR,
0041 PHOSPHATE,
0042 GUANINE,
0043 ADENINE,
0044 CYTOSINE,
0045 THYMINE,
0046 Count
0047 } molecule;
0048
0049
0050
0051 namespace utility
0052 {
0053 using namespace G4::hashing;
0054
0055 #define CT_HASHER(x) larson::Cthash(x)
0056 #define DEFINE_HASHER
0057 #define RT_HASHER(x) larson::Hash(x)
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080 static constexpr size_t fSugar_h = CT_HASHER("SUGAR");
0081 static constexpr size_t fP_h = CT_HASHER("PHOSPHATE");
0082 static constexpr size_t fA_h = CT_HASHER("ADENINE");
0083 static constexpr size_t fG_h = CT_HASHER("GUANINE");
0084 static constexpr size_t fT_h = CT_HASHER("THYMINE");
0085 static constexpr size_t fC_h = CT_HASHER("CYTOSINE");
0086
0087 inline ::molecule GetMoleculeEnum(const G4String& mol)
0088 {
0089 G4String _mol(mol);
0090 std::transform(_mol.begin(), _mol.end(), _mol.begin(), ::toupper);
0091
0092 DEFINE_HASHER
0093 size_t mol_h = RT_HASHER(std::string(_mol));
0094
0095 switch (mol_h) {
0096 case fSugar_h:
0097
0098 return SUGAR;
0099 case fP_h:
0100
0101 return PHOSPHATE;
0102 case fA_h:
0103
0104 return ADENINE;
0105 case fG_h:
0106
0107 return GUANINE;
0108 case fC_h:
0109
0110 return CYTOSINE;
0111 case fT_h:
0112
0113 return THYMINE;
0114 default:
0115
0116
0117 G4Exception("MolecularMoleculeList::GetMoleculeEnum", "ERR_UNKNOWN_MOLECULE", JustWarning,
0118 "Unknown molecule");
0119 return UNSPECIFIED;
0120 }
0121 }
0122
0123 inline G4String GetMoleculeEnumString(::molecule mol)
0124 {
0125 switch (mol) {
0126 case PHOSPHATE:
0127 return "Phosphate";
0128 case SUGAR:
0129 return "Sugar";
0130 case GUANINE:
0131 return "Guanine";
0132 case ADENINE:
0133 return "Adenine";
0134 case CYTOSINE:
0135 return "Cytosine";
0136 case THYMINE:
0137 return "Thymine";
0138 default:
0139 return "Unspecified";
0140 }
0141 }
0142
0143
0144 inline int TestMoleculeEnum()
0145 {
0146 G4cout << GetMoleculeEnumString(utility::GetMoleculeEnum(G4String("PHOSPHATE"))) << G4endl;
0147
0148 G4cout << GetMoleculeEnumString(utility::GetMoleculeEnum(G4String("SUGAR"))) << G4endl;
0149
0150 G4cout << GetMoleculeEnumString(utility::GetMoleculeEnum(G4String("GUANINE"))) << G4endl;
0151
0152 G4cout << GetMoleculeEnumString(utility::GetMoleculeEnum(G4String("ADENINE"))) << G4endl;
0153
0154 G4cout << GetMoleculeEnumString(utility::GetMoleculeEnum(G4String("THYMINE"))) << G4endl;
0155
0156 G4cout << GetMoleculeEnumString(utility::GetMoleculeEnum(G4String("CYTOSINE"))) << G4endl;
0157
0158 G4cout << GetMoleculeEnumString(utility::GetMoleculeEnum(G4String("CyToSiNe"))) << G4endl;
0159
0160 return 0;
0161 }
0162 }
0163
0164
0165
0166 #endif