Geant4-11
Public Types | Public Member Functions | Private Types | Private Attributes
G4AttValueFilterT< T, ConversionErrorPolicy > Class Template Reference

#include <G4AttValueFilterT.hh>

Inheritance diagram for G4AttValueFilterT< T, ConversionErrorPolicy >:
G4ConversionFatalError G4VAttValueFilter G4VFilter< G4AttValue >

Public Types

typedef G4AttValue Type
 

Public Member Functions

G4bool Accept (const G4AttValue &attVal) const
 
 G4AttValueFilterT ()
 
G4String GetName () const
 
G4bool GetValidElement (const G4AttValue &input, G4String &interval) const
 
void LoadIntervalElement (const G4String &input)
 
void LoadSingleValueElement (const G4String &input)
 
G4String Name () const
 
virtual void PrintAll (std::ostream &ostr) const
 
void ReportError (const G4String &input, const G4String &message) const
 
virtual void Reset ()
 
virtual ~G4AttValueFilterT ()
 

Private Types

typedef std::map< G4String, PairIntervalMap
 
typedef std::pair< T, T > Pair
 
typedef std::map< G4String, T > SingleValueMap
 

Private Attributes

IntervalMap fIntervalMap
 
G4String fName
 
SingleValueMap fSingleValueMap
 

Detailed Description

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

Definition at line 71 of file G4AttValueFilterT.hh.

Member Typedef Documentation

◆ IntervalMap

template<typename T , typename ConversionErrorPolicy = G4ConversionFatalError>
typedef std::map<G4String, Pair> G4AttValueFilterT< T, ConversionErrorPolicy >::IntervalMap
private

Definition at line 96 of file G4AttValueFilterT.hh.

◆ Pair

template<typename T , typename ConversionErrorPolicy = G4ConversionFatalError>
typedef std::pair<T, T> G4AttValueFilterT< T, ConversionErrorPolicy >::Pair
private

Definition at line 95 of file G4AttValueFilterT.hh.

◆ SingleValueMap

template<typename T , typename ConversionErrorPolicy = G4ConversionFatalError>
typedef std::map<G4String, T> G4AttValueFilterT< T, ConversionErrorPolicy >::SingleValueMap
private

Definition at line 97 of file G4AttValueFilterT.hh.

◆ Type

typedef G4AttValue G4VFilter< G4AttValue >::Type
inherited

Definition at line 43 of file G4VFilter.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}
SingleValueMap fSingleValueMap
G4bool Convert(const G4String &myInput, Value &output)

References G4ConversionUtils::Convert(), and G4AttValue::GetValue().

◆ GetName()

G4String G4VFilter< G4AttValue >::GetName
inherited

Definition at line 61 of file G4VFilter.hh.

88{
89 return Name();
90}
G4String Name() const
Definition: G4VFilter.hh:80

◆ 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

References G4ConversionUtils::Convert(), and G4AttValue::GetValue().

◆ 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

References G4ConversionUtils::Convert(), G4INCL::Math::max(), and G4INCL::Math::min().

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

References G4ConversionUtils::Convert().

◆ Name()

G4String G4VFilter< G4AttValue >::Name
inherited

Definition at line 60 of file G4VFilter.hh.

81{
82 return fName;
83}

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

◆ ReportError()

void G4ConversionFatalError::ReportError ( const G4String input,
const G4String message 
) const
inlineinherited

Definition at line 39 of file G4ConversionFatalError.hh.

39 {
41 ed <<input<<": "<<message<<G4endl;
42 G4Exception("G4ConversionFatalError::ReportError",
43 "greps0101", FatalErrorInArgument, ed);
44 }
@ FatalErrorInArgument
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:40
#define G4endl
Definition: G4ios.hh:57

References FatalErrorInArgument, G4endl, and G4Exception().

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

Field Documentation

◆ fIntervalMap

template<typename T , typename ConversionErrorPolicy = G4ConversionFatalError>
IntervalMap G4AttValueFilterT< T, ConversionErrorPolicy >::fIntervalMap
private

Definition at line 101 of file G4AttValueFilterT.hh.

◆ fName

G4String G4VFilter< G4AttValue >::fName
privateinherited

Definition at line 66 of file G4VFilter.hh.

◆ fSingleValueMap

template<typename T , typename ConversionErrorPolicy = G4ConversionFatalError>
SingleValueMap G4AttValueFilterT< T, ConversionErrorPolicy >::fSingleValueMap
private

Definition at line 102 of file G4AttValueFilterT.hh.


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