Import Geant4 10.7.0 source tree

This commit is contained in:
Gabriele Cosmo
2020-12-04 12:30:43 +01:00
parent 67ba86d073
commit dab42d2018
3770 changed files with 226369 additions and 286486 deletions
+157 -70
View File
@@ -23,11 +23,16 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4GenericMessenger
//
// Class description:
//
// A generic messenger class.
#ifndef G4GenericMessenger_h
#define G4GenericMessenger_h 1
// Author: P.Mato, CERN - 27 September 2012
// --------------------------------------------------------------------
#ifndef G4GenericMessenger_hh
#define G4GenericMessenger_hh 1
#include "G4UImessenger.hh"
#include "G4UIcommand.hh"
@@ -40,76 +45,158 @@
class G4UIdirectory;
/// This class is generic messenger.
class G4GenericMessenger : public G4UImessenger
{
public:
/// Contructor
G4GenericMessenger(void* obj, const G4String& dir = "", const G4String& doc = "");
/// Destructor
virtual ~G4GenericMessenger();
/// The concrete, but generic implementation of this method.
virtual G4String GetCurrentValue(G4UIcommand* command);
/// The concrete, generic implementation of this method converts the string "newValue" to action.
virtual void SetNewValue(G4UIcommand* command, G4String newValue);
public:
struct Command {
enum UnitSpec {UnitCategory, UnitDefault};
Command(G4UIcommand* cmd, const std::type_info& ti) : command(cmd), type(&ti) {}
Command() : command(0), type(0) {}
// Command& operator =(const Command& rhs) { command = rhs.command; type = rhs.type; }
Command& SetStates(G4ApplicationState s0) {command->AvailableForStates(s0); return *this;}
Command& SetStates(G4ApplicationState s0, G4ApplicationState s1) {command->AvailableForStates(s0, s1); return *this;}
Command& SetStates(G4ApplicationState s0, G4ApplicationState s1, G4ApplicationState s2){command->AvailableForStates(s0,s1,s2); return *this;}
Command& SetStates(G4ApplicationState s0, G4ApplicationState s1, G4ApplicationState s2, G4ApplicationState s3) {command->AvailableForStates(s0,s1,s2,s3); return *this;}
Command& SetStates(G4ApplicationState s0, G4ApplicationState s1, G4ApplicationState s2, G4ApplicationState s3, G4ApplicationState s4) {command->AvailableForStates(s0,s1,s2,s3,s4); return *this;}
Command& SetRange(const G4String& range) {command->SetRange(range.c_str()); return *this;}
Command& SetGuidance(const G4String& s0) { command->SetGuidance(s0); return *this; }
Command& SetUnit(const G4String&, UnitSpec = UnitDefault);
Command& SetUnitCategory(const G4String& u) {return SetUnit(u, UnitCategory);}
Command& SetDefaultUnit(const G4String& u) {return SetUnit(u, UnitDefault);}
Command& SetParameterName(const G4String&, G4bool, G4bool =false);
Command& SetDefaultValue(const G4String&);
Command& SetCandidates(const G4String&);
Command& SetToBeBroadcasted(G4bool s0) { command->SetToBeBroadcasted(s0); return *this; }
Command& SetToBeFlushed(G4bool s0) { command->SetToBeFlushed(s0); return *this; }
Command& SetWorkerThreadOnly(G4bool s0) { command->SetWorkerThreadOnly(s0); return *this; }
G4UIcommand* command;
const std::type_info* type;
};
struct Property : public Command {
Property(const G4AnyType& var, G4UIcommand* cmd) : Command(cmd, var.TypeInfo()) , variable(var) {}
Property() {}
G4AnyType variable;
};
struct Method : public Command {
Method(const G4AnyMethod& fun, void* obj, G4UIcommand* cmd) : Command(cmd, fun.ArgType()), method(fun), object(obj) {}
Method() : object(0) {}
G4AnyMethod method;
void* object;
};
///Declare Methods
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 G4String& defaultUnit, const G4AnyMethod& fun, const G4String& doc = "");
void SetDirectory(const G4String& dir) {directory = dir;}
void SetGuidance(const G4String& s);
private:
std::map<G4String, Property> properties;
std::map<G4String, Method> methods;
G4UIdirectory* dircmd;
G4String directory;
void* object;
public:
G4GenericMessenger(void* obj, const G4String& dir = "",
const G4String& doc = "");
// Contructor
virtual ~G4GenericMessenger();
// Destructor
virtual G4String GetCurrentValue(G4UIcommand* command);
// The concrete, but generic implementation of this method.
virtual void SetNewValue(G4UIcommand* command, G4String newValue);
// The concrete, generic implementation of this method converts
// the string "newValue" to action.
public:
struct Command
{
enum UnitSpec
{
UnitCategory,
UnitDefault
};
Command(G4UIcommand* cmd, const std::type_info& ti)
: command(cmd)
, type(&ti)
{}
Command()
{}
Command& SetStates(G4ApplicationState s0)
{
command->AvailableForStates(s0);
return *this;
}
Command& SetStates(G4ApplicationState s0, G4ApplicationState s1)
{
command->AvailableForStates(s0, s1);
return *this;
}
Command& SetStates(G4ApplicationState s0, G4ApplicationState s1,
G4ApplicationState s2)
{
command->AvailableForStates(s0, s1, s2);
return *this;
}
Command& SetStates(G4ApplicationState s0, G4ApplicationState s1,
G4ApplicationState s2, G4ApplicationState s3)
{
command->AvailableForStates(s0, s1, s2, s3);
return *this;
}
Command& SetStates(G4ApplicationState s0, G4ApplicationState s1,
G4ApplicationState s2, G4ApplicationState s3,
G4ApplicationState s4)
{
command->AvailableForStates(s0, s1, s2, s3, s4);
return *this;
}
Command& SetRange(const G4String& range)
{
command->SetRange(range.c_str());
return *this;
}
Command& SetGuidance(const G4String& s0)
{
command->SetGuidance(s0);
return *this;
}
Command& SetUnit(const G4String&, UnitSpec = UnitDefault);
Command& SetUnitCategory(const G4String& u)
{
return SetUnit(u, UnitCategory);
}
Command& SetDefaultUnit(const G4String& u)
{
return SetUnit(u, UnitDefault);
}
Command& SetParameterName(const G4String&, G4bool, G4bool = false);
Command& SetDefaultValue(const G4String&);
Command& SetCandidates(const G4String&);
Command& SetToBeBroadcasted(G4bool s0)
{
command->SetToBeBroadcasted(s0);
return *this;
}
Command& SetToBeFlushed(G4bool s0)
{
command->SetToBeFlushed(s0);
return *this;
}
Command& SetWorkerThreadOnly(G4bool s0)
{
command->SetWorkerThreadOnly(s0);
return *this;
}
G4UIcommand* command = nullptr;
const std::type_info* type = nullptr;
};
struct Property : public Command
{
Property(const G4AnyType& var, G4UIcommand* cmd)
: Command(cmd, var.TypeInfo())
, variable(var)
{}
Property() {}
G4AnyType variable;
};
struct Method : public Command
{
Method(const G4AnyMethod& fun, void* obj, G4UIcommand* cmd)
: Command(cmd, fun.ArgType())
, method(fun)
, object(obj)
{}
Method()
{}
G4AnyMethod method;
void* object = nullptr;
};
// Declare Methods
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 G4String& defaultUnit,
const G4AnyMethod& fun,
const G4String& doc = "");
void SetDirectory(const G4String& dir) { directory = dir; }
void SetGuidance(const G4String& s);
private:
std::map<G4String, Property> properties;
std::map<G4String, Method> methods;
G4UIdirectory* dircmd = nullptr;
G4String directory;
void* object = nullptr;
};
#endif