source: trunk/examples/advanced/radiation_monitor/physics/src/RadmonPhysicsMessenger.cc@ 1273

Last change on this file since 1273 was 807, checked in by garnier, 17 years ago

update

File size: 6.6 KB
Line 
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//
27// File name: RadmonPhysicsMessenger.cc
28// Creation date: Nov 2005
29// Main author: Riccardo Capra <capra@ge.infn.it>
30//
31// Id: $Id: RadmonPhysicsMessenger.cc,v 1.4 2006/06/29 16:18:59 gunter Exp $
32// Tag: $Name: $
33//
34
35// Messenger commands path
36#define COMMANDS_PATH "/radmon/physics/"
37
38// Include files
39#include "RadmonPhysicsMessenger.hh"
40#include "RadmonVPhysicsLayout.hh"
41#include "G4UnitsTable.hh"
42
43
44
45 RadmonPhysicsMessenger :: RadmonPhysicsMessenger(RadmonVPhysicsLayout * layout)
46:
47 RadmonMessenger(COMMANDS_PATH, "Interactive physics list commands."),
48 physicsLayout(layout),
49 RADMON_INITIALIZE_COMMAND(AddPhysicsList),
50 RADMON_INITIALIZE_COMMAND(RemovePhysicsList),
51 RADMON_INITIALIZE_COMMAND(SetPhysicsListAttribute),
52 RADMON_INITIALIZE_COMMAND(ClearPhysicsListAttribute),
53 RADMON_INITIALIZE_COMMAND(DumpLayout),
54 RADMON_INITIALIZE_COMMAND(Load),
55 RADMON_INITIALIZE_COMMAND(Save)
56{
57 if (layout==0)
58 G4Exception("RadmonPhysicsMessenger::RadmonPhysicsMessenger: layout==0.");
59
60 RADMON_CREATE_COMMAND_1ARG (AddPhysicsList, "Enables a group of physics processes", "physiscsListName");
61 RADMON_CREATE_COMMAND_1ARG (RemovePhysicsList, "Disables a group of physics processes", "physicsListName");
62 RADMON_CREATE_COMMAND_3ARGS(SetPhysicsListAttribute, "Set the attributes of a physics list", "physicsListName", "attributeName", "value");
63 RADMON_CREATE_COMMAND_2ARGS(ClearPhysicsListAttribute, "Remove the attributes of a physics list", "physicsListName", "attributeName");
64 RADMON_CREATE_COMMAND_0ARGS(DumpLayout, "Print out the current layout");
65 RADMON_CREATE_COMMAND_1ARG (Load, "Loads a layout from file", "fileName");
66 RADMON_CREATE_COMMAND_1ARG (Save, "Saves a layout to file", "fileName");
67}
68
69
70
71 RadmonPhysicsMessenger :: ~RadmonPhysicsMessenger()
72{
73 RADMON_DESTROY_COMMAND(Save);
74 RADMON_DESTROY_COMMAND(Load);
75 RADMON_DESTROY_COMMAND(DumpLayout);
76 RADMON_DESTROY_COMMAND(ClearPhysicsListAttribute);
77 RADMON_DESTROY_COMMAND(SetPhysicsListAttribute);
78 RADMON_DESTROY_COMMAND(RemovePhysicsList);
79 RADMON_DESTROY_COMMAND(AddPhysicsList);
80}
81
82
83
84
85
86G4String RadmonPhysicsMessenger :: GetCurrentValue(G4UIcommand * /* command */)
87{
88 G4cout << "RadmonPhysicsMessenger::GetCurrentValue(): Not supported" << G4endl;
89
90 return G4String();
91}
92
93
94
95void RadmonPhysicsMessenger :: SetNewValue(G4UIcommand * command, G4String newValue)
96{
97 RADMON_BEGIN_LIST_SET_COMMANDS
98 RADMON_SET_COMMAND(AddPhysicsList)
99 RADMON_SET_COMMAND(RemovePhysicsList)
100 RADMON_SET_COMMAND(SetPhysicsListAttribute)
101 RADMON_SET_COMMAND(ClearPhysicsListAttribute)
102 RADMON_SET_COMMAND(DumpLayout)
103 RADMON_SET_COMMAND(Load)
104 RADMON_SET_COMMAND(Save)
105 RADMON_END_LIST_SET_COMMANDS
106}
107
108
109
110
111
112// Events
113void RadmonPhysicsMessenger :: OnAddPhysicsList(const G4String & value)
114{
115 G4String args[1];
116
117 if (!ProcessArguments(value, 1, args))
118 return;
119
120 physicsLayout->AddPhysicsList(args[0]);
121}
122
123
124
125void RadmonPhysicsMessenger :: OnRemovePhysicsList(const G4String & value)
126{
127 G4String args[1];
128
129 if (!ProcessArguments(value, 1, args))
130 return;
131
132 physicsLayout->RemovePhysicsList(args[0]);
133}
134
135
136
137void RadmonPhysicsMessenger :: OnSetPhysicsListAttribute(const G4String & value)
138{
139 G4String args[3];
140
141 if (!ProcessArguments(value, 3, args))
142 return;
143
144 physicsLayout->SetPhysicsListAttribute(args[0], args[1], args[2]);
145}
146
147
148
149void RadmonPhysicsMessenger :: OnClearPhysicsListAttribute(const G4String & value)
150{
151 G4String args[2];
152
153 if (!ProcessArguments(value, 2, args))
154 return;
155
156 physicsLayout->ClearPhysicsListAttribute(args[0], args[1]);
157}
158
159
160
161void RadmonPhysicsMessenger :: OnDumpLayout(const G4String & /* value */)
162{
163 physicsLayout->DumpLayout(G4cout);
164 G4cout << G4endl;
165}
166
167
168
169void RadmonPhysicsMessenger :: OnLoad(const G4String & value)
170{
171 G4String args[1];
172
173 if (!ProcessArguments(value, 1, args))
174 return;
175
176 std::istream * in(OpenForInput(args[0]));
177
178 if (!in)
179 return;
180
181 if (!physicsLayout->Load(*in))
182 G4cout << "RadmonPhysicsMessenger::OnLoad(): Error reading from file \"" << args[0] << "\"." << G4endl;
183
184 delete in;
185}
186
187
188
189void RadmonPhysicsMessenger :: OnSave(const G4String & value)
190{
191 G4String args[1];
192
193 if (!ProcessArguments(value, 1, args))
194 return;
195
196 std::ostream * out(OpenForOutput(args[0]));
197
198 if (!out)
199 return;
200
201 if (!physicsLayout->Save(*out))
202 G4cout << "RadmonPhysicsMessenger::OnSave(): Cannot write layout into file \"" << args[0] << "\"." << G4endl;
203
204 delete out;
205}
Note: See TracBrowser for help on using the repository browser.