Geant4 10.7.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 ()
 
virtual G4bool Accept (const G4AttValue &) const =0
 
virtual G4bool GetValidElement (const G4AttValue &, G4String &) const =0
 
virtual void PrintAll (std::ostream &ostr) const =0
 
virtual void Reset ()=0
 
virtual void LoadIntervalElement (const G4String &)=0
 
virtual void LoadSingleValueElement (const G4String &)=0
 
- Public Member Functions inherited from G4VFilter< G4AttValue >
 G4VFilter (const G4String &name)
 
virtual ~G4VFilter ()
 
virtual G4bool Accept (const G4AttValue &) const=0
 
virtual void PrintAll (std::ostream &ostr) const=0
 
virtual void Reset ()=0
 
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 71 of file G4AttValueFilterT.hh.

Constructor & Destructor Documentation

◆ G4AttValueFilterT()

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

Definition at line 107 of file G4AttValueFilterT.hh.

107{}

◆ ~G4AttValueFilterT()

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

Definition at line 110 of file G4AttValueFilterT.hh.

110{}

Member Function Documentation

◆ Accept()

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

Implements G4VAttValueFilter.

Definition at line 142 of file G4AttValueFilterT.hh.

143{
144 T value;
145
146 G4String input = attValue.GetValue();
147 if (!G4ConversionUtils::Convert(input, value)) ConversionErrorPolicy::ReportError(input, "Invalid format. Was the input data formatted correctly ?");
148
149 typename SingleValueMap::const_iterator iterValues =
150 std::find_if(fSingleValueMap.begin(), fSingleValueMap.end(), IsEqual<T>(value));
151
152 if (iterValues != fSingleValueMap.end()) return true;
153
154 typename IntervalMap::const_iterator iterIntervals =
155 std::find_if(fIntervalMap.begin(), fIntervalMap.end(), InInterval<T>(value));
156
157 if (iterIntervals != fIntervalMap.end()) return true;
158
159 return false;
160}
G4bool Convert(const G4String &myInput, Value &output)

◆ GetValidElement()

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

Implements G4VAttValueFilter.

Definition at line 114 of file G4AttValueFilterT.hh.

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

◆ LoadIntervalElement()

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

Implements G4VAttValueFilter.

Definition at line 164 of file G4AttValueFilterT.hh.

165{
166 T min;
167 T max;
168
169 if (!G4ConversionUtils::Convert(input, min, max)) ConversionErrorPolicy::ReportError(input, "Invalid format. Was the input data formatted correctly ?");
170
171 std::pair<T, T> myPair(min, max);
172 fIntervalMap[input] = myPair;
173}
T max(const T t1, const T t2)
brief Return the largest of the two arguments
T min(const T t1, const T t2)
brief Return the smallest of the two arguments

◆ LoadSingleValueElement()

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

Implements G4VAttValueFilter.

Definition at line 177 of file G4AttValueFilterT.hh.

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

◆ PrintAll()

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

Implements G4VAttValueFilter.

Definition at line 188 of file G4AttValueFilterT.hh.

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

◆ Reset()

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

Implements G4VAttValueFilter.

Definition at line 213 of file G4AttValueFilterT.hh.

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

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