// // ******************************************************************** // * License and Disclaimer * // * * // * The Geant4 software is copyright of the Copyright Holders of * // * the Geant4 Collaboration. It is provided under the terms and * // * conditions of the Geant4 Software License, included in the file * // * LICENSE and available at http://cern.ch/geant4/license . These * // * include a list of copyright holders. * // * * // * Neither the authors of this software system, nor their employing * // * institutes,nor the agencies providing financial support for this * // * work make any representation or warranty, express or implied, * // * regarding this software system or assume any liability for its * // * use. Please see the license in the file LICENSE and URL above * // * for the full disclaimer and the limitation of liability. * // * * // * This code implementation is the result of the scientific and * // * technical work of the GEANT4 collaboration. * // * By using, copying, modifying or distributing the software (or * // * any work based on the software) you agree to acknowledge its * // * use in resulting scientific publications, and indicate your * // * acceptance of all terms of the Geant4 Software license. * // ******************************************************************** // // Author: Ivana Hrivnacova, IJCLab IN2P3/CNRS, 07/09/2015 #include "G4AccArray.hh" #include "G4AccMap.hh" #include "G4AccUnorderedMap.hh" #include "G4AccVector.hh" //_____________________________________________________________________________ template G4AccValue* G4AccumulableManager::GetAccumulable(G4VAccumulable* accumulable, G4bool warn) const { // Do not check type if nullptr if (accumulable == nullptr) { return nullptr; } // check type if (! CheckType(accumulable, G4AccType::kValue, warn)) { return nullptr; } return static_cast*>(accumulable); } //_____________________________________________________________________________ template G4AccArray* G4AccumulableManager::GetAccArray(G4VAccumulable* accumulable, G4bool warn) const { // Do not check type if nullptr if (accumulable == nullptr) { return nullptr; } // check type if (! CheckType(accumulable, G4AccType::kArray, warn)) { return nullptr; } return static_cast*>(accumulable); } //_____________________________________________________________________________ template G4AccMap* G4AccumulableManager::GetAccMap(G4VAccumulable* accumulable, G4bool warn) const { // Do not check type if nullptr if (accumulable == nullptr) { return nullptr; } // check type if (! CheckType(accumulable, G4AccType::kMap, warn)) { return nullptr; } return static_cast*>(accumulable); } //_____________________________________________________________________________ template G4AccUnorderedMap* G4AccumulableManager::GetAccUnorderedMap(G4VAccumulable* accumulable, G4bool warn) const { // Do not check type if nullptr if (accumulable == nullptr) { return nullptr; } // check type if (! CheckType(accumulable, G4AccType::kUnorderedMap, warn)) { return nullptr; } return static_cast*>(accumulable); } //_____________________________________________________________________________ template G4AccVector* G4AccumulableManager::GetAccVector(G4VAccumulable* accumulable, G4bool warn) const { // Do not check type if nullptr if (accumulable == nullptr) { return nullptr; } // check type if (! CheckType(accumulable, G4AccType::kVector, warn)) { return nullptr; } return static_cast*>(accumulable); } //_____________________________________________________________________________ template G4AccValue* G4AccumulableManager::CreateAccValue( const G4String& name, T value, G4MergeMode mergeMode) { // do not accept name if it is already used if (!CheckName(name, "CreateAccumulable")) { return 0; } // create accumulable auto accumulable = new G4AccValue(name, value, mergeMode); // register accumulable in the map and vector Register(accumulable); fAccumulablesToDelete.push_back(accumulable); return accumulable; } //_____________________________________________________________________________ template G4AccValue* G4AccumulableManager::CreateAccValue( T value, G4MergeMode mergeMode) { return CreateAccValue(G4String(), value, mergeMode); } // Deprecated function using the old accumulable value name //_____________________________________________________________________________ template G4AccValue* G4AccumulableManager::CreateAccumulable( const G4String& name, T value, G4MergeMode mergeMode) { return CreateAccValue(name, value, mergeMode); } // Deprecated function using the old accumulable value name //_____________________________________________________________________________ template G4AccValue* G4AccumulableManager::CreateAccumulable( T value, G4MergeMode mergeMode) { return CreateAccValue(value, mergeMode); } //_____________________________________________________________________________ template G4bool G4AccumulableManager::Register(G4AccValue& accumulable) { return Register(&accumulable); } //_____________________________________________________________________________ template G4bool G4AccumulableManager::Register(G4AccArray& accumulableArray) { return Register(&accumulableArray); } //_____________________________________________________________________________ template G4bool G4AccumulableManager::Register( G4AccMap& accumulableMap) { return Register(&accumulableMap); } //_____________________________________________________________________________ template G4bool G4AccumulableManager::Register( G4AccUnorderedMap& accumulableUnorderedMap) { return Register(&accumulableUnorderedMap); } //_____________________________________________________________________________ template G4bool G4AccumulableManager::Register(G4AccVector& accumulableVector) { return Register(&accumulableVector); } // Deprecated functions with long name //_____________________________________________________________________________ template G4bool G4AccumulableManager::RegisterAccumulable(G4AccValue& accumulable) { return Register(&accumulable); } //_____________________________________________________________________________ template G4AccValue* G4AccumulableManager::GetAccValue(const G4String& name, G4bool warn) const { // get G4VAccummulable from the map auto accumulable = GetAccumulable(name, warn); return GetAccumulable(accumulable, warn); } //_____________________________________________________________________________ template G4AccArray* G4AccumulableManager::GetAccArray(const G4String& name, G4bool warn) const { // get G4VAccummulable from the map auto accumulable = GetAccumulable(name, warn); return GetAccArray(accumulable, warn); } //_____________________________________________________________________________ template G4AccMap* G4AccumulableManager::GetAccMap(const G4String& name, G4bool warn) const { // get G4VAccummulable from the map auto accumulable = GetAccumulable(name, warn); return GetAccMap(accumulable, warn); } //_____________________________________________________________________________ template G4AccUnorderedMap* G4AccumulableManager::GetAccUnorderedMap(const G4String& name, G4bool warn) const { // get G4VAccummulable from the map auto accumulable = GetAccumulable(name, warn); return GetAccUnorderedMap(accumulable, warn); } //_____________________________________________________________________________ template G4AccVector* G4AccumulableManager::GetAccVector(const G4String& name, G4bool warn) const { // get G4VAccummulable from the map auto accumulable = GetAccumulable(name, warn); return GetAccVector(accumulable, warn); } // Deprecated function using the old accumulable value name //_____________________________________________________________________________ template G4AccValue* G4AccumulableManager::GetAccumulable(const G4String& name, G4bool warn) const { return GetAccValue(name, warn); } //_____________________________________________________________________________ template G4AccValue* G4AccumulableManager::GetAccValue(G4int id, G4bool warn) const { // get G4VAccummulable from the map auto accumulable = GetAccumulable(id, warn); return GetAccumulable(accumulable, warn); } //_____________________________________________________________________________ template G4AccArray* G4AccumulableManager::GetAccArray(G4int id, G4bool warn) const { // get G4VAccummulable from the map auto accumulable = GetAccumulable(id, warn); return GetAccArray(accumulable, warn); } //_____________________________________________________________________________ template G4AccMap* G4AccumulableManager::GetAccMap(G4int id, G4bool warn) const { // get G4VAccummulable from the map auto accumulable = GetAccumulable(id, warn); return GetAccMap(accumulable, warn); } //_____________________________________________________________________________ template G4AccUnorderedMap* G4AccumulableManager::GetAccUnorderedMap(G4int id, G4bool warn) const { // get G4VAccummulable from the map auto accumulable = GetAccumulable(id, warn); return GetAccUnorderedMap(accumulable, warn); } //_____________________________________________________________________________ template G4AccVector* G4AccumulableManager::GetAccVector(G4int id, G4bool warn) const { // get G4VAccummulable from the map auto accumulable = GetAccumulable(id, warn); return GetAccVector(accumulable, warn); } // Deprecated function using the old accumulable value name //_____________________________________________________________________________ template G4AccValue* G4AccumulableManager::GetAccumulable(G4int id, G4bool warn) const { return GetAccValue(id, warn); } //_____________________________________________________________________________ inline G4int G4AccumulableManager::GetNofAccumulables() const { return G4int(fVector.size()); } //_____________________________________________________________________________ inline std::vector::iterator G4AccumulableManager::Begin() { return fVector.begin(); } //_____________________________________________________________________________ inline std::vector::iterator G4AccumulableManager::End() { return fVector.end(); } //_____________________________________________________________________________ inline std::vector::const_iterator G4AccumulableManager::BeginConst() const { return fVector.begin(); } //_____________________________________________________________________________ inline std::vector::const_iterator G4AccumulableManager::EndConst() const { return fVector.end(); } //_____________________________________________________________________________ inline void G4AccumulableManager::SetVerboseLevel(G4int value) { G4Accumulables::VerboseLevel = value; } //_____________________________________________________________________________ inline G4int G4AccumulableManager::GetVerboseLevel() const { return G4Accumulables::VerboseLevel; }