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

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

Definition at line 235 of file G4AttCheck.cc.

References G4AttCheck::fCategories, G4AttCheck::fpDefinitions, G4AttCheck::fpValues, G4AttCheck::fUnits, G4AttCheck::fValueTypes, and G4AttDefStore::GetStoreKey().

00236 {
00237   using namespace std;
00238   if (!ac.fpDefinitions) {
00239     os << "G4AttCheck: ERROR: zero definitions pointer." << endl;
00240     return os;
00241   }
00242   G4String storeKey;
00243   if (G4AttDefStore::GetStoreKey(ac.fpDefinitions, storeKey)) {
00244     os << storeKey << ':' << endl;
00245   }
00246   if (!ac.fpValues) {
00247     // A null values vector is a valid situation.
00248     os << "G4AttCheck: zero values pointer." << endl;
00249     return os;
00250   }
00251   vector<G4AttValue>::const_iterator iValue;
00252   for (iValue = ac.fpValues->begin(); iValue != ac.fpValues->end(); ++iValue) {
00253     const G4String& valueName = iValue->GetName();
00254     const G4String& value = iValue->GetValue();
00255     map<G4String,G4AttDef>::const_iterator iDef =
00256       ac.fpDefinitions->find(valueName);
00257     G4bool error = false;
00258     if (iDef == ac.fpDefinitions->end()) {
00259       error = true;
00260       os << "G4AttCheck: ERROR: No G4AttDef for G4AttValue \""
00261          << valueName << "\": " << value << endl;
00262     } else {
00263       const G4String& category = iDef->second.GetCategory();
00264       const G4String& extra = iDef->second.GetExtra();
00265       const G4String& valueType = iDef->second.GetValueType();
00266       if (ac.fCategories.find(category) == ac.fCategories.end()) {
00267         error = true;
00268         os <<
00269           "G4AttCheck: ERROR: Illegal Category Field \"" << category
00270            << "\" for G4AttValue \"" << valueName << "\": " << value <<
00271           "\n  Possible Categories:";
00272         set<G4String>::iterator i;
00273         for (i = ac.fCategories.begin(); i != ac.fCategories.end(); ++i) {
00274           os << ' ' << *i;
00275         }
00276         os << endl;
00277       }
00278       if(category == "Physics" && ac.fUnits.find(extra) == ac.fUnits.end()) {
00279         error = true;
00280         os <<
00281           "G4AttCheck: ERROR: Illegal Extra field \""<< extra
00282            << "\" for G4AttValue \"" << valueName << "\": " << value <<
00283           "\n  Possible Extra fields if Category==\"Physics\":\n    ";
00284         set<G4String>::iterator i;
00285         for (i = ac.fUnits.begin(); i != ac.fUnits.end(); ++i) {
00286           os << ' ' << *i;
00287         }
00288         os << endl;
00289       }
00290       if (ac.fValueTypes.find(valueType) == ac.fValueTypes.end()) {
00291         error = true;
00292         os <<
00293           "G4AttCheck: ERROR: Illegal Value Type field \"" << valueType
00294            << "\" for G4AttValue \"" << valueName << "\": " << value <<
00295           "\n  Possible Value Types:";
00296         set<G4String>::iterator i;
00297         for (i = ac.fValueTypes.begin(); i != ac.fValueTypes.end(); ++i) {
00298           os << ' ' << *i;
00299         }
00300         os << endl;
00301       }
00302     }
00303     if (!error) {
00304       os << iDef->second.GetDesc()
00305          << " (" << valueName
00306          << "): " << value;
00307       if (iDef->second.GetCategory() == "Physics" &&
00308           !iDef->second.GetExtra().empty()) {
00309         os << " (" << iDef->second.GetExtra() << ")";
00310       }
00311       os << endl;
00312     }
00313   }
00314   return os;
00315 }


Generated on Mon May 27 17:50:38 2013 for Geant4 by  doxygen 1.4.7