Geant4-11
Functions
G4AttCheck.cc File Reference
#include "G4AttCheck.hh"
#include "globals.hh"
#include "G4AttDef.hh"
#include "G4AttDefStore.hh"
#include "G4AttValue.hh"
#include "G4UnitsTable.hh"
#include "G4UIcommand.hh"

Go to the source code of this file.

Functions

std::ostream & operator<< (std::ostream &os, const G4AttCheck &ac)
 

Function Documentation

◆ operator<<()

std::ostream & operator<< ( std::ostream &  os,
const G4AttCheck ac 
)

Definition at line 248 of file G4AttCheck.cc.

249{
250 using namespace std;
251 if (!ac.fpDefinitions) {
252 os << "G4AttCheck: ERROR: zero definitions pointer." << endl;
253 return os;
254 }
255 G4String storeKey;
256 if (G4AttDefStore::GetStoreKey(ac.fpDefinitions, storeKey)) {
257 os << storeKey << ':' << endl;
258 }
259 if (!ac.fpValues) {
260 // A null values vector is a valid situation.
261 os << "G4AttCheck: zero values pointer." << endl;
262 return os;
263 }
264 vector<G4AttValue>::const_iterator iValue;
265 for (iValue = ac.fpValues->begin(); iValue != ac.fpValues->end(); ++iValue) {
266 const G4String& valueName = iValue->GetName();
267 const G4String& value = iValue->GetValue();
268 map<G4String,G4AttDef>::const_iterator iDef =
269 ac.fpDefinitions->find(valueName);
270 G4bool error = false;
271 if (iDef == ac.fpDefinitions->end()) {
272 error = true;
273 os << "G4AttCheck: ERROR: No G4AttDef for G4AttValue \""
274 << valueName << "\": " << value << endl;
275 } else {
276 const G4String& category = iDef->second.GetCategory();
277 const G4String& extra = iDef->second.GetExtra();
278 const G4String& valueType = iDef->second.GetValueType();
279 if (ac.fCategories->find(category) == ac.fCategories->end()) {
280 error = true;
281 os <<
282 "G4AttCheck: ERROR: Illegal Category Field \"" << category
283 << "\" for G4AttValue \"" << valueName << "\": " << value <<
284 "\n Possible Categories:";
285 set<G4String>::iterator i;
286 for (i = ac.fCategories->begin(); i != ac.fCategories->end(); ++i) {
287 os << ' ' << *i;
288 }
289 os << endl;
290 }
291 if(category == "Physics" && ac.fUnits->find(extra) == ac.fUnits->end()) {
292 error = true;
293 os <<
294 "G4AttCheck: ERROR: Illegal Extra field \""<< extra
295 << "\" for G4AttValue \"" << valueName << "\": " << value <<
296 "\n Possible Extra fields if Category==\"Physics\":\n ";
297 set<G4String>::iterator i;
298 for (i = ac.fUnits->begin(); i != ac.fUnits->end(); ++i) {
299 os << ' ' << *i;
300 }
301 os << endl;
302 }
303 if (ac.fValueTypes->find(valueType) == ac.fValueTypes->end()) {
304 error = true;
305 os <<
306 "G4AttCheck: ERROR: Illegal Value Type field \"" << valueType
307 << "\" for G4AttValue \"" << valueName << "\": " << value <<
308 "\n Possible Value Types:";
309 set<G4String>::iterator i;
310 for (i = ac.fValueTypes->begin(); i != ac.fValueTypes->end(); ++i) {
311 os << ' ' << *i;
312 }
313 os << endl;
314 }
315 }
316 if (!error) {
317 os << iDef->second.GetDesc()
318 << " (" << valueName
319 << "): " << value;
320 if (iDef->second.GetCategory() == "Physics" &&
321 !iDef->second.GetExtra().empty()) {
322 os << " (" << iDef->second.GetExtra() << ")";
323 }
324 os << endl;
325 }
326 }
327 return os;
328}
bool G4bool
Definition: G4Types.hh:86
static G4ThreadLocal std::set< G4String > * fUnits
Definition: G4AttCheck.hh:106
const std::map< G4String, G4AttDef > * fpDefinitions
Definition: G4AttCheck.hh:100
static G4ThreadLocal std::set< G4String > * fCategories
Definition: G4AttCheck.hh:105
static G4ThreadLocal std::set< G4String > * fValueTypes
Definition: G4AttCheck.hh:107
const std::vector< G4AttValue > * fpValues
Definition: G4AttCheck.hh:99
G4bool GetStoreKey(const std::map< G4String, G4AttDef > *definitions, G4String &key)
static PROLOG_HANDLER error
Definition: xmlrole.cc:127