MCPcopy Create free account
hub / github.com/Geant4/geant4 / GetValidElement

Method GetValidElement

source/visualization/modeling/include/G4AttValueFilterT.hh:115–140  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

113
114template <typename T, typename ConversionErrorPolicy>
115G4bool
116G4AttValueFilterT<T, ConversionErrorPolicy>::GetValidElement(const G4AttValue& attValue, G4String& element) const
117{
118 T value{};
119
120 G4String input = attValue.GetValue();
121 if (!G4ConversionUtils::Convert(input, value)) ConversionErrorPolicy::ReportError(input, "Invalid format. Was the input data formatted correctly ?");
122
123 typename SingleValueMap::const_iterator iterValues =
124 std::find_if(fSingleValueMap.begin(), fSingleValueMap.end(), IsEqual<T>(value));
125
126 if (iterValues != fSingleValueMap.end()) {
127 element = iterValues->first;
128 return true;
129 }
130
131 typename IntervalMap::const_iterator iterIntervals =
132 std::find_if(fIntervalMap.begin(), fIntervalMap.end(), InInterval<T>(value));
133
134 if (iterIntervals != fIntervalMap.end()) {
135 element = iterIntervals->first;
136 return true;
137 }
138
139 return false;
140}
141
142template <typename T, typename ConversionErrorPolicy>
143G4bool

Callers 1

DrawMethod · 0.80

Calls 4

ConvertFunction · 0.85
GetValueMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected