Import Geant4 10.0.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-10 11:51:14 +02:00
parent e2d2f9810a
commit 286caacf06
12421 changed files with 730077 additions and 502383 deletions
+1 -1
View File
@@ -7,7 +7,7 @@
#
# Generated on : 24/9/2010
#
# $Id: CMakeLists.txt,v 1.1 2010-09-29 18:45:14 bmorgan Exp $
# $Id: CMakeLists.txt 66892 2013-01-17 10:57:59Z gunter $
#
#------------------------------------------------------------------------------
+1 -1
View File
@@ -1,4 +1,4 @@
# $Id: GNUmakefile,v 1.2 2004-06-01 15:36:48 gcosmo Exp $
# $Id: GNUmakefile 66892 2013-01-17 10:57:59Z gunter $
# -------------------------------------------------------------
# GNUmakefile for intercoms library. Gabriele Cosmo, 11/11/96.
# -------------------------------------------------------------
+73 -1
View File
@@ -1,4 +1,4 @@
$Id: History,v 1.83 2010-11-11 11:32:08 gcosmo Exp $
$Id: History 77651 2013-11-27 08:47:55Z gcosmo $
-------------------------------------------------------------------
=========================================================
@@ -16,6 +16,78 @@ committal in the CVS repository !
----------------------------------------------------------
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
26 November, 2013 M. Asai (intercoms-V09-06-16)
- G4GenericMessenger : introducing two methods for declaring a method
that has a unit. This solves the issue of G4GenericMessenger in
multi-threaded mode.
21 November, 2013 M. Asai (intercoms-V09-06-15)
- G4UIcommandTree : add a protection against a G4UIcommandTree object
that does not have any guidance.
20 November, 2013 M. Asai (intercoms-V09-06-14)
- Modify G4UImanager, G4UIcommandTree and G4UIcommand classes to make
all UI commands defined in the worker thread are visible by the
G4UImanager of the master thread so that undefined command, wrong
parameters, etc are correctly detected.
20 November, 2013 M. Asai (intercoms-V09-06-13)
- Fix G4UIcmdWith3VectorAndUnit and G4UIcmdWithADoubleAndUnit.
Since version 9.3, they do not check and reject incorrect unit
but instead misinterpret and accept with wrong value.
5 November, 2013 M. Asai (intercoms-V09-06-12)
- Fix the way of forwarding a UI command to a thread immediately.
1 November, 2013 P. Mato (intercoms-V09-06-11)
- Moved template specilizations from G4AnyType.cc to header file to
avoid Windows linking problems.
29 October, 2013 P. Mato (intercoms-V09-06-10)
- Fixed problem with G4GenericMessenger reported by Ivana that SetUnit
and SetRange were not working together. Fixed variable shadowing in
G4AnyType.hh.
25 September, 2013 M. Asai (intercoms-V09-06-09)
- G4UImessenger constructor with command directory now may take
a boolean flag of not-to-be-broadcasted.
20 September, 2013 M. Asai (intercoms-V09-06-08)
- A UI command directory may be specified as such that all commands in that
directory and all decendant directories should not be broadcased to
worker threads. This setting must be made by the argument of G4UIdirectory
constructor and cannot be changed. Each individual command may still be
set to be broadcasted by accessing to G4UIcommand::SetToBeBroadcasted()
method individually.
15 August, 2013 M. Asai (intercoms-V09-06-07)
- Improve the behavior of ignoring thread cout.
15 August, 2013 M. Asai (intercoms-V09-06-06)
- G4MTcoutDestination now has a capability of printing out only for
the selected thread to make the display readable.
- Introducing according UI command /control/cout/ignoreThreadsExcept.
23 May, 2013 M. Asai (intercoms-V09-06-05)
- Introducing /control/cout/ command category for handling thread-local cout/cerr.
14 March, 2013 A. Dotti (intercoms-V09-06-04)
- Changing signature for GetCommandStack()
12 March, 2013 M. Asai (intercoms-V09-06-03)
- Adding flags for commands to be boradcasted to thread-local UI mamaners.
12 March, 2013 M. Asai (intercoms-V09-06-02)
- Adding IgnoreCmdNotFound into G4UImanager required for multi-threading.
14 February 2013 Jean Jacquemier (intercoms-V09-06-01)
- Removed modifcation G4UIcommand.cc for G4UnitTable (see tag intercoms-V09-06-00). These
modification will be done once MultiThreading performance loss will be recover.
February 08, 2013 J.Jacquemier (intercoms-V09-06-00)
- G4UIcommand.cc: Modification for G4UnitTable (std::map).
26 October, 2012 P. Mato (intercoms-V09-05-07)
- G4AnyMethod.hh avoided compilation warning.
+20 -8
View File
@@ -49,6 +49,8 @@
#include <iostream>
#include <sstream>
#include "G4UIcommand.hh"
class G4String;
namespace CLHEP {
class Hep3Vector;
@@ -156,14 +158,14 @@ private:
}
/** ToString */
virtual std::string ToString() const {
std::stringstream s;
s << fRef;
return s.str();
std::stringstream ss;
ss << fRef;
return ss.str();
}
/** FromString */
virtual void FromString(const std::string& val) {
std::stringstream s(val);
s >> fRef;
std::stringstream ss(val);
ss >> fRef;
}
/** representation */
ValueType& fRef;
@@ -178,9 +180,19 @@ private:
* Specializations
*/
template<> void G4AnyType::Ref<bool>::FromString(const std::string& val);
template<> void G4AnyType::Ref<G4String>::FromString(const std::string& val);
template<> void G4AnyType::Ref<CLHEP::Hep3Vector>::FromString(const std::string& val);
template <> inline void G4AnyType::Ref<bool>::FromString(const std::string& val) {
fRef = G4UIcommand::ConvertToBool(val.c_str());
}
template <> inline void G4AnyType::Ref<G4String>::FromString(const std::string& val) {
if (val[0] == '"' ) fRef = val.substr(1,val.size()-2);
else fRef = val;
}
template <> inline void G4AnyType::Ref<G4ThreeVector>::FromString(const std::string& val) {
fRef = G4UIcommand::ConvertTo3Vector(val.c_str());
}
/**
* @class G4BadAnyCast G4AnyType.h Reflex/G4AnyType.h
@@ -91,10 +91,12 @@ public:
};
///Declare Methods
//Command& DeclarePropertyWithUnit(const G4String& name, const G4Any& variable, const G4String& unit, const G4String& doc = "");
Command& DeclareProperty(const G4String& name, const G4AnyType& variable, const G4String& doc = "");
Command& DeclarePropertyWithUnit
(const G4String& name, const G4String& defaultUnit, const G4AnyType& variable, const G4String& doc = "");
Command& DeclareMethod(const G4String& name, const G4AnyMethod& fun, const G4String& doc = "");
//Command& DeclareMethodWithUnit(const G4String& name, const G4AnyFunc& fun, const G4String& unit, const G4String& doc = "");
Command& DeclareMethodWithUnit
(const G4String& name, const G4String& defaultUnit, const G4AnyMethod& fun, const G4String& doc = "");
void SetDirectory(const G4String& dir) {directory = dir;}
void SetGuidance(const G4String& s);
@@ -0,0 +1,66 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4LocalThreadCoutMessenger.hh 66241 2012-12-13 18:34:42Z gunter $
//
// class description
//
// This class is the messenger for handling cout/cerr of local thread
//
#ifndef G4LocalThreadCoutMessenger_h
#define G4LocalThreadCoutMessenger_h 1
#include "globals.hh"
#include "G4UImessenger.hh"
class G4UIdirectory;
class G4UIcommand;
class G4UIcmdWithABool;
class G4UIcmdWithAString;
class G4UIcmdWithAnInteger;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
class G4LocalThreadCoutMessenger: public G4UImessenger
{
public:
G4LocalThreadCoutMessenger();
~G4LocalThreadCoutMessenger();
void SetNewValue(G4UIcommand*, G4String);
private:
G4UIdirectory* coutDir;
G4UIcommand* coutFileNameCmd;
G4UIcommand* cerrFileNameCmd;
G4UIcmdWithABool* bufferCoutCmd;
G4UIcmdWithAString* prefixCmd;
G4UIcmdWithAnInteger* ignoreCmd;
};
#endif
+1 -1
View File
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4UIaliasList.hh 67965 2013-03-13 09:35:29Z gcosmo $
//
#ifndef G4UIaliasList_h
+1 -1
View File
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id$
// $Id: G4UIbatch.hh 67965 2013-03-13 09:35:29Z gcosmo $
//
// ====================================================================
// G4UIbatch.hh
+80
View File
@@ -0,0 +1,80 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4UIbridge.hh 66241 2012-12-13 18:34:42Z gunter $
//
// ====================================================================
// G4UIbridge.hh
//
// This is a concrete class of G4UIsession.
//
// This class object is instantiated by G4UImanager at every time
// when "/control/execute macro_file" command is executed.
// Also in the case of pure batch mode with a macro file,
// this class can be used as other ordinary G4UIsession
// concrete classes, i.e. SessionStart() is invoked in main().
// ====================================================================
#ifndef G4UIbridge_H
#define G4UIbridge_H 1
class G4UImanager;
#include "globals.hh"
// ====================================================================
//
// class definition
//
// G4UIbridge:
// To be used for MT mode.
// Register a particular thread-local G4UImanager with a UI command
// directory name. When a UI command is issued in the master thread
// that starts with this redistered directory name, it is immediately
// forwarded to the registered G4UImanager. Such forwarded command
// is not processed in the master thread nor other worker thread.
//
// ====================================================================
class G4UIbridge
{
public:
G4UIbridge(G4UImanager* localUI,G4String dir);
~G4UIbridge();
G4int ApplyCommand(const G4String& aCmd);
private:
G4UImanager* localUImanager;
G4String dirName;
public:
inline G4UImanager* LocalUI() const
{ return localUImanager; }
inline G4String DirName() const
{ return dirName; }
inline G4int DirLength() const
{ return dirName.length(); }
};
#endif
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4UIcmdWith3Vector.hh 67965 2013-03-13 09:35:29Z gcosmo $
//
//
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4UIcmdWith3VectorAndUnit.hh 67965 2013-03-13 09:35:29Z gcosmo $
//
//
+1 -1
View File
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4UIcmdWithABool.hh 67965 2013-03-13 09:35:29Z gcosmo $
//
//
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4UIcmdWithADouble.hh 67965 2013-03-13 09:35:29Z gcosmo $
//
//
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4UIcmdWithADoubleAndUnit.hh 67965 2013-03-13 09:35:29Z gcosmo $
//
//
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4UIcmdWithAString.hh 67965 2013-03-13 09:35:29Z gcosmo $
//
//
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4UIcmdWithAnInteger.hh 67965 2013-03-13 09:35:29Z gcosmo $
//
//
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4UIcmdWithoutParameter.hh 67965 2013-03-13 09:35:29Z gcosmo $
//
//
+26 -2
View File
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4UIcommand.hh 77563 2013-11-26 09:03:18Z gcosmo $
//
//
@@ -53,9 +53,14 @@ class G4UIcommand
public:
G4UIcommand();
public: // with description
G4UIcommand(const char * theCommandPath, G4UImessenger * theMessenger);
G4UIcommand(const char * theCommandPath, G4UImessenger * theMessenger,
G4bool tBB = true);
// Constructor. The command string with full path directory
// and the pointer to the messenger must be given.
// If tBB is set to false, this command won't be sent to worker threads.
// This tBB parameter could be changed with SetToBeBroadcasted() method
// except for G4UIdirectory.
public:
virtual ~G4UIcommand();
@@ -170,6 +175,25 @@ class G4UIcommand
{ return commandGuidance[0]; }
}
protected:
G4bool toBeBroadcasted;
G4bool toBeFlushed;
G4bool workerThreadOnly;
public:
inline void SetToBeBroadcasted(G4bool val)
{ toBeBroadcasted = val; }
inline G4bool ToBeBroadcasted() const
{ return toBeBroadcasted; }
inline void SetToBeFlushed(G4bool val)
{ toBeFlushed = val; }
inline G4bool ToBeFlushed() const
{ return toBeFlushed; }
inline void SetWorkerThreadOnly(G4bool val=true)
{ workerThreadOnly = val; }
inline G4bool IsWorkerThreadOnly() const
{ return workerThreadOnly; }
protected:
G4int CheckNewValue(const char* newValue);
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4UIcommandStatus.hh 67965 2013-03-13 09:35:29Z gcosmo $
//
#ifndef G4UIcommandStatus_h
+4 -3
View File
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4UIcommandTree.hh 77651 2013-11-27 08:47:55Z gcosmo $
//
#ifndef G4UIcommandTree_h
@@ -51,8 +51,8 @@ class G4UIcommandTree
G4int operator!=(const G4UIcommandTree &right) const;
public:
void AddNewCommand(G4UIcommand * newCommand);
void RemoveCommand(G4UIcommand * aCommand);
void AddNewCommand(G4UIcommand * newCommand, G4bool workerThreadOnly=false);
void RemoveCommand(G4UIcommand * aCommand, G4bool workerThreadOnly=false);
G4UIcommand* FindPath(const char* commandPath) const;
G4UIcommandTree* FindCommandTree(const char* commandPath);
G4String CompleteCommandPath(const G4String& commandPath);
@@ -73,6 +73,7 @@ class G4UIcommandTree
std::vector<G4UIcommandTree*> tree;
G4UIcommand *guidance;
G4String pathName;
G4bool broadcastCommands;
public:
inline const G4UIcommand * GetGuidance() const
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4UIcontrolMessenger.hh 67965 2013-03-13 09:35:29Z gcosmo $
//
#ifndef G4UIcontrolMessenger_h
+3 -3
View File
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4UIdirectory.hh 74098 2013-09-22 16:05:49Z gcosmo $
//
//
@@ -41,8 +41,8 @@
class G4UIdirectory : public G4UIcommand
{
public: // with description
G4UIdirectory(char * theCommandPath);
G4UIdirectory(const char * theCommandPath);
G4UIdirectory(char * theCommandPath,G4bool commandsToBeBroadcasted = true);
G4UIdirectory(const char * theCommandPath,G4bool commandsToBeBroadcasted = true);
// Constructors. The argument is a full path directory which
// starts and ends with "/".
};
+50 -10
View File
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4UImanager.hh 77651 2013-11-27 08:47:55Z gcosmo $
//
#ifndef G4UImanager_h
@@ -41,7 +41,10 @@ class G4UIcommand;
class G4UIsession;
class G4UIcontrolMessenger;
class G4UnitsMessenger;
class G4LocalThreadCoutMessenger;
class G4UIaliasList;
class G4MTcoutDestination;
class G4UIbridge;
// class description:
//
@@ -54,6 +57,7 @@ class G4UImanager : public G4VStateDependent
{
public: // with description
static G4UImanager * GetUIpointer();
static G4UImanager * GetMasterUIpointer();
// A static method to get the pointer to the only existing object
// of this class.
@@ -118,6 +122,9 @@ class G4UImanager : public G4VStateDependent
void CreateHTML(const char* dir = "/");
// Generate HTML files for defined UI commands
private:
void AddWorkerCommand(G4UIcommand * newCommand);
void RemoveWorkerCommand(G4UIcommand * aCommand);
public:
void LoopS(const char* valueList);
@@ -138,13 +145,15 @@ class G4UImanager : public G4VStateDependent
// void Interact(const char * promptCharacters);
private:
static G4UImanager * fUImanager;
static G4bool fUImanagerHasBeenKilled;
static G4ThreadLocal G4UImanager * fUImanager;
static G4ThreadLocal G4bool fUImanagerHasBeenKilled;
static G4UImanager * fMasterUImanager;
G4UIcommandTree * treeTop;
G4UIsession * session;
G4UIsession * g4UIWindow;
G4UIcontrolMessenger * UImessenger;
G4UnitsMessenger * UnitsMessenger;
G4LocalThreadCoutMessenger * CoutMessenger;
G4String savedParameters;
G4UIcommand * savedCommand;
G4int verboseLevel;
@@ -238,14 +247,45 @@ class G4UImanager : public G4VStateDependent
void ParseMacroSearchPath();
G4String FindMacroPath(const G4String& fname) const;
// Old methods kept for backward compatibility
// inline G4UIcommandTree * GetTree() const
// { return treeTop; };
// inline G4UIsession * GetSession() const
// { return session; };
// inline void SetSession(G4UIsession *const value)
// { session = value; };
private:
G4bool isMaster;
std::vector<G4UIbridge*>* bridges;
G4bool ignoreCmdNotFound;
G4bool stackCommandsForBroadcast;
std::vector<G4String>* commandStack;
public:
inline void SetMasterUIManager(G4bool val)
{
isMaster = val;
//ignoreCmdNotFound = val;
stackCommandsForBroadcast = val;
if(val&&!bridges)
{
bridges = new std::vector<G4UIbridge*>;
fMasterUImanager = this;
}
}
inline void SetIgnoreCmdNotFound(G4bool val)
{ ignoreCmdNotFound = val; }
std::vector<G4String>* GetCommandStack();
void RegisterBridge(G4UIbridge* brg);
public:
void SetUpForAThread(G4int tId);
private:
G4int threadID;
G4MTcoutDestination* threadCout;
static G4int igThreadID;
public:
void SetCoutFileName(const G4String& fileN = "G4cout.txt", G4bool ifAppend = true);
void SetCerrFileName(const G4String& fileN = "G4cerr.txt", G4bool ifAppend = true);
void SetThreadPrefixString(const G4String& s = "W");
void SetThreadUseBuffer(G4bool flg = true);
void SetThreadIgnore(G4int tid = 0);
};
#endif
+5 -3
View File
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4UImessenger.hh 74278 2013-10-02 15:04:18Z gcosmo $
//
#ifndef G4UImessenger_h
@@ -48,7 +48,8 @@ class G4UImessenger
{
public: // with description
G4UImessenger();
G4UImessenger(const G4String& path, const G4String& dsc);
G4UImessenger(const G4String& path, const G4String& dsc,
G4bool commandsToBeBroadcasted = true);
// Constructor. In the implementation of the concrete messenger, all commands
// related to the messenger must be constructed.
virtual ~G4UImessenger();
@@ -83,7 +84,8 @@ class G4UImessenger
// shortcut way for creating directory and commands
G4UIdirectory* baseDir; // used if new object is created
G4String baseDirName; // used if dir already exists
void CreateDirectory(const G4String& path, const G4String& dsc);
void CreateDirectory(const G4String& path, const G4String& dsc,
G4bool commandsToBeBroadcasted=true);
template <typename T> T* CreateCommand(const G4String& cname,
const G4String& dsc);
+1 -1
View File
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4UIparameter.hh 67965 2013-03-13 09:35:29Z gcosmo $
//
//
// ---------------------------------------------------------------------
+1 -1
View File
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4UIsession.hh 67965 2013-03-13 09:35:29Z gcosmo $
//
// $id$
+1 -1
View File
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4UItokenNum.hh 67965 2013-03-13 09:35:29Z gcosmo $
//
// G4UItokenNum.hh
+1 -1
View File
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4UnitsMessenger.hh 67965 2013-03-13 09:35:29Z gcosmo $
//
// class description
//
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4VFlavoredParallelWorld.hh 67965 2013-03-13 09:35:29Z gcosmo $
//
//
// Abstract interface for GEANT4 Flavored Parallel World.
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4VGlobalFastSimulationManager.hh 67965 2013-03-13 09:35:29Z gcosmo $
//
//
// Abstract interface for GEANT4 Global Fast Simulation Manager.
@@ -54,6 +54,7 @@
#ifndef G4VGLOBALFASTSIMULATIONMANAGER_HH
#define G4VGLOBALFASTSIMULATIONMANAGER_HH
#include "G4Types.hh"
class G4VFlavoredParallelWorld;
class G4ParticleDefinition;
@@ -78,7 +79,7 @@ protected:
static void SetConcreteInstance (G4VGlobalFastSimulationManager*);
// Sets the pointer to actual Global Fast Simulation manager.
static G4VGlobalFastSimulationManager* fpConcreteInstance;
static G4ThreadLocal G4VGlobalFastSimulationManager* fpConcreteInstance;
// Pointer to real G4GlobalFastSimulationManager.
};
+5 -1
View File
@@ -11,7 +11,7 @@
#
# Generated on : 24/9/2010
#
# $Id: sources.cmake,v 1.1 2010-09-29 18:45:22 bmorgan Exp $
# $Id: sources.cmake 75773 2013-11-06 09:14:23Z gcosmo $
#
#------------------------------------------------------------------------------
@@ -31,6 +31,7 @@ GEANT4_DEFINE_MODULE(NAME G4intercoms
HEADERS
G4UIaliasList.hh
G4UIbatch.hh
G4UIbridge.hh
G4UIcmdWith3Vector.hh
G4UIcmdWith3VectorAndUnit.hh
G4UIcmdWithABool.hh
@@ -53,11 +54,13 @@ GEANT4_DEFINE_MODULE(NAME G4intercoms
G4VFlavoredParallelWorld.hh
G4VGlobalFastSimulationManager.hh
G4GenericMessenger.hh
G4LocalThreadCoutMessenger.hh
G4AnyType.hh
G4AnyMethod.hh
SOURCES
G4UIaliasList.cc
G4UIbatch.cc
G4UIbridge.cc
G4UIcmdWith3Vector.cc
G4UIcmdWith3VectorAndUnit.cc
G4UIcmdWithABool.cc
@@ -76,6 +79,7 @@ GEANT4_DEFINE_MODULE(NAME G4intercoms
G4UIsession.cc
G4UnitsMessenger.cc
G4VGlobalFastSimulationManager.cc
G4LocalThreadCoutMessenger.cc
G4GenericMessenger.cc
G4AnyType.cc
GRANULAR_DEPENDENCIES
+7
View File
@@ -31,6 +31,11 @@
#include "G4Types.hh"
#include "G4ThreeVector.hh"
// The definitions of these specializations have been moved to the
// to the header file to solve Windows linking problem
#if 0
template <> void G4AnyType::Ref<bool>::FromString(const std::string& val) {
fRef = G4UIcommand::ConvertToBool(val.c_str());
}
@@ -43,3 +48,5 @@ template <> void G4AnyType::Ref<G4String>::FromString(const std::string& val) {
template <> void G4AnyType::Ref<G4ThreeVector>::FromString(const std::string& val) {
fRef = G4UIcommand::ConvertTo3Vector(val.c_str());
}
#endif
@@ -84,6 +84,30 @@ G4GenericMessenger::DeclareProperty(const G4String& name, const G4AnyType& var,
}
G4GenericMessenger::Command& G4GenericMessenger::DeclarePropertyWithUnit
(const G4String& name, const G4String& defaultUnit, const G4AnyType& var, const G4String& doc) {
if(var.TypeInfo()!=typeid(float) && var.TypeInfo()!=typeid(double) && var.TypeInfo()!= typeid(G4ThreeVector))
{ return DeclareProperty(name,var,doc); }
G4String fullpath = directory+name;
G4UIcommand* cmd;
if(var.TypeInfo()==typeid(float) || var.TypeInfo()==typeid(double))
{
cmd = new G4UIcmdWithADoubleAndUnit(fullpath.c_str(), this);
(static_cast<G4UIcmdWithADoubleAndUnit*>(cmd))->SetParameterName("value",false,false);
(static_cast<G4UIcmdWithADoubleAndUnit*>(cmd))->SetDefaultUnit(defaultUnit);
}
else
{
cmd = new G4UIcmdWith3VectorAndUnit(fullpath.c_str(), this);
(static_cast<G4UIcmdWith3VectorAndUnit*>(cmd))->SetParameterName("valueX","valueY","valueZ",false,false);
(static_cast<G4UIcmdWith3VectorAndUnit*>(cmd))->SetDefaultUnit(defaultUnit);
}
if(doc != "") cmd->SetGuidance(doc);
return properties[name] = Property(var, cmd);
}
G4GenericMessenger::Command&
G4GenericMessenger::DeclareMethod(const G4String& name, const G4AnyMethod& fun, const G4String& doc) {
G4String fullpath = directory+name;
@@ -95,6 +119,24 @@ G4GenericMessenger::DeclareMethod(const G4String& name, const G4AnyMethod& fun,
return methods[name] = Method(fun, object, cmd);
}
G4GenericMessenger::Command& G4GenericMessenger::DeclareMethodWithUnit
(const G4String& name, const G4String& defaultUnit, const G4AnyMethod& fun, const G4String& doc) {
G4String fullpath = directory+name;
if(fun.NArg()!=1) {
G4ExceptionDescription ed;
ed<<"G4GenericMessenger::DeclareMethodWithUnit() does not support a method that has more than\n"
<<"one arguments (or no argument). Please use G4GenericMessenger::DeclareMethod method for\n"
<<"your command <"<<fullpath<<">.";
G4Exception("G4GenericMessenger::DeclareMethodWithUnit()","Intercom70002",FatalException,ed);
}
G4UIcommand* cmd = new G4UIcmdWithADoubleAndUnit(fullpath.c_str(), this);
(static_cast<G4UIcmdWithADoubleAndUnit*>(cmd))->SetParameterName("value",false,false);
(static_cast<G4UIcmdWithADoubleAndUnit*>(cmd))->SetDefaultUnit(defaultUnit);
if(doc != "") cmd->SetGuidance(doc);
return methods[name] = Method(fun, object, cmd);
}
G4String G4GenericMessenger::GetCurrentValue(G4UIcommand* command) {
if ( properties.find(command->GetCommandName()) != properties.end()) {
Property& p = properties[command->GetCommandName()];
@@ -141,10 +183,27 @@ G4GenericMessenger::Command& G4GenericMessenger::Command::SetUnit(const G4String
// Change the type of command (unfortunatelly this is done a posteriory)
// We need to delete the old command before creating the new one and therefore we need to recover the information
// before the deletetion
#ifdef G4MULTITHREADED
G4String cmdpath = command->GetCommandPath();
G4ExceptionDescription ed;
ed<<"G4GenericMessenger::Command::SetUnit() is thread-unsafe and should not be used\n"
<<"in multi-threaded mode. For your command <"<<cmdpath<<">, use\n"
<<" DeclarePropertyWithUnit(const G4String& name, const G4String& defaultUnit,\n"
<<" const G4AnyType& variable, const G4String& doc)\n"
<<"or\n"
<<" DeclareMethodWithUnit(const G4String& name, const G4String& defaultUnit,\n"
<<" const G4AnyType& variable, const G4String& doc)\n"
<<"to define a command with a unit <"<<unit<<">.";
if(spec!=UnitDefault) { ed<<"\nPlease use a default unit instead of unit category."; }
G4Exception("G4GenericMessenger::Command::SetUnit()","Intercom70001",FatalException,ed);
return *this;
#else
G4String cmdpath = command->GetCommandPath();
G4UImessenger* messenger = command->GetMessenger();
G4String range = command->GetRange();
std::vector<G4String> guidance;
G4String par_name = command->GetParameter(0)->GetParameterName();
bool par_omitable = command->GetParameter(0)->IsOmittable();
for (G4int i = 0; i < command->GetGuidanceEntries(); i++) guidance.push_back(command->GetGuidanceLine(i));
// Before deleting the command we need to add a fake one to avoid deleting the directory entry and with its guidance
G4UIcommand tmp((cmdpath+"_tmp").c_str(), messenger);
@@ -154,6 +213,7 @@ G4GenericMessenger::Command& G4GenericMessenger::Command::SetUnit(const G4String
G4UIcmdWithADoubleAndUnit* cmd_t = new G4UIcmdWithADoubleAndUnit(cmdpath, messenger);
if(spec == UnitDefault) cmd_t->SetDefaultUnit(unit);
else if(spec == UnitCategory) cmd_t->SetUnitCategory(unit);
cmd_t->SetParameterName(par_name, par_omitable);
command = cmd_t;
}
else if (*type == typeid(G4ThreeVector)) {
@@ -169,6 +229,7 @@ G4GenericMessenger::Command& G4GenericMessenger::Command::SetUnit(const G4String
for (size_t i = 0; i < guidance.size(); i++) command->SetGuidance(guidance[i]);
command->SetRange(range);
return *this;
#endif
}
G4GenericMessenger::Command& G4GenericMessenger::Command::SetParameterName(const G4String& name,G4bool omittable, G4bool currentAsDefault) {
@@ -0,0 +1,134 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4LocalThreadCoutMessenger.cc 66241 2012-12-13 18:34:42Z gunter $
//
//
#include "G4LocalThreadCoutMessenger.hh"
#include "G4UImanager.hh"
#include "G4UIdirectory.hh"
#include "G4UIcommand.hh"
#include "G4UIcmdWithABool.hh"
#include "G4UIcmdWithAString.hh"
#include "G4UIcmdWithAnInteger.hh"
#include "G4UIparameter.hh"
#include "G4Tokenizer.hh"
G4LocalThreadCoutMessenger::G4LocalThreadCoutMessenger()
{
coutDir = new G4UIdirectory("/control/cout/");
coutDir->SetGuidance("Control cout/cerr for local thread.");
coutFileNameCmd = new G4UIcommand("/control/cout/setCoutFile",this);
coutFileNameCmd->SetGuidance("Send G4cout stream to a file dedicated to a thread. ");
coutFileNameCmd->SetGuidance("To have a display output, use special keyword \"**Screen**\".");
coutFileNameCmd->SetGuidance("If append flag is true output is appended to file,");
coutFileNameCmd->SetGuidance("otherwise file output is overwritten.");
coutFileNameCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
G4UIparameter* pp = new G4UIparameter("fileName",'s',true);
pp->SetDefaultValue("**Screen**");
coutFileNameCmd->SetParameter(pp);
pp= new G4UIparameter("append",'b',true);
pp->SetDefaultValue(true);
coutFileNameCmd->SetParameter(pp);
cerrFileNameCmd = new G4UIcommand("/control/cout/setCerrFile",this);
cerrFileNameCmd->SetGuidance("Send G4cerr stream to a file dedicated to a thread. ");
cerrFileNameCmd->SetGuidance("To have a display output, use special keyword \"**Screen**\".");
cerrFileNameCmd->SetGuidance("If append flag is true output is appended to file,");
cerrFileNameCmd->SetGuidance("otherwise file output is overwritten.");
cerrFileNameCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
pp = new G4UIparameter("fileName",'s',true);
pp->SetDefaultValue("**Screen**");
cerrFileNameCmd->SetParameter(pp);
pp= new G4UIparameter("append",'b',true);
pp->SetDefaultValue(true);
cerrFileNameCmd->SetParameter(pp);
bufferCoutCmd = new G4UIcmdWithABool("/control/cout/useBuffer",this);
bufferCoutCmd->SetGuidance("Send cout and/or cerr stream to a buffer.");
bufferCoutCmd->SetGuidance("The buffered text will be printed at the end of the job");
bufferCoutCmd->SetGuidance("for each thread at a time, so that output of each thread is grouped.");
bufferCoutCmd->SetGuidance("This command has no effect if output goes to a file.");
bufferCoutCmd->SetParameterName("flag",true);
bufferCoutCmd->SetDefaultValue(true);
bufferCoutCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
prefixCmd = new G4UIcmdWithAString("/control/cout/prefixString",this);
prefixCmd->SetGuidance("Set the prefix string for each cout/cerr line from a thread.");
prefixCmd->SetParameterName("prefix",true);
prefixCmd->SetDefaultValue("G4WT");
prefixCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
ignoreCmd = new G4UIcmdWithAnInteger("/control/cout/ignoreThreadsExcept",this);
ignoreCmd->SetGuidance("Omit cout from threads except the specified one.");
ignoreCmd->SetGuidance("This command takes effect only if cout destination is screen without buffering.");
ignoreCmd->SetGuidance("If specified thread ID is greater than the number of threads,");
ignoreCmd->SetGuidance("no cout is displayed from worker threads. -1 to reset.");
ignoreCmd->SetGuidance("This command does not affect to cerr.");
ignoreCmd->SetParameterName("threadID",true);
ignoreCmd->SetDefaultValue(0);
ignoreCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
}
G4LocalThreadCoutMessenger::~G4LocalThreadCoutMessenger()
{
delete coutFileNameCmd;
delete cerrFileNameCmd;
delete bufferCoutCmd;
delete prefixCmd;
delete ignoreCmd;
delete coutDir;
}
void G4LocalThreadCoutMessenger::SetNewValue(G4UIcommand* command,G4String newVal)
{
G4UImanager * UI = G4UImanager::GetUIpointer();
if(command == coutFileNameCmd)
{
G4Tokenizer next(newVal);
G4String fn = next();
G4bool af = StoB(next());
UI->SetCoutFileName(fn,af);
}
else if(command == cerrFileNameCmd)
{
G4Tokenizer next(newVal);
G4String fn = next();
G4bool af = StoB(next());
UI->SetCerrFileName(fn,af);
}
else if(command == bufferCoutCmd)
{ UI->SetThreadUseBuffer(StoB(newVal)); }
else if(command == prefixCmd)
{ UI->SetThreadPrefixString(newVal); }
else if(command == ignoreCmd)
{ UI->SetThreadIgnore(StoI(newVal)); }
}
+1 -1
View File
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4UIaliasList.cc 67965 2013-03-13 09:35:29Z gcosmo $
//
#include "G4UIaliasList.hh"
+2 -2
View File
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id$
// $Id: G4UIbatch.cc 67965 2013-03-13 09:35:29Z gcosmo $
//
// ====================================================================
// G4UIbatch.cc
@@ -96,7 +96,7 @@ G4String G4UIbatch::ReadCommand()
/////////////////////////////////
{
enum { BUFSIZE= 4096 };
static char linebuf[BUFSIZE];
static G4ThreadLocal char *linebuf = 0 ; if (!linebuf) linebuf = new char [BUFSIZE];
const char ctrM = 0x0d;
G4String cmdtotal= "";
+69
View File
@@ -0,0 +1,69 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4UIbridge.cc 66885 2013-01-16 17:37:13Z gunter $
//
// ====================================================================
// G4UIbridge.cc
//
// ====================================================================
#include "G4UIbridge.hh"
#include "G4UImanager.hh"
////////////////////////////////////////////////////////////////////
G4UIbridge::G4UIbridge(G4UImanager* localUI, G4String dir)
: localUImanager(localUI)
////////////////////////////////////////////////////////////////////
{
// make sure dirName starts and ends with '/'
if(dir(0,1)=="/")
{ dirName = dir; }
else
{ dirName = "/"+dir; }
if(dirName(dirName.length()-1,1)!="/")
{ dirName += "/"; }
// register to the master G4UImanager
G4UImanager* masterUI = G4UImanager::GetMasterUIpointer();
if(masterUI)
{ masterUI->RegisterBridge(this); }
else
{
G4Exception("G4UIbridge::G4UIbridge()","UI7001",FatalException,
"G4UImanager for the master thread is not yet instantiated. Instantiate G4MTRunManager first.");
}
}
///////////////////////
G4UIbridge::~G4UIbridge()
///////////////////////
{;}
/////////////////////////////////
G4int G4UIbridge::ApplyCommand(const G4String& aCmd)
/////////////////////////////////
{ return localUImanager->ApplyCommand(aCmd); }
+1 -1
View File
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4UIcmdWith3Vector.cc 67965 2013-03-13 09:35:29Z gcosmo $
//
//
@@ -24,13 +24,14 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4UIcmdWith3VectorAndUnit.cc 77308 2013-11-22 11:22:28Z gcosmo $
//
//
#include "G4UIcmdWith3VectorAndUnit.hh"
#include "G4Tokenizer.hh"
#include "G4UnitsTable.hh"
#include "G4UIcommandStatus.hh"
#include <sstream>
G4UIcmdWith3VectorAndUnit::G4UIcmdWith3VectorAndUnit
@@ -61,6 +62,8 @@ G4int G4UIcmdWith3VectorAndUnit::DoIt(G4String parameterList)
G4String converted_parameter;
G4String default_unit = GetParameter(3)-> GetDefaultValue();
if (default_unit != "" && token_vector.size() >= 4) {
if(CategoryOf(token_vector[3])!=CategoryOf(default_unit))
{ return fParameterOutOfCandidates+3; }
G4double value_given = ValueOf(token_vector[3]);
G4double value_default = ValueOf(default_unit);
G4double x = ConvertToDouble(token_vector[0]) * value_given / value_default;
+1 -1
View File
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4UIcmdWithABool.cc 67965 2013-03-13 09:35:29Z gcosmo $
//
//
+1 -1
View File
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4UIcmdWithADouble.cc 67965 2013-03-13 09:35:29Z gcosmo $
//
//
@@ -24,13 +24,14 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4UIcmdWithADoubleAndUnit.cc 77308 2013-11-22 11:22:28Z gcosmo $
//
//
#include "G4UIcmdWithADoubleAndUnit.hh"
#include "G4Tokenizer.hh"
#include "G4UnitsTable.hh"
#include "G4UIcommandStatus.hh"
#include <sstream>
#include <vector>
@@ -58,6 +59,8 @@ G4int G4UIcmdWithADoubleAndUnit::DoIt(G4String parameterList)
G4String converted_parameter;
G4String default_unit = GetParameter(1)-> GetDefaultValue();
if (default_unit != "" && token_vector.size() >= 2) {
if(CategoryOf(token_vector[1])!=CategoryOf(default_unit))
{ return fParameterOutOfCandidates+1; }
G4double value_given = ValueOf(token_vector[1]);
G4double value_default = ValueOf(default_unit);
G4double value = ConvertToDouble(token_vector[0])
+1 -1
View File
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4UIcmdWithAString.cc 67965 2013-03-13 09:35:29Z gcosmo $
//
//
+1 -1
View File
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4UIcmdWithAnInteger.cc 67965 2013-03-13 09:35:29Z gcosmo $
//
//
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4UIcmdWithoutParameter.cc 67965 2013-03-13 09:35:29Z gcosmo $
//
//
+12 -4
View File
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4UIcommand.cc 77563 2013-11-26 09:03:18Z gcosmo $
//
//
@@ -39,13 +39,15 @@
#include <sstream>
G4UIcommand::G4UIcommand()
: messenger(0), bp(0), token(IDENTIFIER), paramERR(0)
: messenger(0), toBeBroadcasted(false), toBeFlushed(false), workerThreadOnly(false),
bp(0), token(IDENTIFIER), paramERR(0)
{
}
G4UIcommand::G4UIcommand(const char * theCommandPath,
G4UImessenger * theMessenger)
:messenger(theMessenger),token(IDENTIFIER),paramERR(0)
G4UImessenger * theMessenger, G4bool tBB)
:messenger(theMessenger),toBeBroadcasted(tBB),toBeFlushed(false), workerThreadOnly(false),
token(IDENTIFIER),paramERR(0)
{
G4String comStr = theCommandPath;
if(!theMessenger)
@@ -101,6 +103,8 @@ G4int G4UIcommand::operator!=(const G4UIcommand &right) const
return ( commandPath != right.GetCommandPath() );
}
#include "G4Threading.hh"
G4int G4UIcommand::DoIt(G4String parameterList)
{
G4String correctParameters;
@@ -207,6 +211,8 @@ G4int G4UIcommand::DoIt(G4String parameterList)
if(CheckNewValue( correctParameters ))
{ return fParameterOutOfRange+99; }
if(workerThreadOnly && !G4Threading::IsWorkerThread()) return 0;
messenger->SetNewValue( this, correctParameters );
return 0;
}
@@ -331,6 +337,8 @@ void G4UIcommand::List()
G4cout << G4endl;
if(commandPath(commandPath.length()-1)!='/')
{ G4cout << "Command " << commandPath << G4endl; }
if(workerThreadOnly)
{ G4cout << " ---- available only in worker thread" << G4endl; }
G4cout << "Guidance :" << G4endl;
G4int n_guidanceEntry = commandGuidance.size();
for( G4int i_thGuidance=0; i_thGuidance < n_guidanceEntry; i_thGuidance++ )
+32 -13
View File
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4UIcommandTree.cc 77651 2013-11-27 08:47:55Z gcosmo $
//
#include "G4UIcommandTree.hh"
@@ -33,11 +33,11 @@
#include "G4ios.hh"
G4UIcommandTree::G4UIcommandTree()
:guidance(NULL)
:guidance(NULL),broadcastCommands(true)
{ }
G4UIcommandTree::G4UIcommandTree(const char * thePathName)
:guidance(NULL)
:guidance(NULL),broadcastCommands(true)
{
pathName = thePathName;
}
@@ -60,14 +60,19 @@ G4int G4UIcommandTree::operator!=(const G4UIcommandTree &right) const
return ( pathName != right.GetPathName() );
}
void G4UIcommandTree::AddNewCommand(G4UIcommand *newCommand)
void G4UIcommandTree::AddNewCommand(G4UIcommand *newCommand, G4bool workerThreadOnly)
{
G4String commandPath = newCommand->GetCommandPath();
G4String remainingPath = commandPath;
remainingPath.remove(0,pathName.length());
if( remainingPath.isNull() )
{
guidance = newCommand;
if(!guidance)
{
guidance = newCommand;
if(!(newCommand->ToBeBroadcasted())) broadcastCommands = false;
if(workerThreadOnly) newCommand->SetWorkerThreadOnly();
}
return;
}
G4int i = remainingPath.first('/');
@@ -80,6 +85,8 @@ void G4UIcommandTree::AddNewCommand(G4UIcommand *newCommand)
if( remainingPath == command[i_thCommand]->GetCommandName() )
{ return; }
}
if(!broadcastCommands) newCommand->SetToBeBroadcasted(false);
if(workerThreadOnly) newCommand->SetWorkerThreadOnly();
command.push_back( newCommand );
return;
}
@@ -93,19 +100,22 @@ void G4UIcommandTree::AddNewCommand(G4UIcommand *newCommand)
{
if( nextPath == tree[i_thTree]->GetPathName() )
{
tree[i_thTree]->AddNewCommand( newCommand );
if(!broadcastCommands) newCommand->SetToBeBroadcasted(false);
tree[i_thTree]->AddNewCommand( newCommand, workerThreadOnly );
return;
}
}
G4UIcommandTree * newTree = new G4UIcommandTree( nextPath );
tree.push_back( newTree );
newTree->AddNewCommand( newCommand );
if(!broadcastCommands) newCommand->SetToBeBroadcasted(false);
newTree->AddNewCommand( newCommand, workerThreadOnly );
return;
}
}
void G4UIcommandTree::RemoveCommand(G4UIcommand *aCommand)
void G4UIcommandTree::RemoveCommand(G4UIcommand *aCommand, G4bool workerThreadOnly)
{
if(workerThreadOnly && !(aCommand->IsWorkerThreadOnly())) return;
G4String commandPath = aCommand->GetCommandPath();
G4String remainingPath = commandPath;
remainingPath.remove(0,pathName.length());
@@ -332,16 +342,25 @@ void G4UIcommandTree::ListCurrent() const
G4cout << " Sub-directories : " << G4endl;
G4int n_treeEntry = tree.size();
for( G4int i_thTree = 0; i_thTree < n_treeEntry; i_thTree++ )
{
G4cout << " " << tree[i_thTree]->GetPathName()
<< " " << tree[i_thTree]->GetTitle() << G4endl;
{
G4cout << " " << tree[i_thTree]->GetPathName();
if(tree[i_thTree]->GetGuidance() &&
tree[i_thTree]->GetGuidance()->IsWorkerThreadOnly())
{ G4cout << " @ "; }
else
{ G4cout << " "; }
G4cout << tree[i_thTree]->GetTitle() << G4endl;
}
G4cout << " Commands : " << G4endl;
G4int n_commandEntry = command.size();
for( G4int i_thCommand = 0; i_thCommand < n_commandEntry; i_thCommand++ )
{
G4cout << " " << command[i_thCommand]->GetCommandName()
<< " * " << command[i_thCommand]->GetTitle() << G4endl;
G4cout << " " << command[i_thCommand]->GetCommandName();
if(command[i_thCommand]->IsWorkerThreadOnly())
{ G4cout << " @ "; }
else
{ G4cout << " * "; }
G4cout << command[i_thCommand]->GetTitle() << G4endl;
}
}
+7 -1
View File
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4UIcontrolMessenger.cc 68725 2013-04-05 09:27:45Z gcosmo $
//
#include <stdlib.h>
@@ -55,6 +55,7 @@ G4UIcontrolMessenger::G4UIcontrolMessenger()
ExecuteCommand = new G4UIcmdWithAString("/control/execute",this);
ExecuteCommand->SetGuidance("Execute a macro file.");
ExecuteCommand->SetParameterName("fileName",false);
ExecuteCommand->SetToBeBroadcasted(false);
loopCommand = new G4UIcommand("/control/loop",this);
loopCommand->SetGuidance("Execute a macro file more than once.");
@@ -70,6 +71,7 @@ G4UIcontrolMessenger::G4UIcontrolMessenger()
G4UIparameter* param5 = new G4UIparameter("stepSize",'d',true);
param5->SetDefaultValue(1.0);
loopCommand->SetParameter(param5);
loopCommand->SetToBeBroadcasted(false);
foreachCommand = new G4UIcommand("/control/foreach",this);
foreachCommand->SetGuidance("Execute a macro file more than once.");
@@ -81,6 +83,7 @@ G4UIcontrolMessenger::G4UIcontrolMessenger()
foreachCommand->SetParameter(param7);
G4UIparameter* param8 = new G4UIparameter("valueList",'s',false);
foreachCommand->SetParameter(param8);
foreachCommand->SetToBeBroadcasted(false);
suppressAbortionCommand = new G4UIcmdWithAnInteger("/control/suppressAbortion",this);
suppressAbortionCommand->SetGuidance("Suppress the program abortion caused by G4Exception.");
@@ -146,12 +149,14 @@ G4UIcontrolMessenger::G4UIcontrolMessenger()
ManualCommand->SetGuidance("Directory path should be given by FULL-PATH.");
ManualCommand->SetParameterName("dirPath",true);
ManualCommand->SetDefaultValue("/");
ManualCommand->SetToBeBroadcasted(false);
HTMLCommand = new G4UIcmdWithAString("/control/createHTML",this);
HTMLCommand->SetGuidance("Generate HTML files for all of sub-directories and commands.");
HTMLCommand->SetGuidance("Directory path should be given by FULL-PATH.");
HTMLCommand->SetParameterName("dirPath",true);
HTMLCommand->SetDefaultValue("/");
HTMLCommand->SetToBeBroadcasted(false);
maxStoredHistCommand = new G4UIcmdWithAnInteger("/control/maximumStoredHistory",this);
maxStoredHistCommand->SetGuidance("Set maximum number of stored UI commands.");
@@ -170,6 +175,7 @@ G4UIcontrolMessenger::G4UIcontrolMessenger()
ifCommand->SetParameter(rightParam);
G4UIparameter* macroFileParam = new G4UIparameter("aliasValue",'s',false);
ifCommand->SetParameter(macroFileParam);
ifCommand->SetToBeBroadcasted(false);
addCommand = new G4UIcommand("/control/add",this);
addCommand->SetGuidance("Define a new alias as the sum of two values.");
+5 -5
View File
@@ -24,17 +24,17 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4UIdirectory.cc 74098 2013-09-22 16:05:49Z gcosmo $
//
//
#include "G4UIdirectory.hh"
G4UIdirectory::G4UIdirectory(char * theCommandPath)
:G4UIcommand(theCommandPath,NULL)
G4UIdirectory::G4UIdirectory(char * theCommandPath,G4bool commandsToBeBroadcasted)
:G4UIcommand(theCommandPath,NULL,commandsToBeBroadcasted)
{;}
G4UIdirectory::G4UIdirectory(const char * theCommandPath)
:G4UIcommand(theCommandPath,NULL)
G4UIdirectory::G4UIdirectory(const char * theCommandPath,G4bool commandsToBeBroadcasted)
:G4UIcommand(theCommandPath,NULL,commandsToBeBroadcasted)
{;}
+162 -6
View File
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4UImanager.cc 77651 2013-11-27 08:47:55Z gcosmo $
//
//
// ---------------------------------------------------------------------
@@ -36,17 +36,24 @@
#include "G4UIbatch.hh"
#include "G4UIcontrolMessenger.hh"
#include "G4UnitsMessenger.hh"
#include "G4LocalThreadCoutMessenger.hh"
#include "G4ios.hh"
#include "G4strstreambuf.hh"
#include "G4StateManager.hh"
#include "G4UIaliasList.hh"
#include "G4Tokenizer.hh"
#include "G4MTcoutDestination.hh"
#include "G4UIbridge.hh"
#include "G4Threading.hh"
#include <sstream>
#include <fstream>
G4UImanager * G4UImanager::fUImanager = 0;
G4bool G4UImanager::fUImanagerHasBeenKilled = false;
G4ThreadLocal G4UImanager * G4UImanager::fUImanager = 0;
G4ThreadLocal G4bool G4UImanager::fUImanagerHasBeenKilled = false;
G4UImanager * G4UImanager::fMasterUImanager = 0;
G4int G4UImanager::igThreadID = -1;
G4UImanager * G4UImanager::GetUIpointer()
{
@@ -61,9 +68,15 @@ G4UImanager * G4UImanager::GetUIpointer()
return fUImanager;
}
G4UImanager * G4UImanager::GetMasterUIpointer()
{ return fMasterUImanager; }
G4UImanager::G4UImanager()
: G4VStateDependent(true),
UImessenger(0), UnitsMessenger(0)
UImessenger(0), UnitsMessenger(0), CoutMessenger(0),
isMaster(false),bridges(0),
ignoreCmdNotFound(false), stackCommandsForBroadcast(false),
threadID(-1), threadCout(0)
{
savedCommand = 0;
treeTop = new G4UIcommandTree("/");
@@ -79,25 +92,46 @@ G4UImanager::G4UImanager()
pauseAtEndOfEvent = false;
maxHistSize = 20;
searchPath="";
commandStack = new std::vector<G4String>;
}
void G4UImanager::CreateMessenger()
{
UImessenger = new G4UIcontrolMessenger;
UnitsMessenger = new G4UnitsMessenger;
CoutMessenger = new G4LocalThreadCoutMessenger;
}
G4UImanager::~G4UImanager()
{
if(bridges)
{
std::vector<G4UIbridge*>::iterator itr = bridges->begin();
for(;itr!=bridges->end();itr++)
{ delete *itr; }
delete bridges;
}
SetCoutDestination(NULL);
histVec.clear();
if(saveHistory) historyFile.close();
delete UImessenger;
delete CoutMessenger;
delete UnitsMessenger;
delete UImessenger;
delete treeTop;
delete aliasList;
fUImanagerHasBeenKilled = true;
fUImanager = NULL;
if(commandStack)
{
commandStack->clear();
delete commandStack;
}
if(threadID >= 0)
{
if(threadCout) delete threadCout;
G4iosFinalization();
threadID = -1;
}
}
G4UImanager::G4UImanager(const G4UImanager& ui)
@@ -220,11 +254,25 @@ G4int parameterNumber, G4bool reGet)
void G4UImanager::AddNewCommand(G4UIcommand * newCommand)
{
treeTop->AddNewCommand( newCommand );
if(fMasterUImanager!=0&&G4Threading::G4GetThreadId()==0)
{ fMasterUImanager->AddWorkerCommand(newCommand); }
}
void G4UImanager::AddWorkerCommand(G4UIcommand * newCommand)
{
treeTop->AddNewCommand( newCommand, true );
}
void G4UImanager::RemoveCommand(G4UIcommand * aCommand)
{
treeTop->RemoveCommand( aCommand );
if(fMasterUImanager!=0&&G4Threading::G4GetThreadId()==0)
{ fMasterUImanager->RemoveWorkerCommand(aCommand); }
}
void G4UImanager::RemoveWorkerCommand(G4UIcommand * aCommand)
{
treeTop->RemoveCommand( aCommand, true );
}
void G4UImanager::ExecuteMacroFile(const char * fileName)
@@ -366,6 +414,8 @@ G4int G4UImanager::ApplyCommand(const G4String& aCmd)
return ApplyCommand(aCmd.data());
}
#include "G4Threading.hh"
G4int G4UImanager::ApplyCommand(const char * aCmd)
{
G4String aCommand = SolveAlias(aCmd);
@@ -408,9 +458,32 @@ G4int G4UImanager::ApplyCommand(const char * aCmd)
{ ll++; }
}
if(isMaster&&bridges)
{
std::vector<G4UIbridge*>::iterator itr = bridges->begin();
for(;itr!=bridges->end();itr++)
{
G4int leng = (*itr)->DirLength();
if(commandString(0,leng)==(*itr)->DirName())
{ return (*itr)->LocalUI()->ApplyCommand(commandString+" "+commandParameter); }
}
}
G4UIcommand * targetCommand = treeTop->FindPath( commandString );
if( targetCommand == NULL )
{ return fCommandNotFound; }
{
if(ignoreCmdNotFound)
{
if(stackCommandsForBroadcast)
{ commandStack->push_back(commandString+" "+commandParameter); }
return fCommandSucceeded;
}
else
{ return fCommandNotFound; }
}
if(stackCommandsForBroadcast && targetCommand->ToBeBroadcasted())
{ commandStack->push_back(commandString+" "+commandParameter); }
if(!(targetCommand->IsAvailable()))
{ return fIllegalApplicationState; }
@@ -419,6 +492,7 @@ G4int G4UImanager::ApplyCommand(const char * aCmd)
if( G4int(histVec.size()) >= maxHistSize )
{ histVec.erase(histVec.begin()); }
histVec.push_back(aCommand);
return targetCommand->DoIt( commandParameter );
}
@@ -604,3 +678,85 @@ G4String G4UImanager::FindMacroPath(const G4String& fname) const
return macrofile;
}
std::vector<G4String>* G4UImanager::GetCommandStack()
{
std::vector<G4String>* returnValue = commandStack;
commandStack = new std::vector<G4String>;
return returnValue;
}
void G4UImanager::RegisterBridge(G4UIbridge* brg)
{
if(brg->LocalUI()==this)
{
G4Exception("G4UImanager::RegisterBridge()","UI7002",FatalException,
"G4UIBridge cannot bridge between same object.");
}
else
{ bridges->push_back(brg); }
}
void G4UImanager::SetUpForAThread(G4int tId)
{
threadID = tId;
G4iosInitialization();
threadCout = new G4MTcoutDestination(threadID);
threadCout->SetIgnoreCout(igThreadID);
}
void G4UImanager::SetCoutFileName(const G4String& fileN, G4bool ifAppend)
{
// for sequential mode, ignore this method.
if(threadID<0) return;
if(fileN == "**Screen**")
{ threadCout->SetCoutFileName(fileN,ifAppend); }
else
{
std::stringstream fn;
fn<<"G4W_"<<threadID<<"_"<<fileN;
threadCout->SetCoutFileName(fn.str(),ifAppend);
}
}
void G4UImanager::SetCerrFileName(const G4String& fileN, G4bool ifAppend)
{
// for sequential mode, ignore this method.
if(threadID<0) return;
if(fileN == "**Screen**")
{ threadCout->SetCerrFileName(fileN,ifAppend); }
else
{
std::stringstream fn;
fn<<"G4W_"<<threadID<<"_"<<fileN;
threadCout->SetCerrFileName(fn.str(),ifAppend);
}
}
void G4UImanager::SetThreadPrefixString(const G4String& s)
{
// for sequential mode, ignore this method.
if(threadID<0) return;
threadCout->SetPrefixString(s);
}
void G4UImanager::SetThreadUseBuffer(G4bool flg)
{
// for sequential mode, ignore this method.
if(threadID<0) return;
threadCout->EnableBuffering(flg);
}
void G4UImanager::SetThreadIgnore(G4int tid)
{
// for sequential mode, ignore this method.
if(threadID<0)
{
igThreadID = tid;
return;
}
threadCout->SetIgnoreCout(tid);
}
+7 -5
View File
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4UImessenger.cc 74278 2013-10-02 15:04:18Z gcosmo $
//
#include "G4UImessenger.hh"
@@ -40,10 +40,11 @@ G4UImessenger::G4UImessenger()
{
}
G4UImessenger::G4UImessenger(const G4String& path, const G4String& dsc)
G4UImessenger::G4UImessenger(const G4String& path, const G4String& dsc,
G4bool commandsToBeBroadcasted)
: baseDir(NULL), baseDirName("")
{
CreateDirectory(path, dsc);
CreateDirectory(path, dsc, commandsToBeBroadcasted);
}
G4UImessenger::~G4UImessenger()
@@ -120,7 +121,8 @@ void G4UImessenger::AddUIcommand(G4UIcommand * newCommand)
<< newCommand->GetCommandPath() << ">." << G4endl;
}
void G4UImessenger::CreateDirectory(const G4String& path, const G4String& dsc)
void G4UImessenger::CreateDirectory(const G4String& path, const G4String& dsc,
G4bool commandsToBeBroadcasted)
{
G4UImanager* ui = G4UImanager::GetUIpointer();
@@ -131,7 +133,7 @@ void G4UImessenger::CreateDirectory(const G4String& path, const G4String& dsc)
if (tree) {
baseDirName = tree-> GetPathName();
} else {
baseDir = new G4UIdirectory(fullpath.c_str());
baseDir = new G4UIdirectory(fullpath.c_str(),commandsToBeBroadcasted);
baseDirName = fullpath;
baseDir-> SetGuidance(dsc.c_str());
}
+1 -1
View File
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4UIparameter.cc 67965 2013-03-13 09:35:29Z gcosmo $
//
#include "G4UIparameter.hh"
+1 -1
View File
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4UIsession.cc 67965 2013-03-13 09:35:29Z gcosmo $
//
//
// ---------------------------------------------------------------------
+1 -1
View File
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4UnitsMessenger.cc 67965 2013-03-13 09:35:29Z gcosmo $
//
//
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4VGlobalFastSimulationManager.cc 67965 2013-03-13 09:35:29Z gcosmo $
//
//
// Abstract interface for GEANT4 Global Fast Simulation Manager.
@@ -32,7 +32,7 @@
#include "G4VGlobalFastSimulationManager.hh"
G4VGlobalFastSimulationManager*
G4ThreadLocal G4VGlobalFastSimulationManager*
G4VGlobalFastSimulationManager::fpConcreteInstance = 0;
G4VGlobalFastSimulationManager*