Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-31 09:22:01

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 UserMolecule.hh
0028 /// \brief Definition of the UserMolecule class
0029 
0030 #ifndef UserMolecule_h
0031 #define UserMolecule_h
0032 
0033 #include "G4Molecule.hh"
0034 class UserMolecule : public G4Molecule
0035 {
0036 public:
0037     using G4Molecule::G4Molecule;
0038     ~UserMolecule() override = default;
0039     //From G4VUserTrackInformation
0040     void Print() const override {;;;};
0041     //  new/delete operators are overloded to use G4Allocator
0042     inline void *operator new(size_t);
0043 #ifdef __IBMCPP__
0044     inline void *operator new(size_t sz, void* p)
0045     {
0046         return p;
0047     }
0048 #endif
0049     inline void operator delete(void*);
0050       // Copy number
0051     void SetCopyNumber(G4int copyNum) {fCopyNumber=copyNum;}
0052     G4int GetCopyNumber() const {return fCopyNumber;}
0053     // DNA strand
0054     void SetStrand(G4int strand) {fStrand=strand;}
0055     G4int GetStrand() const {return fStrand;}
0056 
0057 private:
0058     G4int fCopyNumber=-1;
0059     G4int fStrand=-1;
0060 };
0061 
0062 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0063 
0064 #if defined G4EM_ALLOC_EXPORT
0065 extern G4DLLEXPORT G4Allocator<UserMolecule>*& UserMoleculeAllocator();
0066 #else
0067 extern G4DLLIMPORT G4Allocator<UserMolecule>*& UserMoleculeAllocator();
0068 #endif
0069 
0070 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0071 
0072 inline void * UserMolecule::operator new(size_t)
0073 {
0074     if (!UserMoleculeAllocator())
0075     {
0076         UserMoleculeAllocator() = new G4Allocator<UserMolecule>;
0077     }
0078     return (void *)UserMoleculeAllocator()->MallocSingle();
0079 }
0080 
0081 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0082 
0083 inline void UserMolecule::operator delete(void * aMolecule)
0084 {
0085     UserMoleculeAllocator()->FreeSingle((UserMolecule *)aMolecule);
0086 }
0087 
0088 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0089 
0090 #endif