source: trunk/examples/advanced/radiation_monitor/generator/src/RadmonGeneratorsWithLabelMessenger.cc @ 1321

Last change on this file since 1321 was 807, checked in by garnier, 16 years ago

update

File size: 4.4 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:     RadmonGeneratorsWithLabelMessenger.cc
28// Creation date: Sep 2005
29// Main author:   Riccardo Capra <capra@ge.infn.it>
30//
31// Id:            $Id: RadmonGeneratorsWithLabelMessenger.cc,v 1.3 2006/06/29 16:16:39 gunter Exp $
32// Tag:           $Name:  $
33//
34
35// Messenger commands path
36#define COMMANDS_PATH "/radmon/generatorsFactory/"
37
38// Include files
39#include "RadmonGeneratorsWithLabelMessenger.hh"
40
41
42
43RadmonGeneratorsWithLabelMessenger *            RadmonGeneratorsWithLabelMessenger :: Instance(void)
44{
45 if (instance==0)
46 {
47  instance=new RadmonGeneratorsWithLabelMessenger;
48 
49  if (!instance)
50   G4Exception("RadmonGeneratorsWithLabelMessenger::Instance: RadmonGeneratorsWithLabelMessenger singleton not allocated.");
51 }   
52 
53 return instance;
54}
55
56
57
58
59 
60void                                            RadmonGeneratorsWithLabelMessenger :: AddAvailableGenerator(const G4String & name)
61{
62 availableGenerators.insert(name);
63}
64
65
66
67void                                            RadmonGeneratorsWithLabelMessenger :: RemoveAvailableGenerator(const G4String & name)
68{
69 availableGenerators.erase(name);
70}
71
72
73
74
75
76                                                RadmonGeneratorsWithLabelMessenger :: RadmonGeneratorsWithLabelMessenger()
77:
78 RadmonMessenger(COMMANDS_PATH, "Interactive primary generators factory commands."),
79 RADMON_INITIALIZE_COMMAND(Dump)
80{
81 RADMON_CREATE_COMMAND_0ARGS(Dump, "Print out the current available primary generators");
82}
83
84
85
86                                                RadmonGeneratorsWithLabelMessenger :: ~RadmonGeneratorsWithLabelMessenger()
87{
88 RADMON_DESTROY_COMMAND(Dump);
89}
90
91
92
93
94
95G4String                                        RadmonGeneratorsWithLabelMessenger :: GetCurrentValue(G4UIcommand * /* command */)
96{
97 G4cout << "RadmonGeneratorsWithLabelMessenger::GetCurrentValue(): Not supported" << G4endl;
98 
99 return G4String();
100}
101
102
103
104void                                            RadmonGeneratorsWithLabelMessenger :: SetNewValue(G4UIcommand * command, G4String newValue)
105{
106 RADMON_BEGIN_LIST_SET_COMMANDS
107  RADMON_SET_COMMAND(Dump)
108 RADMON_END_LIST_SET_COMMANDS
109}
110
111
112
113
114
115// Events
116void                                            RadmonGeneratorsWithLabelMessenger :: OnDump(const G4String & /* value */)
117{
118 G4String indent("- ");
119 
120 G4String indent2(indent);
121 indent2.prepend("  ");
122 
123 G4cout << indent << "Available generators:\n";
124 
125 AvailableGenerators::const_iterator i(availableGenerators.begin());
126 AvailableGenerators::const_iterator end(availableGenerators.end());
127 
128 if (i==end)
129  G4cout << indent2 << "No generators available.\n";
130 else
131 {
132  while (i!=end)
133  {
134   G4cout << indent2 << (*i) << '\n';
135   i++;
136  }
137 }
138 
139 G4cout << G4endl;
140}
141
142
143
144
145
146RadmonGeneratorsWithLabelMessenger *            RadmonGeneratorsWithLabelMessenger :: instance(0);
Note: See TracBrowser for help on using the repository browser.