|
|
|||
File indexing completed on 2025-12-16 09:30:06
0001 // 0002 // ******************************************************************** 0003 // * License and Disclaimer * 0004 // * * 0005 // * The Geant4 software is copyright of the Copyright Holders of * 0006 // * the Geant4 Collaboration. It is provided under the terms and * 0007 // * conditions of the Geant4 Software License, included in the file * 0008 // * LICENSE and available at http://cern.ch/geant4/license . These * 0009 // * include a list of copyright holders. * 0010 // * * 0011 // * Neither the authors of this software system, nor their employing * 0012 // * institutes,nor the agencies providing financial support for this * 0013 // * work make any representation or warranty, express or implied, * 0014 // * regarding this software system or assume any liability for its * 0015 // * use. Please see the license in the file LICENSE and URL above * 0016 // * for the full disclaimer and the limitation of liability. * 0017 // * * 0018 // * This code implementation is the result of the scientific and * 0019 // * technical work of the GEANT4 collaboration. * 0020 // * By using, copying, modifying or distributing the software (or * 0021 // * any work based on the software) you agree to acknowledge its * 0022 // * use in resulting scientific publications, and indicate your * 0023 // * acceptance of all terms of the Geant4 Software license. * 0024 // ******************************************************************** 0025 // 0026 // 0027 /// \file VectorAccummulable.hh 0028 /// \brief Definition of the VectorAccummulable class 0029 /// 0030 /// This class defines an accummulable of a vector<T> type 0031 /// that merges the vectors filled on workers in a single vector. 0032 0033 #ifndef VectorAccumulable_h 0034 #define VectorAccumulable_h 1 0035 0036 #include "G4VAccumulable.hh" 0037 #include "globals.hh" 0038 0039 #include <vector> 0040 0041 template<typename T> 0042 class VectorAccumulable : public G4VAccumulable 0043 { 0044 public: 0045 VectorAccumulable() = default; 0046 ~VectorAccumulable() override = default; 0047 0048 void AddValue(T value); 0049 const std::vector<T>& GetVector() const; 0050 0051 void Merge(const G4VAccumulable& other) override; 0052 void Reset() override; 0053 0054 private: 0055 std::vector<T> fTVector; 0056 }; 0057 0058 // inline functions 0059 0060 template<typename T> 0061 inline void VectorAccumulable<T>::AddValue(T value) 0062 { 0063 fTVector.push_back(value); 0064 } 0065 0066 template<typename T> 0067 inline const std::vector<T>& VectorAccumulable<T>::GetVector() const 0068 { 0069 return fTVector; 0070 } 0071 0072 template<typename T> 0073 inline void VectorAccumulable<T>::Merge(const G4VAccumulable& other) 0074 { 0075 for (const auto& value : static_cast<const VectorAccumulable<T>&>(other).fTVector) { 0076 fTVector.push_back(value); 0077 } 0078 } 0079 0080 template<typename T> 0081 inline void VectorAccumulable<T>::Reset() 0082 { 0083 fTVector.clear(); 0084 } 0085 0086 #endif
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|