Geant4 Cross Reference |
1 // 2 // ******************************************************************** 3 // * License and Disclaimer * 4 // * * 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. * 10 // * * 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitation of liability. * 17 // * * 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************************************** 25 // 26 // 27 /// \file UserMolecule.hh 28 /// \brief Definition of the UserMolecule class 29 30 #ifndef UserMolecule_h 31 #define UserMolecule_h 32 33 #include "G4Molecule.hh" 34 class UserMolecule : public G4Molecule 35 { 36 public: 37 using G4Molecule::G4Molecule; 38 ~UserMolecule() override = default; 39 //From G4VUserTrackInformation 40 void Print() const override {;;;}; 41 // new/delete operators are overloded to use G4Allocator 42 inline void *operator new(size_t); 43 #ifdef __IBMCPP__ 44 inline void *operator new(size_t sz, void* p) 45 { 46 return p; 47 } 48 #endif 49 inline void operator delete(void*); 50 // Copy number 51 void SetCopyNumber(G4int copyNum) {fCopyNumber=copyNum;} 52 G4int GetCopyNumber() const {return fCopyNumber;} 53 // DNA strand 54 void SetStrand(G4int strand) {fStrand=strand;} 55 G4int GetStrand() const {return fStrand;} 56 57 private: 58 G4int fCopyNumber=-1; 59 G4int fStrand=-1; 60 }; 61 62 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 63 64 #if defined G4EM_ALLOC_EXPORT 65 extern G4DLLEXPORT G4Allocator<UserMolecule>*& UserMoleculeAllocator(); 66 #else 67 extern G4DLLIMPORT G4Allocator<UserMolecule>*& UserMoleculeAllocator(); 68 #endif 69 70 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 71 72 inline void * UserMolecule::operator new(size_t) 73 { 74 if (!UserMoleculeAllocator()) 75 { 76 UserMoleculeAllocator() = new G4Allocator<UserMolecule>; 77 } 78 return (void *)UserMoleculeAllocator()->MallocSingle(); 79 } 80 81 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 82 83 inline void UserMolecule::operator delete(void * aMolecule) 84 { 85 UserMoleculeAllocator()->FreeSingle((UserMolecule *)aMolecule); 86 } 87 88 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 89 90 #endif