Geant4 VMC
Version 6.8
Toggle main menu visibility
Loading...
Searching...
No Matches
source
global
src
TG4IntMap.cxx
Go to the documentation of this file.
1
//------------------------------------------------
2
// The Geant4 Virtual Monte Carlo package
3
// Copyright (C) 2007 - 2014 Ivana Hrivnacova
4
// All rights reserved.
5
//
6
// For the licensing terms see geant4_vmc/LICENSE.
7
// Contact: root-vmc@cern.ch
8
//-------------------------------------------------
9
14
15
#include "
TG4IntMap.h
"
16
#include "
TG4Globals.h
"
17
18
#include "globals.hh"
19
#include "iomanip"
20
21
//_____________________________________________________________________________
22
TG4IntMap::TG4IntMap
() :
fMap
()
23
{
25
}
26
27
//_____________________________________________________________________________
28
TG4IntMap::~TG4IntMap
()
29
{
31
}
32
33
//
34
// private methods
35
//
36
37
//_____________________________________________________________________________
38
G4bool
TG4IntMap::IsDefined
(
const
G4String& first)
39
{
41
42
MapIterator
i =
fMap
.find(first);
43
if
(i ==
fMap
.end())
44
return
false
;
45
else
46
return
true
;
47
}
48
49
//
50
// public methods
51
//
52
53
//_____________________________________________________________________________
54
G4bool
TG4IntMap::Add
(
const
G4String& first, G4int second)
55
{
57
58
if
(!
IsDefined
(first)) {
59
// insert into map
60
// only in case it is not yet here
61
fMap
[first] = second;
62
return
true
;
63
}
64
return
false
;
65
}
66
67
//_____________________________________________________________________________
68
G4int
TG4IntMap::GetSecond
(
const
G4String& name, G4bool warn)
69
{
71
72
MapIterator
i =
fMap
.find(name);
73
if
(i ==
fMap
.end()) {
74
if
(warn) {
75
TG4Globals::Warning
(
76
"TG4IntMap"
,
"GetSecond"
, TString(name) +
" is not defined."
);
77
}
78
return
0;
79
}
80
else
{
81
return
(*i).second;
82
}
83
}
84
//_____________________________________________________________________________
85
G4int
TG4IntMap::GetSize
()
const
86
{
88
89
return
fMap
.size();
90
}
91
92
//_____________________________________________________________________________
93
void
TG4IntMap::PrintAll
()
const
94
{
96
97
if
(
fMap
.size()) {
98
G4cout <<
"Dump of TG4IntMap - "
<<
fMap
.size() <<
" entries:"
<< G4endl;
99
G4int counter = 0;
100
for
(
MapConstIterator
i =
fMap
.begin(); i !=
fMap
.end(); i++) {
101
const
G4String& first = (*i).first;
102
G4int second = (*i).second;
103
G4cout <<
"Map element "
<< std::setw(3) << counter++ <<
" "
<< first
104
<<
" "
<< second << G4endl;
105
}
106
}
107
}
108
109
//_____________________________________________________________________________
110
void
TG4IntMap::Clear
()
111
{
113
114
if
(
fMap
.size() > 0)
fMap
.clear();
115
}
TG4Globals.h
Definition of the TG4Globals class and basic container types.
TG4IntMap.h
Definition of the TG4IntMap class.
TG4Globals::Warning
static void Warning(const TString &className, const TString &methodName, const TString &text)
Definition
TG4Globals.cxx:48
TG4IntMap::MapConstIterator
Map::const_iterator MapConstIterator
The constant iterator for the map of integers to strings.
Definition
TG4IntMap.h:36
TG4IntMap::TG4IntMap
TG4IntMap()
Definition
TG4IntMap.cxx:22
TG4IntMap::MapIterator
Map::iterator MapIterator
The iterator for the map of integers to strings.
Definition
TG4IntMap.h:33
TG4IntMap::Clear
void Clear()
Definition
TG4IntMap.cxx:110
TG4IntMap::fMap
Map fMap
map container
Definition
TG4IntMap.h:60
TG4IntMap::GetSize
G4int GetSize() const
Definition
TG4IntMap.cxx:85
TG4IntMap::GetSecond
G4int GetSecond(const G4String &name, G4bool warn=true)
Definition
TG4IntMap.cxx:68
TG4IntMap::Add
G4bool Add(const G4String &first, G4int second)
Definition
TG4IntMap.cxx:54
TG4IntMap::IsDefined
G4bool IsDefined(const G4String &first)
Definition
TG4IntMap.cxx:38
TG4IntMap::PrintAll
void PrintAll() const
Definition
TG4IntMap.cxx:93
TG4IntMap::~TG4IntMap
~TG4IntMap()
Definition
TG4IntMap.cxx:28
Generated on
for Geant4 VMC by
1.17.0