32#ifndef G4ATTRIBUTEFILTERT_HH
33#define G4ATTRIBUTEFILTERT_HH
55 virtual bool Evaluate(
const T&)
const;
58 virtual void Print(std::ostream& ostr)
const;
70 enum Config {Interval, SingleValue};
72 typedef std::pair<G4String, Config> Pair;
73 typedef std::vector<Pair> ConfigVect;
77 ConfigVect fConfigVect;
81 mutable G4bool fWarnedMissingAttribute;
91 ,fWarnedMissingAttribute(false)
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));
183 if (0 != filter) filter->Reset();
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);
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);
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);
G4DLLIMPORT std::ostream G4cout
const G4String & GetValue() const
virtual ~G4AttributeFilterT()
void AddValue(const G4String &)
void Set(const G4String &name)
G4AttributeFilterT(const G4String &name="Unspecified")
virtual bool Evaluate(const T &) const
void AddInterval(const G4String &)
virtual void Print(std::ostream &ostr) const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
std::ostringstream G4ExceptionDescription
G4VAttValueFilter * GetNewFilter(const G4AttDef &def)
G4bool ExtractAttDef(const T &object, const G4String &name, G4AttDef &def)
G4bool ExtractAttValue(const T &object, const G4String &name, G4AttValue &attVal)