Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4ITType.cc
이 파일의 문서화 페이지로 가기
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 80151 2014-04-03 09:42:22Z 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;
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  {
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 
92 {
93  fLastType = 0;
94  fRessource = 0;
95 }
96 
98 {;}
99 
100 size_t G4ITTypeManager::size() const
101 {
102  return fLastType;
103 }
104 
106 {
107  G4ITType newType = fLastType;
108  fLastType++;
109  return newType;
110 }
size_t fRessource
Definition: G4ITType.hh:102
void ReleaseRessource()
Definition: G4ITType.cc:83
#define G4ThreadLocal
Definition: tls.hh:69
int fValue
Definition: G4ITType.hh:65
G4ITType NewType()
Definition: G4ITType.cc:105
G4ITType & operator=(const G4ITType &rhs)
Definition: G4ITType.cc:51
static G4ITTypeManager * Instance()
Definition: G4ITType.cc:58
#define G4MUTEX_INITIALIZER
Definition: G4Threading.hh:88
G4Mutex ressourceMutex
Definition: G4ITType.cc:43
static G4ITTypeManager * fgInstance
Definition: G4ITType.hh:96
G4ITType fLastType
Definition: G4ITType.hh:98
G4Mutex deleteMutex
Definition: G4ITType.cc:42
size_t size() const
Definition: G4ITType.cc:100
static G4ThreadLocal G4ITTypeManager * fgInstance_local
Definition: G4ITType.hh:97
virtual ~G4ITTypeManager()
Definition: G4ITType.cc:97
static size_t size()
Definition: G4ITType.cc:46
static void DeleteInstance()
Definition: G4ITType.cc:67
void ReserveRessource()
Definition: G4ITType.cc:77
std::mutex G4Mutex
Definition: G4Threading.hh:84