Geant4 VMC
Version 6.8
Toggle main menu visibility
Loading...
Searching...
No Matches
source
global
src
TG4VerboseMessenger.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 "
TG4VerboseMessenger.h
"
16
#include "
TG4Verbose.h
"
17
18
#include <G4UIcmdWithAnInteger.hh>
19
#include <G4UIcommandTree.hh>
20
#include <G4UIdirectory.hh>
21
#include <G4UImanager.hh>
22
23
//_____________________________________________________________________________
24
TG4VerboseMessenger::TG4VerboseMessenger
(
const
G4String& directoryName)
25
:
fkDirectoryName
(directoryName),
26
fDirectory
(0),
27
fGlobalVerboseCmd
(0),
28
fVerboseVector
(),
29
fCommandVector
()
30
{
32
33
fDirectory
=
new
G4UIdirectory(directoryName);
34
fDirectory
->SetGuidance(
"TGeant4 verbose control commands."
);
35
36
// sets the given level to all verbose instances
37
fGlobalVerboseCmd
=
38
new
G4UIcmdWithAnInteger(G4String(directoryName +
"all"
),
this
);
39
G4String guidance(
"Set a given verbose level to all verbose instances."
);
40
fGlobalVerboseCmd
->SetGuidance(guidance);
41
fGlobalVerboseCmd
->SetParameterName(
"GlobalVerbose"
,
false
);
42
fGlobalVerboseCmd
->AvailableForStates(
43
G4State_PreInit, G4State_Init, G4State_Idle);
44
}
45
46
//_____________________________________________________________________________
47
TG4VerboseMessenger::~TG4VerboseMessenger
()
48
{
50
51
delete
fDirectory
;
52
delete
fGlobalVerboseCmd
;
53
54
for
(G4int i = 0; i < G4int(
fCommandVector
.size()); i++) {
55
// G4cout << this << " ... Deleting "
56
// << fCommandVector[i]->GetCommandName() << " "
57
// << fCommandVector[i] << G4endl;
58
delete
fCommandVector
[i];
59
}
60
}
61
62
//
63
// private methods
64
//
65
66
//_____________________________________________________________________________
67
void
TG4VerboseMessenger::SetNewValueToAll
(
const
G4String value)
const
68
{
70
71
G4UIcommandTree* cmdTree =
72
G4UImanager::GetUIpointer()->GetTree()->GetTree(
fkDirectoryName
);
73
74
for
(G4int i = 0; i < cmdTree->GetCommandEntry(); i++) {
75
if
(cmdTree->GetCommand(i + 1)->GetCommandName() !=
"all"
) {
76
// skip the first command in the tree ("all")
77
cmdTree->GetCommand(i + 1)->DoIt(value);
78
}
79
}
80
}
81
82
//
83
// public methods
84
//
85
86
//_____________________________________________________________________________
87
G4UIcommand
*
TG4VerboseMessenger::AddCommand
(
88
TG4Verbose
* verbose,
const
G4String& cmdName)
89
{
91
//--
92
93
G4UIcmdWithAnInteger* cmd =
94
new
G4UIcmdWithAnInteger(G4String(
fkDirectoryName
+ cmdName),
this
);
95
96
fVerboseVector
.push_back(verbose);
97
fCommandVector
.push_back(cmd);
98
99
G4String guidance(
"Set verbose level."
);
100
guidance.insert(4, cmdName);
101
cmd->SetGuidance(guidance);
102
103
G4String parameterName(
"Verbose"
);
104
parameterName.insert(0, cmdName);
105
cmd->SetParameterName(parameterName,
false
);
106
107
cmd->AvailableForStates(G4State_PreInit, G4State_Init, G4State_Idle);
108
109
return
cmd;
110
}
111
112
//_____________________________________________________________________________
113
void
TG4VerboseMessenger::RemoveCommand
(
114
TG4Verbose
* verbose,
G4UIcommand
* command)
115
{
117
//--
118
119
// Remove verbose from the array
120
VerboseVector::iterator pos1 =
121
find(
fVerboseVector
.begin(),
fVerboseVector
.end(), verbose);
122
if
(pos1 !=
fVerboseVector
.end())
fVerboseVector
.erase(pos1);
123
124
// Remove command from the array
125
CommandVector::iterator pos2 =
126
find(
fCommandVector
.begin(),
fCommandVector
.end(), command);
127
if
(pos2 !=
fCommandVector
.end())
fCommandVector
.erase(pos2);
128
129
// Delete command
130
// Command is automatically removed from UI manager
131
delete
command;
132
}
133
134
//_____________________________________________________________________________
135
void
TG4VerboseMessenger::SetNewValue
(
G4UIcommand
* command, G4String newValue)
136
{
138
139
if
(command ==
fGlobalVerboseCmd
) {
140
SetNewValueToAll
(newValue);
141
}
142
for
(G4int i = 0; i < G4int(
fCommandVector
.size()); i++)
143
if
(command ==
fCommandVector
[i]) {
144
fVerboseVector
[i]->VerboseLevel(
145
fCommandVector
[i]->GetNewIntValue(newValue));
146
}
147
}
TG4VerboseMessenger.h
Definition of the TG4VerboseMessenger class.
TG4Verbose.h
Definition of the TG4Verbose class.
G4UIcommand
TG4VerboseMessenger::fGlobalVerboseCmd
G4UIcmdWithAnInteger * fGlobalVerboseCmd
global verbose command
Definition
TG4VerboseMessenger.h:68
TG4VerboseMessenger::fVerboseVector
VerboseVector fVerboseVector
associated verbose instances
Definition
TG4VerboseMessenger.h:69
TG4VerboseMessenger::AddCommand
G4UIcommand * AddCommand(TG4Verbose *verbose, const G4String &cmdName)
Definition
TG4VerboseMessenger.cxx:87
TG4VerboseMessenger::RemoveCommand
void RemoveCommand(TG4Verbose *verbose, G4UIcommand *command)
Definition
TG4VerboseMessenger.cxx:113
TG4VerboseMessenger::fCommandVector
CommandVector fCommandVector
verbose commands
Definition
TG4VerboseMessenger.h:70
TG4VerboseMessenger::TG4VerboseMessenger
TG4VerboseMessenger()
Not implemented.
TG4VerboseMessenger::~TG4VerboseMessenger
virtual ~TG4VerboseMessenger()
Definition
TG4VerboseMessenger.cxx:47
TG4VerboseMessenger::fDirectory
G4UIdirectory * fDirectory
command directory
Definition
TG4VerboseMessenger.h:67
TG4VerboseMessenger::fkDirectoryName
const G4String fkDirectoryName
command directory name
Definition
TG4VerboseMessenger.h:66
TG4VerboseMessenger::SetNewValue
virtual void SetNewValue(G4UIcommand *command, G4String string)
Definition
TG4VerboseMessenger.cxx:135
TG4VerboseMessenger::SetNewValueToAll
void SetNewValueToAll(const G4String value) const
Definition
TG4VerboseMessenger.cxx:67
TG4Verbose
Base class for defining the verbose level and a common messenger.
Definition
TG4Verbose.h:36
Generated on
for Geant4 VMC by
1.17.0