Geant4 11.3.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4AttValueFilterT< T, ConversionErrorPolicy > Class Template Reference

#include <G4AttValueFilterT.hh>

+ Inheritance diagram for G4AttValueFilterT< T, ConversionErrorPolicy >:

Public Member Functions

 G4AttValueFilterT ()
 
virtual ~G4AttValueFilterT ()
 
G4bool Accept (const G4AttValue &attVal) const
 
G4bool GetValidElement (const G4AttValue &input, G4String &interval) const
 
virtual void PrintAll (std::ostream &ostr) const
 
virtual void Reset ()
 
void LoadIntervalElement (const G4String &input)
 
void LoadSingleValueElement (const G4String &input)
 
- Public Member Functions inherited from G4ConversionFatalError
void ReportError (const G4String &input, const G4String &message) const
 
- Public Member Functions inherited from G4VAttValueFilter
 G4VAttValueFilter (const G4String &name="G4AttValueFilter")
 
virtual ~G4VAttValueFilter ()
 
- Public Member Functions inherited from G4VFilter< G4AttValue >
 G4VFilter (const G4String &name)
 
virtual ~G4VFilter ()
 
G4String Name () const
 
G4String GetName () const
 

Additional Inherited Members

- Public Types inherited from G4VFilter< G4AttValue >
typedef G4AttValue Type
 

Detailed Description

template<typename T, typename ConversionErrorPolicy = G4ConversionFatalError>
class G4AttValueFilterT< T, ConversionErrorPolicy >

Definition at line 73 of file G4AttValueFilterT.hh.

Constructor & Destructor Documentation

◆ G4AttValueFilterT()

template<typename T, typename ConversionErrorPolicy>
G4AttValueFilterT< T, ConversionErrorPolicy >::G4AttValueFilterT ( )

Definition at line 109 of file G4AttValueFilterT.hh.

109{}

◆ ~G4AttValueFilterT()

template<typename T, typename ConversionErrorPolicy>
G4AttValueFilterT< T, ConversionErrorPolicy >::~G4AttValueFilterT ( )
virtual

Definition at line 112 of file G4AttValueFilterT.hh.

112{}

Member Function Documentation

◆ Accept()

template<typename T, typename ConversionErrorPolicy>
G4bool G4AttValueFilterT< T, ConversionErrorPolicy >::Accept ( const G4AttValue & attVal) const
virtual

Implements G4VAttValueFilter.

Definition at line 144 of file G4AttValueFilterT.hh.

145{
146 T value{};
147
148 G4String input = attValue.GetValue();
149 if (!G4ConversionUtils::Convert(input, value)) ConversionErrorPolicy::ReportError(input, "Invalid format. Was the input data formatted correctly ?");
150
152 std::find_if(fSingleValueMap.begin(), fSingleValueMap.end(), IsEqual<T>(value));
153
154 if (iterValues != fSingleValueMap.end()) return true;
155
157 std::find_if(fIntervalMap.begin(), fIntervalMap.end(), InInterval<T>(value));
158
159 if (iterIntervals != fIntervalMap.end()) return true;
160
161 return false;
162}

◆ GetValidElement()

template<typename T, typename ConversionErrorPolicy>
G4bool G4AttValueFilterT< T, ConversionErrorPolicy >::GetValidElement ( const G4AttValue & input,
G4String & interval ) const
virtual

Implements G4VAttValueFilter.

Definition at line 116 of file G4AttValueFilterT.hh.

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
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
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}

◆ LoadIntervalElement()

template<typename T, typename ConversionErrorPolicy>
void G4AttValueFilterT< T, ConversionErrorPolicy >::LoadIntervalElement ( const G4String & input)
virtual

Implements G4VAttValueFilter.

Definition at line 166 of file G4AttValueFilterT.hh.

167{
168 T min{};
169 T max{};
170
171 if (!G4ConversionUtils::Convert(input, min, max)) ConversionErrorPolicy::ReportError(input, "Invalid format. Was the input data formatted correctly ?");
172
173 fIntervalMap[input] = std::pair<T, T> (min, max);
174}

◆ LoadSingleValueElement()

template<typename T, typename ConversionErrorPolicy>
void G4AttValueFilterT< T, ConversionErrorPolicy >::LoadSingleValueElement ( const G4String & input)
virtual

Implements G4VAttValueFilter.

Definition at line 178 of file G4AttValueFilterT.hh.

179{
180 T output{};
181
182 if (!G4ConversionUtils::Convert(input, output)) ConversionErrorPolicy::ReportError(input, "Invalid format. Was the input data formatted correctly ?");
183
184 fSingleValueMap[input] = std::move(output);
185}

◆ PrintAll()

template<typename T, typename ConversionErrorPolicy>
void G4AttValueFilterT< T, ConversionErrorPolicy >::PrintAll ( std::ostream & ostr) const
virtual

Implements G4VAttValueFilter.

Definition at line 189 of file G4AttValueFilterT.hh.

190{
191 ostr<<"Printing data for filter: "<<Name()<<std::endl;
192
193 ostr<<"Interval data:"<<std::endl;
194
195 typename IntervalMap::const_iterator iterIntervals = fIntervalMap.begin();
196
197 while (iterIntervals != fIntervalMap.end()) {
198 ostr<<iterIntervals->second.first<<" : "<<iterIntervals->second.second<<std::endl;
200 }
201
202 ostr<<"Single value data:"<<std::endl;
203
204 typename SingleValueMap::const_iterator iterValues = fSingleValueMap.begin();
205
206 while (iterValues != fSingleValueMap.end()) {
207 ostr<<iterValues->second<<std::endl;
208 iterValues++;
209 }
210}
G4String Name() const
Definition G4VFilter.hh:80

◆ Reset()

template<typename T, typename ConversionErrorPolicy>
void G4AttValueFilterT< T, ConversionErrorPolicy >::Reset ( )
virtual

Implements G4VAttValueFilter.

Definition at line 214 of file G4AttValueFilterT.hh.

215{
216 fIntervalMap.clear();
217 fSingleValueMap.clear();
218}

The documentation for this class was generated from the following file: