32 #ifndef G4ATTRIBUTEFILTERT_HH
33 #define G4ATTRIBUTEFILTERT_HH
55 virtual bool Evaluate(
const T&)
const;
58 virtual void Print(std::ostream& ostr)
const;
72 typedef std::pair<G4String, Config>
Pair;
91 ,fWarnedMissingAttribute(false)
101 template <
typename T>
106 if (fAttName.isNull()) {
108 if (!fWarnedMissingAttribute) {
110 fWarnedMissingAttribute =
true;
125 static G4bool warnedUnableToExtract =
false;
126 if (!warnedUnableToExtract) {
128 ed <<
"Unable to extract attribute definition named "<<fAttName;
130 (
"G4AttributeFilterT::Evaluate",
"modeling0102",
JustWarning, ed,
"Invalid attribute definition");
131 G4cout <<
"Available attributes:\n"
132 <<
object.GetAttDefs();
133 warnedUnableToExtract =
true;
142 typename ConfigVect::const_iterator iter = fConfigVect.begin();
144 while (iter != fConfigVect.end()) {
156 static G4bool warnedUnableToExtract =
false;
157 if (!warnedUnableToExtract) {
159 ed <<
"Unable to extract attribute value named "<<fAttName;
161 (
"G4AttributeFilterT::Evaluate",
"modeling0103",
JustWarning, ed,
"InvalidAttributeValue");
162 G4cout <<
"Available attributes:\n"
163 <<
object.GetAttDefs();
164 warnedUnableToExtract =
true;
170 G4cout<<
"G4AttributeFilterT processing attribute named "<<fAttName;
175 return (filter->Accept(attVal));
178 template <
typename T>
183 if (0 != filter) filter->Reset();
186 template <
typename T>
190 ostr<<
"Printing data for G4Attribute filter named: "<<
G4VFilter<T>::Name()<<std::endl;
191 ostr<<
"Filtered attribute name: "<<fAttName<<std::endl;
192 ostr<<
"Printing sub filter data:"<<std::endl;
193 if (0 != filter) filter->PrintAll(ostr);
196 template <
typename T>
203 template <
typename T>
209 typename ConfigVect::iterator iter = std::find(fConfigVect.begin(), fConfigVect.end(), myPair);
211 if (iter != fConfigVect.end()) {
213 ed <<
"Interval "<< interval <<
" already exists";
215 (
"G4AttributeFilterT::AddInterval",
"modeling0104",
JustWarning, ed);
219 fConfigVect.push_back(myPair);
222 template <
typename T>
228 typename ConfigVect::iterator iter = std::find(fConfigVect.begin(), fConfigVect.end(), myPair);
230 if (iter != fConfigVect.end()) {
232 ed <<
"Single value "<< value <<
" already exists";
234 (
"G4AttributeFilterT::AddValue",
"modeling0105",
JustWarning, ed);
237 fConfigVect.push_back(myPair);
G4VAttValueFilter * filter
std::ostringstream G4ExceptionDescription
void AddInterval(const G4String &)
G4VAttValueFilter * GetNewFilter(const G4AttDef &def)
void AddValue(const G4String &)
virtual ~G4AttributeFilterT()
G4bool fWarnedMissingAttribute
const XML_Char int const XML_Char * value
std::vector< Pair > ConfigVect
std::pair< G4String, Config > Pair
virtual bool Evaluate(const T &) const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
G4AttributeFilterT(const G4String &name="Unspecified")
G4GLOB_DLL std::ostream G4cout
void Set(const G4String &name)
G4bool ExtractAttValue(const T &object, const G4String &name, G4AttValue &attVal)
G4bool ExtractAttDef(const T &object, const G4String &name, G4AttDef &def)
virtual void Print(std::ostream &ostr) const
const G4String & GetValue() const