File indexing completed on 2026-04-09 07:49:31
0001 #pragma once
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #include <cstring>
0016
0017 enum {
0018 SEVT_UNDEFINED,
0019 SEVT_GENSTEP,
0020 SEVT_NOPSTEP,
0021 SEVT_PHOTON,
0022 SEVT_DEBUG,
0023 SEVT_WAY,
0024 SEVT_SOURCE,
0025 SEVT_RECORD,
0026 SEVT_DELUXE,
0027 SEVT_PHOSEL,
0028 SEVT_RECSEL,
0029 SEVT_SEQUENCE,
0030 SEVT_BOUNDARY,
0031 SEVT_SEED,
0032 SEVT_HIT,
0033 SEVT_HIY,
0034 SEVT_FDOM,
0035 SEVT_IDOM,
0036 SEVT_G4STATES
0037 };
0038
0039 struct SComponent_OLD
0040 {
0041 static bool StartsWith( const char* s, const char* q);
0042 static const char* Name(unsigned comp);
0043 static unsigned Component(const char* name);
0044
0045 static constexpr const char* UNDEFINED_ = "undefined" ;
0046 static constexpr const char* GENSTEP_ = "genstep" ;
0047 static constexpr const char* NOPSTEP_ = "nopstep" ;
0048 static constexpr const char* PHOTON_ = "photon" ;
0049 static constexpr const char* DEBUG_ = "debug" ;
0050 static constexpr const char* WAY_ = "way" ;
0051 static constexpr const char* SOURCE_ = "source" ;
0052 static constexpr const char* RECORD_ = "record" ;
0053 static constexpr const char* DELUXE_ = "deluxe" ;
0054 static constexpr const char* PHOSEL_ = "phosel" ;
0055 static constexpr const char* RECSEL_ = "recsel" ;
0056 static constexpr const char* SEQUENCE_ = "sequence" ;
0057 static constexpr const char* BOUNDARY_ = "boundary" ;
0058 static constexpr const char* SEED_ = "seed" ;
0059 static constexpr const char* HIT_ = "hit" ;
0060 static constexpr const char* HIY_ = "hiy" ;
0061 static constexpr const char* FDOM_ = "fdom" ;
0062 static constexpr const char* IDOM_ = "idom" ;
0063 static constexpr const char* G4STATES_ = "g4states" ;
0064 };
0065
0066 inline bool SComponent_OLD::StartsWith( const char* s, const char* q)
0067 {
0068 return s && q && strlen(q) <= strlen(s) && strncmp(s, q, strlen(q)) == 0 ;
0069 }
0070
0071 inline unsigned SComponent_OLD::Component(const char* name)
0072 {
0073 unsigned comp = SEVT_UNDEFINED ;
0074 if(StartsWith(name, GENSTEP_)) comp = SEVT_GENSTEP ;
0075 if(StartsWith(name, NOPSTEP_)) comp = SEVT_NOPSTEP ;
0076 if(StartsWith(name, PHOTON_)) comp = SEVT_PHOTON ;
0077 if(StartsWith(name, DEBUG_)) comp = SEVT_DEBUG ;
0078 if(StartsWith(name, WAY_)) comp = SEVT_WAY ;
0079 if(StartsWith(name, SOURCE_)) comp = SEVT_SOURCE ;
0080 if(StartsWith(name, RECORD_)) comp = SEVT_RECORD ;
0081 if(StartsWith(name, DELUXE_)) comp = SEVT_DELUXE ;
0082 if(StartsWith(name, PHOSEL_)) comp = SEVT_PHOSEL ;
0083 if(StartsWith(name, RECSEL_)) comp = SEVT_RECSEL ;
0084 if(StartsWith(name, SEQUENCE_)) comp = SEVT_SEQUENCE ;
0085 if(StartsWith(name, BOUNDARY_)) comp = SEVT_BOUNDARY ;
0086 if(StartsWith(name, SEED_)) comp = SEVT_SEED ;
0087 if(StartsWith(name, HIT_)) comp = SEVT_HIT ;
0088 if(StartsWith(name, HIY_)) comp = SEVT_HIY ;
0089 if(StartsWith(name, FDOM_)) comp = SEVT_FDOM ;
0090 if(StartsWith(name, IDOM_)) comp = SEVT_IDOM ;
0091 if(StartsWith(name, G4STATES_)) comp = SEVT_G4STATES ;
0092 return comp ;
0093 }
0094
0095 inline const char* SComponent_OLD::Name(unsigned comp)
0096 {
0097 const char* s = nullptr ;
0098 switch(comp)
0099 {
0100 case SEVT_UNDEFINED: s = UNDEFINED_ ; break ;
0101 case SEVT_GENSTEP: s = GENSTEP_ ; break ;
0102 case SEVT_NOPSTEP: s = NOPSTEP_ ; break ;
0103 case SEVT_PHOTON: s = PHOTON_ ; break ;
0104 case SEVT_DEBUG: s = DEBUG_ ; break ;
0105 case SEVT_WAY: s = WAY_ ; break ;
0106 case SEVT_SOURCE: s = SOURCE_ ; break ;
0107 case SEVT_RECORD: s = RECORD_ ; break ;
0108 case SEVT_DELUXE: s = DELUXE_ ; break ;
0109 case SEVT_PHOSEL: s = PHOSEL_ ; break ;
0110 case SEVT_RECSEL: s = RECSEL_ ; break ;
0111 case SEVT_SEQUENCE: s = SEQUENCE_ ; break ;
0112 case SEVT_BOUNDARY: s = BOUNDARY_ ; break ;
0113 case SEVT_SEED: s = SEED_ ; break ;
0114 case SEVT_HIT: s = HIT_ ; break ;
0115 case SEVT_HIY: s = HIY_ ; break ;
0116 case SEVT_FDOM: s = FDOM_ ; break ;
0117 case SEVT_IDOM: s = IDOM_ ; break ;
0118 case SEVT_G4STATES: s = G4STATES_ ; break ;
0119 }
0120 return s ;
0121 }
0122