Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4ITType.cc
Go to the documentation of this file.
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 // $Id: G4ITType.cc 74551 2013-10-14 12:59:14Z gcosmo $
27 //
28 // Author: Mathieu Karamitros (kara (AT) cenbg . in2p3 . fr)
29 //
30 // History:
31 // -----------
32 // 10 Oct 2011 M.Karamitros created
33 //
34 // -------------------------------------------------------------------
35 
36 #include "G4ITType.hh"
37 #include "G4AutoLock.hh"
38 
39 /*G4ThreadLocal*/ G4ITTypeManager* G4ITTypeManager::fgInstance = 0;
40 G4ThreadLocal G4ITTypeManager* G4ITTypeManager::fgInstance_local = 0;
41 
44 
45 // static method
47 {
48  return G4ITTypeManager::Instance()->size();
49 }
50 
52 {
53  if (this == &rhs) return *this;
54  fValue = rhs.fValue;
55  return *this;
56 }
57 
59 {
60  if(fgInstance == 0)
61  {
62  fgInstance = new G4ITTypeManager();
63  }
64  return fgInstance;
65 }
66 
68 {
69  G4AutoLock lock(&deleteMutex);
70  if(fgInstance)
71  {
72  delete fgInstance ;
73  fgInstance = 0;
74  }
75 }
76 
78 {
80  fRessource++;
81 }
82 
84 {
86  fRessource--;
87 
88  if(fRessource <= 0) DeleteInstance();
89 }
90 
91 G4ITTypeManager::G4ITTypeManager()
92 { fLastType = 0;}
93 
94 G4ITTypeManager::~G4ITTypeManager()
95 {;}
96 
97 size_t G4ITTypeManager::size() const
98 {
99  return fLastType;
100 }
101 
103 {
104  G4ITType newType = fLastType;
105  fLastType++;
106  return newType;
107 }
G4Mutex deleteMutex
Definition: G4ITType.cc:42
G4ITType NewType()
Definition: G4ITType.cc:102
static void DeleteInstance()
Definition: G4ITType.cc:67
#define G4ThreadLocal
Definition: tls.hh:52
#define G4MUTEX_INITIALIZER
Definition: G4Threading.hh:158
G4ITType & operator=(const G4ITType &rhs)
Definition: G4ITType.cc:51
static G4ITTypeManager * Instance()
Definition: G4ITType.cc:58
G4Mutex ressourceMutex
Definition: G4ITType.cc:43
static size_t size()
Definition: G4ITType.cc:46
size_t size() const
Definition: G4ITType.cc:97
void ReserveRessource()
Definition: G4ITType.cc:77
G4int G4Mutex
Definition: G4Threading.hh:156
void ReleaseRessource()
Definition: G4ITType.cc:83