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
+193 -150
View File
@@ -23,8 +23,13 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4AnyMethod
//
// Class description:
//
// The G4AnyMethod class represents any object method.
// The class only holds a member pointer.
// See http://www.boost.org/libs/any for Documentation.
// Copyright Kevlin Henney, 2000, 2001, 2002. All rights reserved.
//
@@ -38,175 +43,213 @@
// with features contributed and bugs found by
// Ed Brey, Mark Rodgers, Peter Dimov, and James Curran
// when: July 2001
// where: tested with BCC 5.5, MSVC 6.0, and g++ 2.95
#ifndef G4AnyMethod_h
#define G4AnyMethod_h 1
// --------------------------------------------------------------------
#ifndef G4AnyMethod_hh
#define G4AnyMethod_hh 1
#include <functional>
/** Bad Argument exception */
class G4BadArgument: public std::bad_cast {
public:
class G4BadArgument : public std::bad_cast
{
public:
G4BadArgument() {}
virtual const char* what() const throw() {
virtual const char* what() const throw()
{
return "G4BadArgument: failed operator()";
}
};
#include <type_traits>
using std::remove_reference;
using std::remove_const;
using std::remove_reference;
/**
* @class G4AnyMethod G4AnyMethod.hh
* This class represents any object method. The class only holds a member pointer.
*/
class G4AnyMethod {
public:
/** contructor */
G4AnyMethod(): fContent(0), narg(0) {}
template <class S, class T> G4AnyMethod(S (T::*f)()) : narg(0) {
fContent = new FuncRef<S,T>(f);
}
template <class S, class T, class A0> G4AnyMethod(S (T::*f)(A0)) : narg(1) {
fContent = new FuncRef1<S,T,A0>(f);
}
template <class S, class T, class A0, class A1> G4AnyMethod(S (T::*f)(A0,A1)) : narg(2) {
fContent = new FuncRef2<S,T,A0,A1>(f);
}
G4AnyMethod(const G4AnyMethod &other):
fContent(other.fContent ? other.fContent->Clone() : 0),narg(other.narg) {}
/** destructor */
~G4AnyMethod() {
delete fContent;
}
G4AnyMethod& Swap(G4AnyMethod& rhs) {
std::swap(fContent, rhs.fContent);
std::swap(narg, rhs.narg);
return *this;
}
/** Asignment operator */
template <class S, class T> G4AnyMethod& operator =(S (T::*f)()) {
G4AnyMethod(f).Swap(*this);
narg = 0;
return *this;
}
template <class S, class T, class A0> G4AnyMethod& operator =(S (T::*f)(A0)) {
G4AnyMethod(f).Swap(*this);
narg = 1;
return *this;
}
template <class S, class T, class A0, class A1> G4AnyMethod& operator =(S (T::*f)(A0, A1)) {
G4AnyMethod(f).Swap(*this);
narg = 1;
return *this;
}
/** Asigment operator */
G4AnyMethod& operator =(const G4AnyMethod& rhs) {
G4AnyMethod(rhs).Swap(*this);
narg = rhs.narg;
return *this;
}
/** Query */
bool Empty() const {
return !fContent;
}
/** call operator */
void operator()(void* obj) {
fContent->operator()(obj);
}
void operator()(void* obj, const std::string& a0) {
fContent->operator()(obj, a0);
}
/** Number of arguments */
size_t NArg() const { return narg; }
const std::type_info& ArgType(size_t n = 0) const {
return fContent ? fContent->ArgType(n) : typeid(void);
}
private:
class Placeholder {
class G4AnyMethod
{
public:
Placeholder() {}
virtual ~Placeholder() {}
virtual Placeholder* Clone() const = 0;
virtual void operator()(void*) = 0;
virtual void operator()(void*,const std::string&) = 0;
virtual const std::type_info& ArgType(size_t) const = 0;
};
template <class S, class T> struct FuncRef: public Placeholder {
FuncRef(S (T::*f)()) : fRef(f) {}
virtual void operator()(void* obj) {
((T*)obj->*fRef)();
}
virtual void operator()(void*, const std::string&) {
throw G4BadArgument();
}
virtual Placeholder* Clone() const {
return new FuncRef(fRef);
}
virtual const std::type_info& ArgType(size_t) const {
return typeid(void);
}
S (T::*fRef)();
};
template <class S, class T, class A0> struct FuncRef1: public Placeholder {
typedef typename remove_const<typename remove_reference<A0>::type>::type nakedA0;
FuncRef1(S (T::*f)(A0)) : fRef(f) {}
virtual void operator()(void*) {
throw G4BadArgument();
}
virtual void operator()(void* obj, const std::string& s0) {
nakedA0 a0;
std::stringstream strs(s0);
strs >> a0;
((T*)obj->*fRef)(a0);
}
virtual Placeholder* Clone() const {
return new FuncRef1(fRef);
}
virtual const std::type_info& ArgType(size_t) const {
return typeid(A0);
}
S (T::*fRef)(A0);
};
/** contructors */
template <class S, class T, class A0, class A1> struct FuncRef2: public Placeholder {
typedef typename remove_const<typename remove_reference<A0>::type>::type nakedA0;
typedef typename remove_const<typename remove_reference<A1>::type>::type nakedA1;
FuncRef2(S (T::*f)(A0, A1)) : fRef(f) {}
virtual void operator()(void*) {
throw G4BadArgument();
G4AnyMethod()
{}
template <class S, class T>
G4AnyMethod(S (T::*f)())
{
fContent = new FuncRef<S, T>(f);
}
virtual void operator()(void* obj, const std::string& s0) {
nakedA0 a0;
nakedA1 a1;
std::stringstream strs(s0);
strs >> a0 >> a1;
((T*)obj->*fRef)(a0, a1);
template <class S, class T, class A0>
G4AnyMethod(S (T::*f)(A0))
: narg(1)
{
fContent = new FuncRef1<S, T, A0>(f);
}
virtual Placeholder* Clone() const {
return new FuncRef2(fRef);
template <class S, class T, class A0, class A1>
G4AnyMethod(S (T::*f)(A0, A1))
: narg(2)
{
fContent = new FuncRef2<S, T, A0, A1>(f);
}
virtual const std::type_info& ArgType(size_t i) const {
return i == 0 ? typeid(A0) : typeid(A1);
G4AnyMethod(const G4AnyMethod& other)
: fContent(other.fContent ? other.fContent->Clone() : nullptr)
, narg(other.narg)
{}
/** destructor */
~G4AnyMethod() { delete fContent; }
G4AnyMethod& Swap(G4AnyMethod& rhs)
{
std::swap(fContent, rhs.fContent);
std::swap(narg, rhs.narg);
return *this;
}
S (T::*fRef)(A0, A1);
};
Placeholder* fContent;
size_t narg;
/** Assignment operators */
template <class S, class T>
G4AnyMethod& operator=(S (T::*f)())
{
G4AnyMethod(f).Swap(*this);
narg = 0;
return *this;
}
template <class S, class T, class A0>
G4AnyMethod& operator=(S (T::*f)(A0))
{
G4AnyMethod(f).Swap(*this);
narg = 1;
return *this;
}
template <class S, class T, class A0, class A1>
G4AnyMethod& operator=(S (T::*f)(A0, A1))
{
G4AnyMethod(f).Swap(*this);
narg = 1;
return *this;
}
G4AnyMethod& operator=(const G4AnyMethod& rhs)
{
G4AnyMethod(rhs).Swap(*this);
narg = rhs.narg;
return *this;
}
/** Query */
G4bool Empty() const { return !fContent; }
/** call operators */
void operator()(void* obj) { fContent->operator()(obj); }
void operator()(void* obj, const std::string& a0)
{
fContent->operator()(obj, a0);
}
/** Number of arguments */
std::size_t NArg() const { return narg; }
const std::type_info& ArgType(size_t n = 0) const
{
return fContent ? fContent->ArgType(n) : typeid(void);
}
private:
class Placeholder
{
public:
Placeholder() {}
virtual ~Placeholder() {}
virtual Placeholder* Clone() const = 0;
virtual void operator()(void*) = 0;
virtual void operator()(void*, const std::string&) = 0;
virtual const std::type_info& ArgType(size_t) const = 0;
};
template <class S, class T>
struct FuncRef : public Placeholder
{
FuncRef(S (T::*f)())
: fRef(f)
{}
virtual void operator()(void* obj) { ((T*) obj->*fRef)(); }
virtual void operator()(void*, const std::string&)
{
throw G4BadArgument();
}
virtual Placeholder* Clone() const { return new FuncRef(fRef); }
virtual const std::type_info& ArgType(std::size_t) const
{
return typeid(void);
}
S (T::*fRef)();
};
template <class S, class T, class A0>
struct FuncRef1 : public Placeholder
{
typedef
typename remove_const<typename remove_reference<A0>::type>::type nakedA0;
FuncRef1(S (T::*f)(A0))
: fRef(f)
{}
virtual void operator()(void*) { throw G4BadArgument(); }
virtual void operator()(void* obj, const std::string& s0)
{
nakedA0 a0;
std::stringstream strs(s0);
strs >> a0;
((T*) obj->*fRef)(a0);
}
virtual Placeholder* Clone() const { return new FuncRef1(fRef); }
virtual const std::type_info& ArgType(size_t) const { return typeid(A0); }
S (T::*fRef)(A0);
};
template <class S, class T, class A0, class A1>
struct FuncRef2 : public Placeholder
{
typedef
typename remove_const<typename remove_reference<A0>::type>::type nakedA0;
typedef
typename remove_const<typename remove_reference<A1>::type>::type nakedA1;
FuncRef2(S (T::*f)(A0, A1))
: fRef(f)
{}
virtual void operator()(void*) { throw G4BadArgument(); }
virtual void operator()(void* obj, const std::string& s0)
{
nakedA0 a0;
nakedA1 a1;
std::stringstream strs(s0);
strs >> a0 >> a1;
((T*) obj->*fRef)(a0, a1);
}
virtual Placeholder* Clone() const { return new FuncRef2(fRef); }
virtual const std::type_info& ArgType(size_t i) const
{
return i == 0 ? typeid(A0) : typeid(A1);
}
S (T::*fRef)(A0, A1);
};
Placeholder* fContent = nullptr;
std::size_t narg = 0;
};
#endif
+194 -143
View File
@@ -23,8 +23,13 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4AnyType
//
//
// Class description:
//
// The class G4AnyType represents any data type.
// The class only holds a reference to the type and not the value.
// See http://www.boost.org/libs/any for Documentation.
// Copyright Kevlin Henney, 2000, 2001, 2002. All rights reserved.
//
@@ -38,10 +43,9 @@
// with features contributed and bugs found by
// Ed Brey, Mark Rodgers, Peter Dimov, and James Curran
// when: July 2001
// where: tested with BCC 5.5, MSVC 6.0, and g++ 2.95
#ifndef G4AnyType_h
#define G4AnyType_h 1
// --------------------------------------------------------------------
#ifndef G4AnyType_hh
#define G4AnyType_hh 1
#include <algorithm>
#include <typeinfo>
@@ -51,176 +55,223 @@
#include "G4UIcommand.hh"
class G4String;
namespace CLHEP {
namespace CLHEP
{
class Hep3Vector;
}
/**
* @class G4AnyType G4AnyType.hh
* This class represents any data type. The class only holds a reference to the type and not the value.
*/
class G4AnyType {
public:
/** Constructor */
G4AnyType():
fContent(0) {}
/** Constructor */
template <typename ValueType> G4AnyType(ValueType &value):
fContent(new Ref<ValueType>(value)) {}
/** Copy Constructor */
G4AnyType(const G4AnyType &other):
fContent(other.fContent ? other.fContent->Clone() : 0) {}
/** Dtor */
~G4AnyType() {
delete fContent;
}
/** bool operator */
operator bool() {
return !Empty();
}
/** Modifier */
G4AnyType& Swap(G4AnyType& rhs) {
std::swap(fContent, rhs.fContent);
return *this;
}
/** Modifier */
template <typename ValueType> G4AnyType& operator =(const ValueType& rhs) {
G4AnyType(rhs).Swap(*this);
return *this;
}
/** Modifier */
G4AnyType& operator =(const G4AnyType& rhs) {
G4AnyType(rhs).Swap(*this);
return *this;
}
/** Query */
bool Empty() const {
return !fContent;
}
/** Query */
const std::type_info& TypeInfo() const {
return fContent ? fContent->TypeInfo() : typeid(void);
}
/** Adress */
void* Address() const {
return fContent ? fContent->Address() : 0;
}
/** String conversion */
std::string ToString() const {
return fContent->ToString();
}
/** String conversion */
void FromString(const std::string& val) {
fContent->FromString(val);
}
private:
/**
* @class Placeholder G4AnyType.h G4AnyType.h
*/
class Placeholder {
class G4AnyType
{
public:
/** Constructor */
Placeholder() {}
/** Constructors */
G4AnyType()
{}
template <typename ValueType>
G4AnyType(ValueType& value)
: fContent(new Ref<ValueType>(value))
{}
/** Copy Constructor */
G4AnyType(const G4AnyType& other)
: fContent(other.fContent ? other.fContent->Clone() : 0)
{}
/** Destructor */
virtual ~Placeholder() {}
/** Query */
virtual const std::type_info& TypeInfo() const = 0;
/** Query */
virtual Placeholder* Clone() const = 0;
/** Query */
virtual void* Address() const = 0;
/** ToString */
virtual std::string ToString() const = 0;
/** FromString */
virtual void FromString(const std::string& val) = 0;
};
template <typename ValueType> class Ref: public Placeholder {
public:
/** Constructor */
Ref(ValueType& value): fRef(value) {}
/** Query */
virtual const std::type_info& TypeInfo() const {
return typeid(ValueType);
~G4AnyType() { delete fContent; }
/** bool operator */
operator bool() { return !Empty(); }
/** Modifiers */
G4AnyType& Swap(G4AnyType& rhs)
{
std::swap(fContent, rhs.fContent);
return *this;
}
/** Clone */
virtual Placeholder* Clone() const {
return new Ref(fRef);
template <typename ValueType>
G4AnyType& operator=(const ValueType& rhs)
{
G4AnyType(rhs).Swap(*this);
return *this;
}
G4AnyType& operator=(const G4AnyType& rhs)
{
G4AnyType(rhs).Swap(*this);
return *this;
}
/** Queries */
G4bool Empty() const { return !fContent; }
const std::type_info& TypeInfo() const
{
return fContent ? fContent->TypeInfo() : typeid(void);
}
/** Address */
virtual void* Address() const {
return (void*) (&fRef);
}
/** ToString */
virtual std::string ToString() const {
std::stringstream ss;
ss << fRef;
return ss.str();
}
/** FromString */
virtual void FromString(const std::string& val) {
std::stringstream ss(val);
ss >> fRef;
}
void* Address() const { return fContent ? fContent->Address() : 0; }
/** String conversions */
std::string ToString() const { return fContent->ToString(); }
void FromString(const std::string& val) { fContent->FromString(val); }
private:
class Placeholder
{
public:
Placeholder() {}
virtual ~Placeholder() {}
/** Queries */
virtual const std::type_info& TypeInfo() const = 0;
virtual Placeholder* Clone() const = 0;
virtual void* Address() const = 0;
/** ToString */
virtual std::string ToString() const = 0;
/** FromString */
virtual void FromString(const std::string& val) = 0;
};
template <typename ValueType>
class Ref : public Placeholder
{
public:
/** Constructor */
Ref(ValueType& value)
: fRef(value)
{}
/** Query */
virtual const std::type_info& TypeInfo() const
{
return typeid(ValueType);
}
/** Clone */
virtual Placeholder* Clone() const { return new Ref(fRef); }
/** Address */
virtual void* Address() const { return (void*) (&fRef); }
/** ToString */
virtual std::string ToString() const
{
std::stringstream ss;
ss << fRef;
return ss.str();
}
/** FromString */
virtual void FromString(const std::string& val)
{
std::stringstream ss(val);
ss >> fRef;
}
ValueType& fRef; // representation
};
/** representation */
ValueType& fRef;
};
/** representation */
template <typename ValueType> friend ValueType* any_cast(G4AnyType*);
/** representation */
Placeholder* fContent;
template <typename ValueType>
friend ValueType* any_cast(G4AnyType*);
Placeholder* fContent = nullptr;
};
/**
* Specializations
*/
//
// Specializations
//
template <> inline void G4AnyType::Ref<bool>::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<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) {
template <>
inline void G4AnyType::Ref<G4ThreeVector>::FromString(const std::string& val)
{
fRef = G4UIcommand::ConvertTo3Vector(val.c_str());
}
/**
* @class G4BadAnyCast G4AnyType.h Reflex/G4AnyType.h
* @author K. Henney
*/
class G4BadAnyCast: public std::bad_cast {
public:
/** Constructor */
G4BadAnyCast() {}
/** Query */
virtual const char* what() const throw() {
return "G4BadAnyCast: failed conversion using any_cast";
}
class G4BadAnyCast : public std::bad_cast
{
public:
G4BadAnyCast() {}
virtual const char* what() const throw()
{
return "G4BadAnyCast: failed conversion using any_cast";
}
};
/** value */
template <typename ValueType> ValueType* any_cast(G4AnyType* operand) {
template <typename ValueType>
ValueType* any_cast(G4AnyType* operand)
{
return operand && operand->TypeInfo() == typeid(ValueType)
? &static_cast<G4AnyType::Ref<ValueType>*>(operand->fContent)->fRef : 0;
? &static_cast<G4AnyType::Ref<ValueType>*>(operand->fContent)->fRef
: nullptr;
}
/** value */
template <typename ValueType> const ValueType* any_cast(const G4AnyType* operand) {
template <typename ValueType>
const ValueType* any_cast(const G4AnyType* operand)
{
return any_cast<ValueType>(const_cast<G4AnyType*>(operand));
}
/** value */
template <typename ValueType> ValueType any_cast(const G4AnyType& operand) {
template <typename ValueType>
ValueType any_cast(const G4AnyType& operand)
{
const ValueType* result = any_cast<ValueType>(&operand);
if (!result) {
if(!result)
{
throw G4BadAnyCast();
}
return *result;
+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
@@ -23,15 +23,16 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4LocalThreadCoutMessenger
//
// Class description
//
// class description
//
// This class is the messenger for handling cout/cerr of local thread
//
// This class is the messenger for handling cout/cerr of a local thread
#ifndef G4LocalThreadCoutMessenger_h
#define G4LocalThreadCoutMessenger_h 1
// Author: M.Asai, 2013
// --------------------------------------------------------------------
#ifndef G4LocalThreadCoutMessenger_hh
#define G4LocalThreadCoutMessenger_hh 1
#include "globals.hh"
#include "G4UImessenger.hh"
@@ -42,25 +43,24 @@ class G4UIcmdWithABool;
class G4UIcmdWithAString;
class G4UIcmdWithAnInteger;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
class G4LocalThreadCoutMessenger: public G4UImessenger
class G4LocalThreadCoutMessenger : public G4UImessenger
{
public:
G4LocalThreadCoutMessenger();
~G4LocalThreadCoutMessenger();
~G4LocalThreadCoutMessenger();
void SetNewValue(G4UIcommand*, G4String);
private:
G4UIdirectory* coutDir;
G4UIcommand* coutFileNameCmd;
G4UIcommand* cerrFileNameCmd;
G4UIcmdWithABool* bufferCoutCmd;
G4UIcmdWithAString* prefixCmd;
G4UIcmdWithAnInteger* ignoreCmd;
G4UIcmdWithABool* ignoreInitCmd;
private:
G4UIdirectory* coutDir = nullptr;
G4UIcommand* coutFileNameCmd = nullptr;
G4UIcommand* cerrFileNameCmd = nullptr;
G4UIcmdWithABool* bufferCoutCmd = nullptr;
G4UIcmdWithAString* prefixCmd = nullptr;
G4UIcmdWithAnInteger* ignoreCmd = nullptr;
G4UIcmdWithABool* ignoreInitCmd = nullptr;
};
#endif
@@ -0,0 +1,83 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
//
//
// class description
//
// This class is the messenger of the class which maintain the profiling
// controls (located in global/management/include/G4Profiler.hh).
// In general, it forwards to the argument parser provided by timemory
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
#ifndef G4ProfilerMessenger_h
#define G4ProfilerMessenger_h 1
#include "globals.hh"
#include "G4UImessenger.hh"
#include "G4Profiler.hh"
class G4UIdirectory;
class G4UIcmdWithAString;
class G4UIcmdWithABool;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
class G4ProfilerMessenger : public G4UImessenger
{
public:
G4ProfilerMessenger();
~G4ProfilerMessenger();
// no copy but move is fine
G4ProfilerMessenger(const G4ProfilerMessenger&) = delete;
G4ProfilerMessenger(G4ProfilerMessenger&&) = default;
// no copy but move is fine
G4ProfilerMessenger& operator=(const G4ProfilerMessenger&) = delete;
G4ProfilerMessenger& operator=(G4ProfilerMessenger&&) = default;
void SetNewValue(G4UIcommand*, G4String);
// G4String GetCurrentValue(G4UIcommand* command);
private:
using stringcmd_pair = std::pair<G4UIcmdWithAString*, std::string>;
using boolcmd_pair = std::pair<G4UIcmdWithABool*, std::string>;
using directory_array = std::array<G4UIdirectory*, G4ProfileType::TypeEnd>;
using stringcmd_array = std::array<stringcmd_pair, G4ProfileType::TypeEnd>;
using boolcmd_array = std::array<boolcmd_pair, G4ProfileType::TypeEnd>;
using boolcmd_vector = std::vector<boolcmd_pair>;
G4UIdirectory* profileDirectory;
G4UIdirectory* profileOutputDirectory;
directory_array profileTypeDirs;
boolcmd_array profileEnableCmds;
boolcmd_vector profileGeneralCmds;
stringcmd_array profileCompCmds;
};
#endif
+24 -27
View File
@@ -23,47 +23,44 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4UIaliasList
//
// Class description:
//
// This class is exclusively used by G4UImanager for handling the
// alias list.
#ifndef G4UIaliasList_h
#define G4UIaliasList_h 1
// Author: M.Asai, 1 October 2001
// --------------------------------------------------------------------
#ifndef G4UIaliasList_hh
#define G4UIaliasList_hh 1
#include "globals.hh"
#include <vector>
// class description:
//
// This class is exclusively used by G4UImanager for handling the
// alias list.
//
#include "globals.hh"
class G4UIaliasList
class G4UIaliasList
{
public:
G4UIaliasList();
~G4UIaliasList();
G4UIaliasList();
~G4UIaliasList();
void RemoveAlias(const char* aliasName);
void ChangeAlias(const char* aliasName, const char* aliasValue);
G4String* FindAlias(const char* aliasName);
void List();
private:
G4bool operator==(const G4UIaliasList &right) const;
G4bool operator!=(const G4UIaliasList &right) const;
public:
void RemoveAlias(const char* aliasName);
void ChangeAlias(const char* aliasName, const char* aliasValue);
G4String* FindAlias(const char* aliasName);
void List();
G4bool operator==(const G4UIaliasList& right) const;
G4bool operator!=(const G4UIaliasList& right) const;
private:
void AddNewAlias(const char* aliasName, const char* aliasValue);
G4int FindAliasID(const char* aliasName);
private:
std::vector<G4String*> alias;
std::vector<G4String*> value;
void AddNewAlias(const char* aliasName, const char* aliasValue);
G4int FindAliasID(const char* aliasName);
std::vector<G4String*> alias;
std::vector<G4String*> value;
};
#endif
+35 -38
View File
@@ -23,59 +23,56 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4UIbatch
//
// ====================================================================
// G4UIbatch.hh
// Class description:
//
// 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 G4UI_BATCH_H
#define G4UI_BATCH_H 1
// This is a concrete class of G4UIsession.
// This class object is instantiated by G4UImanager every time
// the "/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().
// Author: M.Asai, 2000
// --------------------------------------------------------------------
#ifndef G4UI_BATCH_HH
#define G4UI_BATCH_HH 1
#include "G4UIsession.hh"
#include <fstream>
// ====================================================================
//
// class definition
//
// ====================================================================
#include "G4UIsession.hh"
class G4UIbatch : public G4UIsession {
private:
G4UIsession* previousSession;
class G4UIbatch : public G4UIsession
{
public:
std::ifstream macroStream;
G4bool isOpened;
G4UIbatch(const char* fileName, G4UIsession* prevSession = nullptr);
// "prevSession" must be null if this class is constructed from main().
//static G4bool commandFailed;
~G4UIbatch();
// get command from a batch script file
G4String ReadCommand();
G4int ExecCommand(const G4String& command);
inline G4UIsession* GetPreviousSession() const;
public:
G4UIbatch(const char* fileName, G4UIsession* prevSession=0);
// "prevSession" must be 0 if this class is constructed
// from main().
virtual G4UIsession* SessionStart();
virtual void PauseSessionStart(const G4String& Prompt);
~G4UIbatch();
G4UIsession* GetPreviousSession() const;
private:
virtual G4UIsession* SessionStart();
virtual void PauseSessionStart(const G4String& Prompt);
G4String ReadCommand();
// Get command from a batch script file
G4int ExecCommand(const G4String& command);
G4UIsession* previousSession = nullptr;
std::ifstream macroStream;
G4bool isOpened = false;
};
// ============================================================================
// inlines
// --------------------------------------------------------------------
// Inline methods
// --------------------------------------------------------------------
inline G4UIsession* G4UIbatch::GetPreviousSession() const
{
+27 -41
View File
@@ -23,57 +23,43 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4UIbridge
//
// ====================================================================
// G4UIbridge.hh
// Class description:
//
// 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
// This class is 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 registered directory name, it is immediately
// forwarded to the registered G4UImanager. Such forwarded command
// is not processed in the master thread nor by other worker thread
// Author: A.Dotti, 2013
// --------------------------------------------------------------------
#ifndef G4UIbridge_hh
#define G4UIbridge_hh 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 G4UImanager;
class G4UIbridge
class G4UIbridge
{
public:
G4UIbridge(G4UImanager* localUI,G4String dir);
~G4UIbridge();
public:
G4int ApplyCommand(const G4String& aCmd);
G4UIbridge(G4UImanager* localUI, G4String dir);
~G4UIbridge();
private:
G4UImanager* localUImanager;
G4String dirName;
G4int ApplyCommand(const G4String& aCmd);
public:
inline G4UImanager* LocalUI() const
{ return localUImanager; }
inline G4String DirName() const
{ return dirName; }
inline G4int DirLength() const
{ return dirName.length(); }
inline G4UImanager* LocalUI() const { return localUImanager; }
inline const G4String& DirName() const { return dirName; }
inline G4int DirLength() const { return dirName.length(); }
private:
G4UImanager* localUImanager = nullptr;
G4String dirName;
};
#endif
+34 -29
View File
@@ -23,46 +23,51 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4UIcmdWith3Vector
//
// Class description:
//
//
// A concrete class of G4UIcommand. The command defined by this class
// takes three double values.
// General information of G4UIcommand is given in G4UIcommand.hh
#ifndef G4UIcmdWith3Vector_H
#define G4UIcmdWith3Vector_H 1
// Author: M.Asai, 1998
// --------------------------------------------------------------------
#ifndef G4UIcmdWith3Vector_hh
#define G4UIcmdWith3Vector_hh 1
#include "G4UIcommand.hh"
#include "G4ThreeVector.hh"
// class description:
// A concrete class of G4UIcommand. The command defined by this class
// takes three double values.
// General information of G4UIcommand is given in G4UIcommand.hh.
class G4UIcmdWith3Vector : public G4UIcommand
{
public: // with description
G4UIcmdWith3Vector
(const char * theCommandPath,G4UImessenger * theMessenger);
// Constructor. The command string with full path directory
// and the pointer to the messenger must be given.
public:
G4UIcmdWith3Vector(const char* theCommandPath, G4UImessenger* theMessenger);
// Constructor. The command string with full path directory
// and the pointer to the messenger must be given
static G4ThreeVector GetNew3VectorValue(const char* paramString);
// Convert string which represents three double values to
// G4ThreeVector.
void SetParameterName(const char * theNameX,const char * theNameY,
const char * theNameZ,G4bool omittable,G4bool currentAsDefault=false);
// Set the parameter names for three parameters. Names are used by
// the range checking routine.
// If "omittable" is set as true, the user of this command can ommit
// the value(s) when he/she applies the command. If "omittable" is false,
// the user must supply all three values.
// "currentAsDefault" flag is valid only if "omittable" is true. If this
// flag is true, the current values are used as the default values when the
// user ommit some of the parameters. If this flag is false, the values
// given by the next SetDefaultValue() method are used.
// Convert string which represents three double values to
// G4ThreeVector
void SetParameterName(const char* theNameX, const char* theNameY,
const char* theNameZ, G4bool omittable,
G4bool currentAsDefault = false);
// Set the parameter names for three parameters. Names are used by
// the range checking function.
// If "omittable" is set as true, the user of this command can omit
// the value(s) when the command is applied. If "omittable" is false,
// the user must supply all three values.
// "currentAsDefault" flag is valid only if "omittable" is true. If this
// flag is true, the current values are used as the default values when
// the user omits some of the parameters. If this flag is false, the
// values given by the next SetDefaultValue() method are used
void SetDefaultValue(G4ThreeVector defVal);
// Set the default values of the parameters. These default values are used
// when the user of this command ommits some of the parameter values, and
// "ommitable" is true and "currentAsDefault" is false.
// Set the default values of the parameters. These default values are
// used when the user of this command omits some of the parameter values,
// and "omittable" is true and "currentAsDefault" is false
};
#endif
@@ -23,80 +23,94 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4UIcmdWith3VectorAndUnit
//
// Class description:
//
//
// A concrete class of G4UIcommand. The command defined by this class
// takes three double values and a unit.
// General information of G4UIcommand is given in G4UIcommand.hh
#ifndef G4UIcmdWith3VectorAndUnit_H
#define G4UIcmdWith3VectorAndUnit_H 1
// Author: M.Asai, 1998
// --------------------------------------------------------------------
#ifndef G4UIcmdWith3VectorAndUnit_hh
#define G4UIcmdWith3VectorAndUnit_hh 1
#include "G4UIcommand.hh"
#include "G4ThreeVector.hh"
// class description:
// A concrete class of G4UIcommand. The command defined by this class
// takes three double values and a unit.
// General information of G4UIcommand is given in G4UIcommand.hh.
class G4UIcmdWith3VectorAndUnit : public G4UIcommand
{
public: // with description
G4UIcmdWith3VectorAndUnit
(const char * theCommandPath,G4UImessenger * theMessenger);
// Constructor. The command string with full path directory
// and the pointer to the messenger must be given.
public:
G4UIcmdWith3VectorAndUnit(const char* theCommandPath,
G4UImessenger* theMessenger);
// Constructor. The command string with full path directory
// and the pointer to the messenger must be given
virtual G4int DoIt(G4String parameterList);
static G4ThreeVector GetNew3VectorValue(const char* paramString);
// Convert string which represents three double values and a unit to
// G4ThreeVector. Values are converted to the Geant4 internal unit.
// Convert string which represents three double values and a unit to
// G4ThreeVector. Values are converted to the Geant4 internal unit
static G4ThreeVector GetNew3VectorRawValue(const char* paramString);
// Convert string which represents three double values and a unit to
// G4ThreeVector. Values are NOT converted to the Geant4 internal unit
// but just as the given string.
// Convert string which represents three double values and a unit to
// G4ThreeVector. Values are NOT converted to the Geant4 internal unit
// but just as the given string
static G4double GetNewUnitValue(const char* paramString);
// Convert the unit string to the value of the unit. "paramString"
// must contain three double values AND a unit string.
// Convert the unit string to the value of the unit. "paramString"
// must contain three double values AND a unit string
G4String ConvertToStringWithBestUnit(G4ThreeVector vec);
// Convert a 3 vector value to a string of digits and unit. Best unit is
// chosen from the unit category of default unit (in case SetDefaultUnit()
// is defined) or category defined by SetUnitCategory().
// Convert a 3 vector value to a string of digits and unit. Best unit is
// chosen from the unit category of default unit (in case SetDefaultUnit()
// is defined) or category defined by SetUnitCategory()
G4String ConvertToStringWithDefaultUnit(G4ThreeVector vec);
// Convert a 3 vector value to a string of digits and unit. Best unit is
// chosen from the category defined by SetUnitCategory() in case default
// unit is not defined.
void SetParameterName(const char * theNameX,const char * theNameY,
const char * theNameZ,G4bool omittable,G4bool currentAsDefault=false);
// Set the parameter names for three parameters. Names are used by
// the range checking routine.
// If "omittable" is set as true, the user of this command can ommit
// the value(s) when he/she applies the command. If "omittable" is false,
// the user must supply all three values.
// "currentAsDefault" flag is valid only if "omittable" is true. If this
// flag is true, the current values are used as the default values when the
// user ommit some of the parameters. If this flag is false, the values
// given by the next SetDefaultValue() method are used.
// Convert a 3 vector value to a string of digits and unit. Best unit is
// chosen from the category defined by SetUnitCategory() in case default
// unit is not defined
void SetParameterName(const char* theNameX, const char* theNameY,
const char* theNameZ, G4bool omittable,
G4bool currentAsDefault = false);
// Set the parameter names for three parameters. Names are used by
// the range checking routine.
// If "omittable" is set as true, the user of this command can omit
// the value(s) when the command is applied. If "omittable" is false,
// the user must supply all three values.
// "currentAsDefault" flag is valid only if "omittable" is true. If this
// flag is true, the current values are used as the default values when
// the user omit some of the parameters. If this flag is false, the values
// given by the next SetDefaultValue() method are used
void SetDefaultValue(G4ThreeVector defVal);
// Set the default values of the parameters. These default values are used
// when the user of this command ommits some of the parameter values, and
// "ommitable" is true and "currentAsDefault" is false.
void SetUnitCategory(const char * unitCategory);
void SetUnitCandidates(const char * candidateList);
void SetDefaultUnit(const char * defUnit);
// These three methods must be used alternatively.
// The user cannot ommit the unit as the fourth parameter of the command if
// SetUnitCategory() or SetUnitCandidates() is used, while the unit defined
// by SetDefaultUnit() method is used as the default unit so that the user can
// ommits the fourth parameter.
// SetUnitCategory() defines the category of the units which will be accepted.
// The available categories can be found in G4SystemOfUnits.hh in global category.
// Only the units categorized in the given category are accepted as the fourth
// parameter of the command.
// SetUnitCandidates() defines the candidates of units. Units listed in the
// argument of this method must be separated by space(s). Only the units listed
// in the candidate list are accepted as the fourth parameter of the command.
// SetDefaultUnit() defines the default unit and also it defines the category
// of the allowed units. Thus only the units categorized as the given default
// unit will be accepted.
// Set the default values of the parameters. These default values are used
// when the user of this command omits some of the parameter values, and
// "omittable" is true and "currentAsDefault" is false
void SetUnitCategory(const char* unitCategory);
void SetUnitCandidates(const char* candidateList);
void SetDefaultUnit(const char* defUnit);
// These three methods must be used alternatively.
// The user cannot omit the unit as the fourth parameter of the command
// if SetUnitCategory() or SetUnitCandidates() is used, while the unit
// defined by SetDefaultUnit() method is used as the default unit so that
// the user can omit the fourth parameter.
// SetUnitCategory() defines the category of the units which will be
// accepted.
// The available categories can be found in G4SystemOfUnits.hh in 'global'
// category. Only the units categorized in the given category are accepted
// as the fourth parameter of the command.
// SetUnitCandidates() defines the candidates of units. Units listed in
// the argument of this method must be separated by space(s). Only the
// units listed in the candidate list are accepted as the fourth parameter
// of the command.
// SetDefaultUnit() defines the default unit and also defines the category
// of the allowed units. Thus only the units categorized as the given
// default unit will be accepted.
};
#endif
+35 -31
View File
@@ -23,47 +23,51 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4UIcmdWithABool
//
// Class description:
//
//
// A concrete class of G4UIcommand. The command defined by this class
// takes a Boolean value. Boolean value can be in the following notations:
// TRUE :
// 1 t T true TRUE
// FALSE :
// 0 f F false FALSE
// General information of G4UIcommand is given in G4UIcommand.hh
#ifndef G4UIcmdWithABool_H
#define G4UIcmdWithABool_H 1
// Author: M.Asai, 1998
// --------------------------------------------------------------------
#ifndef G4UIcmdWithABool_hh
#define G4UIcmdWithABool_hh 1
#include "G4UIcommand.hh"
// class description:
// A concrete class of G4UIcommand. The command defined by this class
// takes a boolean value. Boolean value can be the following notations.
// TRUE :
// 1 t T true TRUE
// FALSE :
// 0 f F false FALSE
// General information of G4UIcommand is given in G4UIcommand.hh.
class G4UIcmdWithABool : public G4UIcommand
{
public: // with description
G4UIcmdWithABool
(const char * theCommandPath,G4UImessenger * theMessenger);
// Constructor. The command string with full path directory
// and the pointer to the messenger must be given.
public:
G4UIcmdWithABool(const char* theCommandPath, G4UImessenger* theMessenger);
// Constructor. The command string with full path directory
// and the pointer to the messenger must be given
static G4bool GetNewBoolValue(const char* paramString);
// Convert string which represents a boolean value to G4bool.
void SetParameterName(const char * theName,G4bool omittable,
G4bool currentAsDefault=false);
// Set the parameter name for a boolean parameter.
// If "omittable" is set as true, the user of this command can ommit
// the value when he/she applies the command. If "omittable" is false,
// the user must supply a boolean value.
// "currentAsDefault" flag is valid only if "omittable" is true. If this
// flag is true, the current value is used as the default value when the
// user ommit the parameter. If this flag is false, the value given by the
// next SetDefaultValue() method is used.
// Convert string which represents a boolean value to G4bool
void SetParameterName(const char* theName, G4bool omittable,
G4bool currentAsDefault = false);
// Set the parameter name for a Boolean parameter.
// If "omittable" is set as true, the user of this command can omit
// the value when the command is applied. If "omittable" is false,
// the user must supply a Boolean value.
// "currentAsDefault" flag is valid only if "omittable" is true. If this
// flag is true, the current value is used as the default value when the
// user omits the parameter. If this flag is false, the value given by the
// next SetDefaultValue() method is used
void SetDefaultValue(G4bool defVal);
// Set the default value of the parameter. This default value is used
// when the user of this command ommits the parameter value, and
// "ommitable" is true and "currentAsDefault" is false.
// Set the default value of the parameter. This default value is used
// when the user of this command omits the parameter value, and
// "omittable" is true and "currentAsDefault" is false
};
#endif
+31 -27
View File
@@ -23,43 +23,47 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4UIcmdWithADouble
//
// Class description:
//
//
// A concrete class of G4UIcommand. The command defined by this class
// takes a double value.
// General information of G4UIcommand is given in G4UIcommand.hh
#ifndef G4UIcmdWithADouble_H
#define G4UIcmdWithADouble_H 1
// Author: M.Asai, 1998
// --------------------------------------------------------------------
#ifndef G4UIcmdWithADouble_hh
#define G4UIcmdWithADouble_hh 1
#include "G4UIcommand.hh"
// class description:
// A concrete class of G4UIcommand. The command defined by this class
// takes a double value.
// General information of G4UIcommand is given in G4UIcommand.hh.
class G4UIcmdWithADouble : public G4UIcommand
{
public: // with description
G4UIcmdWithADouble
(const char * theCommandPath,G4UImessenger * theMessenger);
// Constructor. The command string with full path directory
// and the pointer to the messenger must be given.
public:
G4UIcmdWithADouble(const char* theCommandPath, G4UImessenger* theMessenger);
// Constructor. The command string with full path directory
// and the pointer to the messenger must be given
static G4double GetNewDoubleValue(const char* paramString);
// Convert string which represents a double value to a double.
void SetParameterName(const char * theName,G4bool omittable,
G4bool currentAsDefault=false);
// Set the parameter name. The name is used by the range checking.
// If "omittable" is set as true, the user of this command can ommit
// the value when he/she applies the command. If "omittable" is false,
// the user must supply a double value.
// "currentAsDefault" flag is valid only if "omittable" is true. If this
// flag is true, the current value is used as the default value when the
// user ommit the parameter. If this flag is false, the value given by the
// next SetDefaultValue() method is used.
// Convert string which represents a double value to a double
void SetParameterName(const char* theName, G4bool omittable,
G4bool currentAsDefault = false);
// Set the parameter name. The name is used by the range checking.
// If "omittable" is set as true, the user of this command can omit
// the value when the command is applied. If "omittable" is false,
// the user must supply a double value.
// "currentAsDefault" flag is valid only if "omittable" is true. If this
// flag is true, the current value is used as the default value when the
// user omits the parameter. If this flag is false, the value given by
// the next SetDefaultValue() method is used
void SetDefaultValue(G4double defVal);
// Set the default value of the parameter. This default value is used
// when the user of this command ommits the parameter value, and
// "ommitable" is true and "currentAsDefault" is false.
// Set the default value of the parameter. This default value is used
// when the user of this command omits the parameter value, and
// "omittable" is true and "currentAsDefault" is false
};
#endif
@@ -23,79 +23,92 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4UIcmdWithADoubleAndUnit
//
// Class description:
//
//
// A concrete class of G4UIcommand. The command defined by this class
// takes a double value and a unit string.
// General information of G4UIcommand is given in G4UIcommand.hh
#ifndef G4UIcmdWithADoubleAndUnit_H
#define G4UIcmdWithADoubleAndUnit_H 1
// Author: M.Asai, 1998
// --------------------------------------------------------------------
#ifndef G4UIcmdWithADoubleAndUnit_hh
#define G4UIcmdWithADoubleAndUnit_hh 1
#include "G4UIcommand.hh"
// class description:
// A concrete class of G4UIcommand. The command defined by this class
// takes a double value and a unit string.
// General information of G4UIcommand is given in G4UIcommand.hh.
class G4UIcmdWithADoubleAndUnit : public G4UIcommand
{
public: // with description
G4UIcmdWithADoubleAndUnit
(const char * theCommandPath,G4UImessenger * theMessenger);
// Constructor. The command string with full path directory
// and the pointer to the messenger must be given.
public:
G4UIcmdWithADoubleAndUnit(const char* theCommandPath,
G4UImessenger* theMessenger);
// Constructor. The command string with full path directory
// and the pointer to the messenger must be given
virtual G4int DoIt(G4String parameterList);
static G4double GetNewDoubleValue(const char* paramString);
// Convert string which represents a double value and a unit to
// double. Value is converted to the Geant4 internal unit.
// Convert string which represents a double value and a unit to
// double. Value is converted to the Geant4 internal unit
static G4double GetNewDoubleRawValue(const char* paramString);
// Convert string which represents a double value and a unit to
// double. Value is NOT converted to the Geant4 internal unit
// but just as the given string.
// Convert string which represents a double value and a unit to
// double. Value is NOT converted to the Geant4 internal unit
// but just as the given string
static G4double GetNewUnitValue(const char* paramString);
// Convert the unit string to the value of the unit. "paramString"
// must contain a double value AND a unit string.
// Convert the unit string to the value of the unit. "paramString"
// must contain a double value AND a unit string
G4String ConvertToStringWithBestUnit(G4double val);
// Convert a double value to a string of digits and unit. Best unit is
// chosen from the unit category of default unit (in case SetDefaultUnit()
// is defined) or category defined by SetUnitCategory().
// Convert a double value to a string of digits and unit. Best unit is
// chosen from the unit category of default unit (in case SetDefaultUnit()
// is defined) or category defined by SetUnitCategory()
G4String ConvertToStringWithDefaultUnit(G4double val);
// Convert a double value to a string of digits and unit. Best unit is
// chosen from the category defined by SetUnitCategory() in case default
// unit is not defined.
void SetParameterName(const char * theName,G4bool omittable,
G4bool currentAsDefault=false);
// Set the parameter name for double parameterxs. Name is used by
// the range checking routine.
// If "omittable" is set as true, the user of this command can ommit
// the value when he/she applies the command. If "omittable" is false,
// the user must supply a value.
// "currentAsDefault" flag is valid only if "omittable" is true. If this
// flag is true, the current value is used as the default value when the
// user ommit the double parameter. If this flag is false, the value
// given by the next SetDefaultValue() method is used.
// Convert a double value to a string of digits and unit. Best unit is
// chosen from the category defined by SetUnitCategory() in case default
// unit is not defined
void SetParameterName(const char* theName, G4bool omittable,
G4bool currentAsDefault = false);
// Set the parameter name for double parameters. Name is used by
// the range checking function.
// If "omittable" is set as true, the user of this command can omit
// the value when the command is applied. If "omittable" is false,
// the user must supply a value.
// "currentAsDefault" flag is valid only if "omittable" is true. If this
// flag is true, the current value is used as the default value when the
// user omits the double parameter. If this flag is false, the value
// given by the next SetDefaultValue() method is used
void SetDefaultValue(G4double defVal);
// Set the default value of the parameter. This default value is used
// when the user of this command ommits the parameter value, and
// "ommitable" is true and "curreutAsDefault" is false.
void SetUnitCategory(const char * unitCategory);
void SetUnitCandidates(const char * candidateList);
void SetDefaultUnit(const char * defUnit);
// These three methods must be used alternatively.
// The user cannot ommit the unit as the second parameter of the command if
// SetUnitCategory() or SetUnitCandidates() is used, while the unit defined
// by SetDefaultUnit() method is used as the default unit so that the user can
// ommits the second parameter.
// SetUnitCategory() defines the category of the units which will be accepted.
// The available categories can be found in G4SystemOfUnits.hh in global category.
// Only the units categorized in the given category are accepted as the second
// parameter of the command.
// SetUnitCandidates() defines the candidates of units. Units listed in the
// argument of this method must be separated by space(s). Only the units listed
// in the candidate list are accepted as the second parameter of the command.
// SetDefaultUnit() defines the default unit and also it defines the category
// of the allowed units. Thus only the units categorized as the given default
// unit will be accepted.
// Set the default value of the parameter. This default value is used
// when the user of this command omits the parameter value, and
// "omittable" is true and "currentAsDefault" is false
void SetUnitCategory(const char* unitCategory);
void SetUnitCandidates(const char* candidateList);
void SetDefaultUnit(const char* defUnit);
// These three methods must be used alternatively.
// The user cannot omit the unit as the second parameter of the command
// if SetUnitCategory() or SetUnitCandidates() is used, while the unit
// defined by SetDefaultUnit() method is used as the default unit so that
// the user can omit the second parameter.
// SetUnitCategory() defines the category of the units which will be
// accepted.
// The available categories can be found in G4SystemOfUnits.hh in 'global'
// category. Only the units categorized in the given category are accepted
// as the second parameter of the command.
// SetUnitCandidates() defines the candidates of units. Units listed in
// the argument of this method must be separated by space(s). Only the
// units listed in the candidate list are accepted as the second parameter
// of the command.
// SetDefaultUnit() defines the default unit and also defines the category
// of the allowed units. Thus only the units categorized as the given
// default unit will be accepted
};
#endif
@@ -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. *
// ********************************************************************
//
// G4UIcmdWithALongInt
//
// Class description:
//
// A concrete class of G4UIcommand. The command defined by this class
// takes a long int value.
// General information of G4UIcommand is given in G4UIcommand.hh
// Author: M.Asai, 2020
// --------------------------------------------------------------------
#ifndef G4UIcmdWithALongInt_hh
#define G4UIcmdWithALongInt_hh 1
#include "G4UIcommand.hh"
class G4UIcmdWithALongInt : public G4UIcommand
{
public:
G4UIcmdWithALongInt(const char* commandPath, G4UImessenger* messenger);
// Constructor. The command string with full path directory
// and the pointer to the messenger must be given
static G4long GetNewLongIntValue(const char* paramString);
// Convert string to long int
void SetParameterName(const char* theName, G4bool omittable,
G4bool currentAsDefault = false);
// Set the parameter name. The name is used by the range checking.
// If "omittable" is set as true, the user of this command can omit
// the value when the command is applied. If "omittable" is false,
// the user must supply an integer value.
// "currentAsDefault" flag is valid only if "omittable" is true. If this
// flag is true, the current value is used as the default value when the
// user omits the parameter. If this flag is false, the value given by
// the next SetDefaultValue() method is used
void SetDefaultValue(G4long defVal);
// Set the default value of the parameter. This default value is used
// when the user of this command omits the parameter value, and
// "omittable" is true and "currentAsDefault" is false
};
#endif
+34 -31
View File
@@ -23,45 +23,48 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4UIcmdWithAString
//
// Class description:
//
//
// A concrete class of G4UIcommand. The command defined by this class
// takes a string. In case the parameter string contains space(s), it
// must be enclosed by double-quotations (").
// General information of G4UIcommand is given in G4UIcommand.hh
#ifndef G4UIcmdWithAString_H
#define G4UIcmdWithAString_H 1
// Author: M.Asai, 1998
// --------------------------------------------------------------------
#ifndef G4UIcmdWithAString_hh
#define G4UIcmdWithAString_hh 1
#include "G4UIcommand.hh"
// class description:
// A concrete class of G4UIcommand. The command defined by this class
// takes a string. Incase the parameter string contains space(s), it
// must be enclosed by double-quotations (").
// General information of G4UIcommand is given in G4UIcommand.hh.
class G4UIcmdWithAString : public G4UIcommand
{
public: // with description
G4UIcmdWithAString
(const char * theCommandPath,G4UImessenger * theMessenger);
// Constructor. The command string with full path directory
// and the pointer to the messenger must be given.
void SetParameterName(const char * theName,G4bool omittable,
G4bool currentAsDefault=false);
// Set the parameter name.
// If "omittable" is set as true, the user of this command can ommit
// the value when he/she applies the command. If "omittable" is false,
// the user must supply the parameter string.
// "currentAsDefault" flag is valid only if "omittable" is true. If this
// flag is true, the current value is used as the default value when the
// user ommit the parameter. If this flag is false, the value given by the
// next SetDefaultValue() method is used.
void SetCandidates(const char * candidateList);
// Defines the candidates of the parameter string. Candidates listed in
// the argument must be separated by space(s).
void SetDefaultValue(const char * defVal);
// Set the default value of the parameter. This default value is used
// when the user of this command ommits the parameter value, and
// "ommitable" is true and "curreutAsDefault" is false.
public:
G4UIcmdWithAString(const char* theCommandPath, G4UImessenger* theMessenger);
// Constructor. The command string with full path directory
// and the pointer to the messenger must be given
void SetParameterName(const char* theName, G4bool omittable,
G4bool currentAsDefault = false);
// If "omittable" is set to true, the user of this command can omit
// the value when the command is applied. If "omittable" is false,
// the user must supply the parameter string.
// "currentAsDefault" flag is valid only if "omittable" is true. If this
// flag is true, the current value is used as the default value when the
// user omits the parameter. If this flag is false, the value given by the
// next SetDefaultValue() method is used
void SetCandidates(const char* candidateList);
// Defines the candidates of the parameter string. Candidates listed in
// the argument must be separated by space(s)
void SetDefaultValue(const char* defVal);
// Set the default value of the parameter. This default value is used
// when the user of this command omits the parameter value, and
// "omittable" is true and "currentAsDefault" is false
};
#endif
@@ -23,43 +23,47 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4UIcmdWithAnInteger
//
// Class description:
//
//
// A concrete class of G4UIcommand. The command defined by this class
// takes an integer value.
// General information of G4UIcommand is given in G4UIcommand.hh
#ifndef G4UIcmdWithAnInteger_H
#define G4UIcmdWithAnInteger_H 1
// Author: M.Asai, 1998
// --------------------------------------------------------------------
#ifndef G4UIcmdWithAnInteger_hh
#define G4UIcmdWithAnInteger_hh 1
#include "G4UIcommand.hh"
// class description:
// A concrete class of G4UIcommand. The command defined by this class
// takes an integer value.
// General information of G4UIcommand is given in G4UIcommand.hh.
class G4UIcmdWithAnInteger : public G4UIcommand
{
public: // with description
G4UIcmdWithAnInteger
(const char * theCommandPath,G4UImessenger * theMessenger);
// Constructor. The command string with full path directory
// and the pointer to the messenger must be given.
public:
G4UIcmdWithAnInteger(const char* commandPath, G4UImessenger* messenger);
// Constructor. The command string with full path directory
// and the pointer to the messenger must be given
static G4int GetNewIntValue(const char* paramString);
// Convert string which represents an integer to an integer.
void SetParameterName(const char * theName,G4bool omittable,
G4bool currentAsDefault=false);
// Set the parameter name. The name is used by the range checking.
// If "omittable" is set as true, the user of this command can ommit
// the value when he/she applies the command. If "omittable" is false,
// the user must supply an integer value.
// "currentAsDefault" flag is valid only if "omittable" is true. If this
// flag is true, the current value is used as the default value when the
// user ommit the parameter. If this flag is false, the value given by the
// next SetDefaultValue() method is used.
// Convert string which represents an integer to an integer
void SetParameterName(const char* theName, G4bool omittable,
G4bool currentAsDefault = false);
// Set the parameter name. The name is used by the range checking.
// If "omittable" is set as true, the user of this command can omit
// the value when the command is applied. If "omittable" is false,
// the user must supply an integer value.
// "currentAsDefault" flag is valid only if "omittable" is true. If this
// flag is true, the current value is used as the default value when the
// user omits the parameter. If this flag is false, the value given by
// the next SetDefaultValue() method is used
void SetDefaultValue(G4int defVal);
// Set the default value of the parameter. This default value is used
// when the user of this command ommits the parameter value, and
// "ommitable" is true and "currentAsDefault" is false.
// Set the default value of the parameter. This default value is used
// when the user of this command omits the parameter value, and
// "omittable" is true and "currentAsDefault" is false
};
#endif
@@ -23,27 +23,29 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4UIcmdWithoutParameter
//
// Class description:
//
//
// A concrete class of G4UIcommand. The command defined by this class
// takes no parameter argument.
// General information of G4UIcommand is given in G4UIcommand.hh
#ifndef G4UIcmdWithoutParameter_H
#define G4UIcmdWithoutParameter_H 1
// Author: M.Asai, 1998
// --------------------------------------------------------------------
#ifndef G4UIcmdWithoutParameter_hh
#define G4UIcmdWithoutParameter_hh 1
#include "G4UIcommand.hh"
// class description:
// A concrete class of G4UIcommand. The command defined by this class
// takes no parameter argument.
// General information of G4UIcommand is given in G4UIcommand.hh.
class G4UIcmdWithoutParameter : public G4UIcommand
{
public: // with description
G4UIcmdWithoutParameter
(const char * theCommandPath,G4UImessenger * theMessenger);
// Constructor. The command string with full path directory
// and the pointer to the messenger must be given.
public:
G4UIcmdWithoutParameter(const char* theCommandPath,
G4UImessenger* theMessenger);
// Constructor. The command string with full path directory
// and the pointer to the messenger must be given
};
#endif
+189 -183
View File
@@ -24,236 +24,242 @@
// ********************************************************************
//
// G4UIcommand
//
// Class description:
//
// This G4UIcommand is the "concrete" base class which represents a command
// used by Geant4 (G)UI. The user can use this class in case the parameter
// arguments of a command are not suitable with respect to the derived command
// classes.
// Some methods defined in this base class are used by the derived classes
// Author: Makoto Asai (SLAC)
// Author: Makoto Asai (SLAC), 1998
// --------------------------------------------------------------------
#ifndef G4UIcommand_hh
#define G4UIcommand_hh 1
#include <vector>
#include "G4UIparameter.hh"
class G4UImessenger;
#include "globals.hh"
#include "G4ApplicationState.hh"
#include <vector>
#include "G4UItokenNum.hh"
#include "G4ThreeVector.hh"
// class description:
//
// This G4UIcommand is the "concrete" base class which represents a command
// used by Geant4 (G)UI. The user can use this class in case the parameter
// arguments of a command are not suitable with respect to the derived command
// classes.
// Some methods defined in this base class are used by the derived classes.
//
class G4UImessenger;
class G4UIcommand
{
public:
G4UIcommand();
public: // with description
G4UIcommand(const char * theCommandPath, G4UImessenger * theMessenger,
G4bool tBB = true);
// Constructor. The command string with full path directory
G4UIcommand();
// Dummy default constructor
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.
// except for G4UIdirectory
public:
virtual ~G4UIcommand();
virtual ~G4UIcommand();
G4bool operator==(const G4UIcommand &right) const;
G4bool operator!=(const G4UIcommand &right) const;
G4bool operator==(const G4UIcommand& right) const;
G4bool operator!=(const G4UIcommand& right) const;
virtual G4int DoIt(G4String parameterList);
G4String GetCurrentValue();
public: // with description
void AvailableForStates(G4ApplicationState s1);
void AvailableForStates(G4ApplicationState s1,G4ApplicationState s2);
void AvailableForStates(G4ApplicationState s1,G4ApplicationState s2,
G4ApplicationState s3);
void AvailableForStates(G4ApplicationState s1,G4ApplicationState s2,
G4ApplicationState s3,G4ApplicationState s4);
void AvailableForStates(G4ApplicationState s1,G4ApplicationState s2,
G4ApplicationState s3,G4ApplicationState s4,
G4ApplicationState s5);
// These methods define the states where the command is available.
virtual G4int DoIt(G4String parameterList);
G4String GetCurrentValue();
void AvailableForStates(G4ApplicationState s1);
void AvailableForStates(G4ApplicationState s1, G4ApplicationState s2);
void AvailableForStates(G4ApplicationState s1, G4ApplicationState s2,
G4ApplicationState s3);
void AvailableForStates(G4ApplicationState s1, G4ApplicationState s2,
G4ApplicationState s3, G4ApplicationState s4);
void AvailableForStates(G4ApplicationState s1, G4ApplicationState s2,
G4ApplicationState s3, G4ApplicationState s4,
G4ApplicationState s5);
// These methods define the states where the command is available.
// Once one of these commands is invoked, the command application will
// be denied when Geant4 is NOT in the assigned states.
public:
G4bool IsAvailable();
virtual void List();
// be denied when Geant4 is NOT in the assigned states
public: // with description
static G4String ConvertToString(G4bool boolVal);
static G4String ConvertToString(G4int intValue);
static G4String ConvertToString(G4double doubleValue);
static G4String ConvertToString(G4double doubleValue,const char* unitName);
static G4String ConvertToString(G4ThreeVector vec);
static G4String ConvertToString(G4ThreeVector vec,const char* unitName);
// Static methods for conversion from value(s) to a string. These methods are to be
// used by GetCurrentValues() methods of concrete messengers.
G4bool IsAvailable();
static G4bool ConvertToBool(const char* st);
static G4int ConvertToInt(const char* st);
static G4double ConvertToDouble(const char* st);
static G4double ConvertToDimensionedDouble(const char* st);
static G4ThreeVector ConvertTo3Vector(const char* st);
static G4ThreeVector ConvertToDimensioned3Vector(const char* st);
// Static methods for conversion from a string to a value of the returning type.
// These methods are to be used directly by SetNewValues() methods of concrete
// messengers, or GetNewXXXValue() of classes derived from this G4UIcommand class.
virtual void List();
static G4double ValueOf(const char* unitName);
static G4String CategoryOf(const char* unitName);
static G4String UnitsList(const char* unitCategory);
// Static methods for unit and its category.
static G4String ConvertToString(G4bool boolVal);
static G4String ConvertToString(G4int intValue);
static G4String ConvertToString(G4long longValue);
static G4String ConvertToString(G4double doubleValue);
static G4String ConvertToString(G4double doubleValue, const char* unitName);
static G4String ConvertToString(G4ThreeVector vec);
static G4String ConvertToString(G4ThreeVector vec, const char* unitName);
// Static methods for conversion from value(s) to a string.
// These methods are to be used by GetCurrentValues() methods
// of concrete messengers
private:
void G4UIcommandCommonConstructorCode (const char * theCommandPath);
G4UImessenger *messenger;
G4String commandPath;
G4String commandName;
G4String rangeString;
std::vector<G4UIparameter*> parameter;
std::vector<G4String> commandGuidance;
std::vector<G4ApplicationState> availabelStateList;
static G4bool ConvertToBool(const char* st);
static G4int ConvertToInt(const char* st);
static G4long ConvertToLongInt(const char* st);
static G4double ConvertToDouble(const char* st);
static G4double ConvertToDimensionedDouble(const char* st);
static G4ThreeVector ConvertTo3Vector(const char* st);
static G4ThreeVector ConvertToDimensioned3Vector(const char* st);
// Static methods for conversion from a string to a value of the returning
// type. These methods are to be used directly by SetNewValues() methods
// of concrete messengers, or GetNewXXXValue() of classes derived from
// this G4UIcommand class
public: // with description
inline void SetRange(const char* rs)
{ rangeString = rs; }
// Defines the range the command parameter(s) can take.
// The variable name(s) appear in the range expression must be same
static G4double ValueOf(const char* unitName);
static G4String CategoryOf(const char* unitName);
static G4String UnitsList(const char* unitCategory);
// Static methods for unit and its category
inline void SetRange(const char* rs) { rangeString = rs; }
// Defines the range the command parameter(s) can take.
// The variable name(s) appear in the range expression must be the same
// as the name(s) of the parameter(s).
// All the C++ syntax of relational operators are allowed for the
// range expression.
public:
inline const G4String & GetRange() const
{ return rangeString; };
inline size_t GetGuidanceEntries() const
{ return commandGuidance.size(); }
inline const G4String & GetGuidanceLine(G4int i) const
{ return commandGuidance[i]; }
inline const G4String & GetCommandPath() const
{ return commandPath; }
inline const G4String & GetCommandName() const
{ return commandName; }
inline size_t GetParameterEntries() const
{ return parameter.size(); }
inline G4UIparameter * GetParameter(G4int i) const
{ return parameter[i]; }
inline std::vector<G4ApplicationState>* GetStateList()
{ return &availabelStateList; }
inline G4UImessenger * GetMessenger() const
{ return messenger; }
public: // with description
inline void SetParameter(G4UIparameter *const newParameter)
{
parameter.push_back( newParameter );
newVal.resize( parameter.size() );
}
// Defines a parameter. This method is used by the derived command classes
// but the user can directly use this command when he/she defines a command
// by hem(her)self without using the derived class. For this case, the order
// of the parameters is the order of invoking this method.
inline void SetGuidance(const char * aGuidance)
{
commandGuidance.push_back( G4String( aGuidance ) );
}
// Adds a guidance line. Unlimitted number of invokation of this method is
// allowed. The given lines of guidance will appear for the help. The first
// line of the guidance will be used as the title of the command, i.e. one
// line list of the commands.
public:
inline const G4String GetTitle() const
{
if(commandGuidance.size() == 0)
{ return G4String("...Title not available..."); }
else
{ return commandGuidance[0]; }
}
// All the C++ syntax of relational operators are allowed for the
// range expression
protected:
G4bool toBeBroadcasted;
G4bool toBeFlushed;
G4bool workerThreadOnly;
inline const G4String& GetRange() const { return rangeString; }
inline std::size_t GetGuidanceEntries() const
{
return commandGuidance.size();
}
inline const G4String& GetGuidanceLine(G4int i) const
{
return commandGuidance[i];
}
inline const G4String& GetCommandPath() const { return commandPath; }
inline const G4String& GetCommandName() const { return commandName; }
inline std::size_t GetParameterEntries() const { return parameter.size(); }
inline G4UIparameter* GetParameter(G4int i) const { return parameter[i]; }
inline std::vector<G4ApplicationState>* GetStateList()
{
return &availabelStateList;
}
inline G4UImessenger* GetMessenger() const { return messenger; }
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; }
inline void SetParameter(G4UIparameter* const newParameter)
// Defines a parameter. This method is used by the derived command
// classes but the user can directly use this command when defining
// a command, without using the derived class. For this case, the order
// of the parameters is the order of invoking this method
{
parameter.push_back(newParameter);
newVal.resize(parameter.size());
}
protected:
G4int commandFailureCode;
G4String failureDescription;
inline void SetGuidance(const char* aGuidance)
// Adds a guidance line. Unlimited times of invokation of this method is
// allowed. The given lines of guidance will appear for the help.
// The first line of the guidance will be used as the title of the
// command, i.e. one line list of the commands
{
commandGuidance.push_back(G4String(aGuidance));
}
public:
inline void CommandFailed( G4int errCode, G4ExceptionDescription& ed )
{ commandFailureCode = errCode; failureDescription = ed.str(); }
inline void CommandFailed( G4ExceptionDescription& ed )
{ commandFailureCode = 1; failureDescription = ed.str(); }
inline G4int IfCommandFailed()
{ return commandFailureCode; }
inline G4String& GetFailureDescription()
{ return failureDescription; }
inline const G4String GetTitle() const
{
return (commandGuidance.size() == 0)
? G4String("...Title not available...")
: commandGuidance[0];
}
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; }
inline void CommandFailed(G4int errCode, G4ExceptionDescription& ed)
{
commandFailureCode = errCode;
failureDescription = ed.str();
}
inline void CommandFailed(G4ExceptionDescription& ed)
{
commandFailureCode = 1;
failureDescription = ed.str();
}
inline G4int IfCommandFailed() { return commandFailureCode; }
inline const G4String& GetFailureDescription() {return failureDescription;}
inline void ResetFailure()
{ commandFailureCode = 0; failureDescription = ""; }
{
commandFailureCode = 0;
failureDescription = "";
}
protected:
G4int CheckNewValue(const char* newValue);
// --- the following is used by CheckNewValue() --------
protected:
using yystype = G4UItokenNum::yystype;
using yystype = G4UItokenNum::yystype;
using tokenNum = G4UItokenNum::tokenNum;
G4int CheckNewValue(const char* newValue);
G4bool toBeBroadcasted = false;
G4bool toBeFlushed = false;
G4bool workerThreadOnly = false;
G4int commandFailureCode = 0;
G4String failureDescription = "";
private:
void G4UIcommandCommonConstructorCode(const char* theCommandPath);
G4int TypeCheck(const char* t);
G4int RangeCheck(const char* t);
G4int IsInt(const char* str, short maxLength);
G4int IsInt(const char* str, short maxLength); // used for both int and long int
G4int IsDouble(const char* str);
G4int ExpectExponent(const char* str);
// syntax nodes
yystype Expression( void );
yystype LogicalORExpression( void );
yystype LogicalANDExpression( void );
yystype EqualityExpression ( void );
yystype RelationalExpression( void );
yystype AdditiveExpression( void );
yystype MultiplicativeExpression( void );
yystype UnaryExpression( void );
yystype PrimaryExpression( void );
yystype Expression(void);
yystype LogicalORExpression(void);
yystype LogicalANDExpression(void);
yystype EqualityExpression(void);
yystype RelationalExpression(void);
yystype AdditiveExpression(void);
yystype MultiplicativeExpression(void);
yystype UnaryExpression(void);
yystype PrimaryExpression(void);
// semantics routines
G4int Eval2( yystype arg1, G4int op, yystype arg2 );
G4int CompareInt( G4int arg1, G4int op, G4int arg2);
G4int CompareDouble( G4double arg1, G4int op, G4double arg2);
G4int Eval2(yystype arg1, G4int op, yystype arg2);
G4int CompareInt(G4int arg1, G4int op, G4int arg2);
G4int CompareLong(G4long arg1, G4int op, G4long arg2);
G4int CompareDouble(G4double arg1, G4int op, G4double arg2);
// utility
tokenNum Yylex( void ); // returns next token
unsigned IndexOf( const char* ); // returns the index of the var name
unsigned IsParameter( const char* ); // returns 1 or 0
G4int G4UIpGetc( void ); // read one char from rangeBuf
G4int G4UIpUngetc( G4int c ); // put back
G4int Backslash( G4int c );
G4int Follow( G4int expect, G4int ifyes, G4int ifno );
G4String TokenToStr(G4int token);
void PrintToken(void); // for debug
// data
tokenNum Yylex(void); // returns next token
unsigned IndexOf(const char*); // returns the index of the var name
unsigned IsParameter(const char*); // returns 1 or 0
G4int G4UIpGetc(void); // read one char from rangeBuf
G4int G4UIpUngetc(G4int c); // put back
G4int Backslash(G4int c);
G4int Follow(G4int expect, G4int ifyes, G4int ifno);
//G4String TokenToStr(G4int token);
//void PrintToken(void); // for debug
// Data -----------------------------------------------------------
G4UImessenger* messenger = nullptr;
G4String commandPath;
G4String commandName;
G4String rangeString;
std::vector<G4UIparameter*> parameter;
std::vector<G4String> commandGuidance;
std::vector<G4ApplicationState> availabelStateList;
G4String rangeBuf;
G4int bp; // buffer pointer for rangeBuf
tokenNum token;
G4int bp = 0; // buffer pointer for rangeBuf
tokenNum token = G4UItokenNum::IDENTIFIER;
yystype yylval;
std::vector<yystype> newVal;
G4int paramERR;
std::vector<yystype> newVal;
G4int paramERR = 0;
};
#endif
@@ -23,15 +23,20 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4UIcommandStatus
//
// Description:
//
// Enumeration of all states associated to a UI command
#ifndef G4UIcommandStatus_h
#define G4UIcommandStatus_h 1
// Author: Makoto Asai (SLAC), 1998
// --------------------------------------------------------------------
#ifndef G4UIcommandStatus_hh
#define G4UIcommandStatus_hh 1
enum G4UIcommandStatus
{
fCommandSucceeded = 0,
fCommandSucceeded = 0,
fCommandNotFound = 100,
fIllegalApplicationState = 200,
fParameterOutOfRange = 300,
+53 -68
View File
@@ -23,89 +23,74 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4UIcommandTree
//
// Class description:
//
// This class is exclusively used by G4UImanager for handling the
// tree structure of the commands. The user MUST NOT construct/use
// this class object
#ifndef G4UIcommandTree_h
#define G4UIcommandTree_h 1
// Author: Makoto Asai (SLAC), 1998
// --------------------------------------------------------------------
#ifndef G4UIcommandTree_hh
#define G4UIcommandTree_hh 1
#include "G4UIcommand.hh"
#include "globals.hh"
#include <vector>
// class description:
//
// This class is exclusively used by G4UImanager for handling the
// tree structure of the commands. The user MUST NOT construct/use
// this class object.
#include "globals.hh"
#include "G4UIcommand.hh"
class G4UIcommandTree
class G4UIcommandTree
{
public:
G4UIcommandTree();
G4UIcommandTree(const char * thePathName);
~G4UIcommandTree();
G4bool operator==(const G4UIcommandTree &right) const;
G4bool operator!=(const G4UIcommandTree &right) const;
public:
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);
G4String GetFirstMatchedString(const G4String&,const G4String&) const;
// Complete most available caracters in common into command path in the command line
// given
G4UIcommandTree();
G4UIcommandTree(const char* thePathName);
void List() const;
void ListCurrent() const;
void ListCurrentWithNum() const;
void CreateHTML();
~G4UIcommandTree();
G4bool operator==(const G4UIcommandTree& right) const;
G4bool operator!=(const G4UIcommandTree& right) const;
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 GetFirstMatchedString(const G4String&, const G4String&) const;
G4String CompleteCommandPath(const G4String& commandPath);
// Complete most available characters in common into command path in the
// command line given
void List() const;
void ListCurrent() const;
void ListCurrentWithNum() const;
void CreateHTML();
inline const G4UIcommand* GetGuidance() const { return guidance; }
inline const G4String& GetPathName() const { return pathName; }
inline G4int GetTreeEntry() const { return G4int(tree.size()); }
inline G4int GetCommandEntry() const { return G4int(command.size()); }
inline G4UIcommandTree* GetTree(G4int i) { return tree[i - 1]; }
G4UIcommandTree* GetTree(const char* comNameC);
inline G4UIcommand* GetCommand(G4int i) { return command[i - 1]; }
inline const G4String GetTitle() const
{
return (guidance == nullptr) ? G4String("...Title not available...")
: guidance->GetTitle();
}
private:
G4String CreateFileName(const char* pName);
G4String ModStr(const char* strS);
std::vector<G4UIcommand*> command;
std::vector<G4UIcommandTree*> tree;
G4UIcommand *guidance;
G4String pathName;
G4bool broadcastCommands;
public:
inline const G4UIcommand * GetGuidance() const
{ return guidance; };
inline const G4String GetPathName() const
{ return pathName; };
inline G4int GetTreeEntry() const
{ return G4int(tree.size()); };
inline G4int GetCommandEntry() const
{ return G4int(command.size()); };
inline G4UIcommandTree * GetTree(G4int i)
{ return tree[i-1]; };
inline G4UIcommandTree * GetTree(const char* comNameC)
{
G4String comName = comNameC;
for( size_t i=0; i < tree.size(); i++)
{
if( comName == tree[i]->GetPathName() )
{ return tree[i]; }
}
return NULL;
};
inline G4UIcommand * GetCommand(G4int i)
{ return command[i-1]; };
inline const G4String GetTitle() const
{
if(guidance==NULL)
{ return G4String("...Title not available..."); }
else
{ return guidance->GetTitle(); }
};
G4String CreateFileName(const char* pName);
G4String ModStr(const char* strS);
std::vector<G4UIcommand*> command;
std::vector<G4UIcommandTree*> tree;
G4UIcommand* guidance = nullptr;
G4String pathName;
G4bool broadcastCommands = true;
};
#endif
@@ -23,26 +23,14 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4UIcontrolMessenger
//
// Class description:
//
#ifndef G4UIcontrolMessenger_h
#define G4UIcontrolMessenger_h 1
#include "G4UImessenger.hh"
class G4UIdirectory;
class G4UIcmdWithAString;
class G4UIcmdWithABool;
class G4UIcmdWithAnInteger;
class G4UIcmdWithoutParameter;
class G4UIcommand;
// class description:
// This class is a concrete class of G4UImessenger which defines
// This class is a concrete class of G4UImessenger which defines
// commands affecting to the G4UImanager. Commands defined by
// this messenger are
// /control/
// this messenger are:
// /control/
// /control/macroPath
// /control/execute
// /control/loop
@@ -75,49 +63,64 @@ class G4UIcommand;
// /control/doifBatch
// /control/doifInteractive
class G4UIcontrolMessenger : public G4UImessenger
// Author: Makoto Asai, SLAC - 2001
// --------------------------------------------------------------------
#ifndef G4UIcontrolMessenger_hh
#define G4UIcontrolMessenger_hh 1
#include "G4UImessenger.hh"
class G4UIdirectory;
class G4UIcmdWithAString;
class G4UIcmdWithABool;
class G4UIcmdWithAnInteger;
class G4UIcmdWithoutParameter;
class G4UIcommand;
class G4UIcontrolMessenger : public G4UImessenger
{
public:
G4UIcontrolMessenger();
~G4UIcontrolMessenger();
void SetNewValue(G4UIcommand * command,G4String newValue);
G4String GetCurrentValue(G4UIcommand * command);
G4UIcontrolMessenger();
~G4UIcontrolMessenger();
void SetNewValue(G4UIcommand* command, G4String newValue);
G4String GetCurrentValue(G4UIcommand* command);
private:
G4UIdirectory * controlDirectory;
G4UIcmdWithAString * macroPathCommand;
G4UIcmdWithAString * ExecuteCommand;
G4UIcmdWithAnInteger * suppressAbortionCommand;
G4UIcmdWithAnInteger * verboseCommand;
G4UIcmdWithABool * doublePrecCommand;
G4UIcmdWithAString * historyCommand;
G4UIcmdWithoutParameter * stopStoreHistoryCommand;
G4UIcommand * aliasCommand;
G4UIcmdWithAString * unaliasCommand;
G4UIcmdWithoutParameter * listAliasCommand;
G4UIcmdWithAString * getEnvCmd;
G4UIcommand * getValCmd;
G4UIcmdWithAString * echoCmd;
G4UIcmdWithAString * shellCommand;
G4UIcommand * loopCommand;
G4UIcommand * foreachCommand;
G4UIcmdWithAString * ManualCommand;
G4UIcmdWithAString * HTMLCommand;
G4UIcmdWithAnInteger * maxStoredHistCommand;
G4UIcommand * ifCommand;
G4UIcommand * doifCommand;
G4UIcommand * addCommand;
G4UIcommand * subtractCommand;
G4UIcommand * multiplyCommand;
G4UIcommand * divideCommand;
G4UIcommand * remainderCommand;
G4UIcommand * strifCommand;
G4UIcommand * strdoifCommand;
G4UIcmdWithAString * ifBatchCommand;
G4UIcmdWithAString * ifInteractiveCommand;
G4UIcmdWithAString * doifBatchCommand;
G4UIcmdWithAString * doifInteractiveCommand;
G4UIdirectory* controlDirectory = nullptr;
G4UIcmdWithAString* macroPathCommand = nullptr;
G4UIcmdWithAString* ExecuteCommand = nullptr;
G4UIcmdWithAnInteger* suppressAbortionCommand = nullptr;
G4UIcmdWithAnInteger* verboseCommand = nullptr;
G4UIcmdWithABool* doublePrecCommand = nullptr;
G4UIcmdWithAString* historyCommand = nullptr;
G4UIcmdWithoutParameter* stopStoreHistoryCommand = nullptr;
G4UIcommand* aliasCommand = nullptr;
G4UIcmdWithAString* unaliasCommand = nullptr;
G4UIcmdWithoutParameter* listAliasCommand = nullptr;
G4UIcmdWithAString* getEnvCmd = nullptr;
G4UIcommand* getValCmd = nullptr;
G4UIcmdWithAString* echoCmd = nullptr;
G4UIcmdWithAString* shellCommand = nullptr;
G4UIcommand* loopCommand = nullptr;
G4UIcommand* foreachCommand = nullptr;
G4UIcmdWithAString* ManualCommand = nullptr;
G4UIcmdWithAString* HTMLCommand = nullptr;
G4UIcmdWithAnInteger* maxStoredHistCommand = nullptr;
G4UIcommand* ifCommand = nullptr;
G4UIcommand* doifCommand = nullptr;
G4UIcommand* addCommand = nullptr;
G4UIcommand* subtractCommand = nullptr;
G4UIcommand* multiplyCommand = nullptr;
G4UIcommand* divideCommand = nullptr;
G4UIcommand* remainderCommand = nullptr;
G4UIcommand* strifCommand = nullptr;
G4UIcommand* strdoifCommand = nullptr;
G4UIcmdWithAString* ifBatchCommand = nullptr;
G4UIcmdWithAString* ifInteractiveCommand = nullptr;
G4UIcmdWithAString* doifBatchCommand = nullptr;
G4UIcmdWithAString* doifInteractiveCommand = nullptr;
};
#endif
+16 -13
View File
@@ -23,27 +23,30 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4UIdirectory
//
// Class description:
//
//
// A concrete class of G4UIcommand. This class defines a command
// directory which can have commands.
// General information of G4UIcommand is given in G4UIcommand.hh
#ifndef G4UIdirectory_H
#define G4UIdirectory_H 1
// Author: Makoto Asai, 1998
// --------------------------------------------------------------------
#ifndef G4UIdirectory_hh
#define G4UIdirectory_hh 1
#include "G4UIcommand.hh"
// class description:
// A concrete class of G4UIcommand. This class defines a command
// directory which can have commands.
// General information of G4UIcommand is given in G4UIcommand.hh.
class G4UIdirectory : public G4UIcommand
{
public: // with description
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 "/".
public:
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 "/".
};
#endif
+213 -223
View File
@@ -23,16 +23,22 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4UImanager
//
// Class description:
//
// This is a singleton class which controls the command manipulation
// and the user interface(s)
#ifndef G4UImanager_h
#define G4UImanager_h 1
#include "globals.hh"
// Author: Makoto Asai, 1997
// --------------------------------------------------------------------
#ifndef G4UImanager_hh
#define G4UImanager_hh 1
#include <vector>
#include <fstream>
#include "globals.hh"
#include "icomsdefs.hh"
#include "G4VStateDependent.hh"
#include "G4UIcommandStatus.hh"
@@ -46,267 +52,251 @@ class G4LocalThreadCoutMessenger;
class G4UIaliasList;
class G4MTcoutDestination;
class G4UIbridge;
// class description:
//
// This is a singlton class which controls the command manipulation
// and the user interface(s). The constructor of this class MUST NOT
// invoked by the user.
//
class G4ProfilerMessenger;
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.
protected:
G4UImanager();
public:
~G4UImanager();
private:
G4UImanager(const G4UImanager &right);
const G4UImanager & operator=(const G4UImanager &right);
G4bool operator==(const G4UImanager &right) const;
G4bool operator!=(const G4UImanager &right) const;
public: // with description
G4String GetCurrentValues(const char * aCommand);
// This method returns a string which represents the current value(s)
static G4UImanager* GetUIpointer();
static G4UImanager* GetMasterUIpointer();
// A static method to get the pointer to the only existing object
// of this class
~G4UImanager();
G4UImanager(const G4UImanager&) = delete;
const G4UImanager& operator=(const G4UImanager&) = delete;
G4bool operator==(const G4UImanager&) const = delete;
G4bool operator!=(const G4UImanager&) const = delete;
G4String GetCurrentValues(const char* aCommand);
// This method returns a string which represents the current value(s)
// of the parameter(s) of the specified command. Null string will be
// returned if the given command is not defined or the command does
// not support the GetCurrentValues() method.
void AddNewCommand(G4UIcommand * newCommand);
// This method register a new command.
void RemoveCommand(G4UIcommand * aCommand);
// This command remove the registered command. After invokation of this
// command, that particular command cannot be applied.
void ExecuteMacroFile(const char * fileName);
// A macro file defined by the argument will be read by G4UIbatch object.
void Loop(const char * macroFile,const char * variableName,
G4double initialValue,G4double finalValue,G4double stepSize=1.0);
// Execute a macro file more than once with a loop counter.
void Foreach(const char * macroFile,const char * variableName,
const char * candidates);
// Execute a macro file more than once with an aliased variable which takes
// a value in the candidate list.
G4int ApplyCommand(const char * aCommand);
G4int ApplyCommand(const G4String& aCommand);
// A command (and parameter(s)) given
// not support the GetCurrentValues() method
void AddNewCommand(G4UIcommand* newCommand);
// This method register a new command
void RemoveCommand(G4UIcommand* aCommand);
// This command removes the registered command. After invokation of this
// command, that particular command cannot be applied
void ExecuteMacroFile(const char* fileName);
// A macro file defined by the argument will be read by G4UIbatch object
void Loop(const char* macroFile, const char* variableName,
G4double initialValue, G4double finalValue,
G4double stepSize = 1.0);
// Execute a macro file more than once with a loop counter
void Foreach(const char* macroFile, const char* variableName,
const char* candidates);
// Execute a macro file more than once with an aliased variable which
// takes a value in the candidate list
G4int ApplyCommand(const char* aCommand);
G4int ApplyCommand(const G4String& aCommand);
// A command (and parameter(s)) given
// by the method's argument will be applied. Zero will be returned in
// case the command is successfully executed. Positive non-zero value
// will be returned if the command couldn't be executed. The meaning of
// this non-zero value is the following.
// will be returned if the command cannot be executed. The meaning of
// this non-zero value is the following:
// The returned number : xyy
// x00 : G4CommandStatus.hh enumeration
// yy : the problematic parameter (first found)
void StoreHistory(const char* fileName = "G4history.macro");
void StoreHistory(G4bool historySwitch,
const char* fileName = "G4history.macro");
// The executed commands will be stored in the defined file. If
// "historySwitch" is false, saving will be suspended.
void ListCommands(const char* direc);
// All commands registored under the given directory will be listed to
// G4cout.
void SetAlias(const char * aliasLine);
// Define an alias. The first word of "aliasLine" string is the
void StoreHistory(const char* fileName = "G4history.macro");
void StoreHistory(G4bool historySwitch,
const char* fileName = "G4history.macro");
// The executed commands will be stored in the defined file. If
// "historySwitch" is false, saving will be suspended
void ListCommands(const char* direc);
// All commands registered under the given directory will be listed to
// standard output
void SetAlias(const char* aliasLine);
// Define an alias. The first word of "aliasLine" string is the
// alias name and the remaining word(s) is(are) string value
// to be aliased.
void RemoveAlias(const char * aliasName);
// Remove the defined alias.
void ListAlias();
// Print all aliases.
G4String SolveAlias(const char* aCmd);
// Convert a command string which contains alias(es).
void CreateHTML(const char* dir = "/");
// Generate HTML files for defined UI commands
// to be aliased
private:
void AddWorkerCommand(G4UIcommand * newCommand);
void RemoveWorkerCommand(G4UIcommand * aCommand);
void RemoveAlias(const char* aliasName);
// Remove the defined alias
public:
void LoopS(const char* valueList);
void ForeachS(const char* valueList);
// These methods are used by G4UIcontrolMessenger to use Loop() and Foreach() methods.
virtual G4bool Notify(G4ApplicationState requestedState);
// This method is exclusively invoked by G4StateManager and the user
// must not use this method.
void ListAlias();
// Print all aliases
private:
void PauseSession(const char* msg);
void CreateMessenger();
G4UIcommandTree* FindDirectory(const char* dirName);
G4String SolveAlias(const char* aCmd);
// Convert a command string which contains alias(es)
//public:
// following three methods will be removed quite soon.
// void Interact();
// void Interact(const char * promptCharacters);
void CreateHTML(const char* dir = "/");
// Generate HTML files for defined UI commands
private:
G4ICOMS_DLL static G4UImanager*& fUImanager(); // thread-local
G4ICOMS_DLL static G4bool& fUImanagerHasBeenKilled(); // thread-local
G4ICOMS_DLL static G4UImanager*& fMasterUImanager();
G4UIcommandTree * treeTop;
G4UIsession * session;
G4UIsession * g4UIWindow;
G4UIcontrolMessenger * UImessenger;
G4UnitsMessenger * UnitsMessenger;
G4LocalThreadCoutMessenger * CoutMessenger;
G4String savedParameters;
G4UIcommand * savedCommand;
G4int verboseLevel;
std::ofstream historyFile;
G4bool saveHistory;
std::vector<G4String> histVec;
G4UIaliasList* aliasList;
G4int maxHistSize;
G4bool pauseAtBeginOfEvent;
G4bool pauseAtEndOfEvent;
G4String searchPath;
std::vector<G4String> searchDirs;
void LoopS(const char* valueList);
void ForeachS(const char* valueList);
// These methods are used by G4UIcontrolMessenger to use Loop()
// and Foreach() methods
public: // with description
G4String GetCurrentStringValue(const char * aCommand,
G4int parameterNumber=1, G4bool reGet=true);
G4int GetCurrentIntValue(const char * aCommand,
G4int parameterNumber=1, G4bool reGet=true);
G4double GetCurrentDoubleValue(const char * aCommand,
G4int parameterNumber=1, G4bool reGet=true);
G4String GetCurrentStringValue(const char * aCommand,
const char * aParameterName, G4bool reGet=true);
G4int GetCurrentIntValue(const char * aCommand,
const char * aParameterName, G4bool reGet=true);
G4double GetCurrentDoubleValue(const char * aCommand,
const char * aParameterName, G4bool reGet=true);
// These six methods returns the current value of a parameter of the
virtual G4bool Notify(G4ApplicationState requestedState);
// This method is exclusively invoked by G4StateManager
G4String GetCurrentStringValue(const char* aCommand,
G4int parameterNumber = 1,
G4bool reGet = true);
G4int GetCurrentIntValue(const char* aCommand, G4int parameterNumber = 1,
G4bool reGet = true);
G4double GetCurrentDoubleValue(const char* aCommand,
G4int parameterNumber = 1,
G4bool reGet = true);
G4String GetCurrentStringValue(const char* aCommand,
const char* aParameterName,
G4bool reGet = true);
G4int GetCurrentIntValue(const char* aCommand, const char* aParameterName,
G4bool reGet = true);
G4double GetCurrentDoubleValue(const char* aCommand,
const char* aParameterName,
G4bool reGet = true);
// These six methods return the current value of a parameter of the
// given command. For the first three methods, the ordering number of
// the parameter (1 is the first parameter) can be given, whereas,
// other three methods can give the parameter name.
// If "reGet" is true, actual request of returning the current value
// If "reGet" is true, actual request of returning the current value
// will be sent to the corresponding messenger, while, if it is false,
// the value stored in G4Umanager will be used. The later case is valid
// for the sequential invokation for the same command.
// for the sequential invokation for the same command
inline void SetPauseAtBeginOfEvent(G4bool vl)
{ pauseAtBeginOfEvent = vl; }
inline G4bool GetPauseAtBeginOfEvent() const
{ return pauseAtBeginOfEvent; }
inline void SetPauseAtEndOfEvent(G4bool vl)
{ pauseAtEndOfEvent = vl; }
inline G4bool GetPauseAtEndOfEvent() const
{ return pauseAtEndOfEvent; }
// If the boolean flags are true, Pause() method of G4StateManager is invoked
// at the very begining (before generating a G4Event object) or at the end of
// each event. So that, in case a (G)UI session is defined, the user can interact.
inline void SetPauseAtBeginOfEvent(G4bool vl) { pauseAtBeginOfEvent = vl; }
inline G4bool GetPauseAtBeginOfEvent() const { return pauseAtBeginOfEvent; }
inline void SetPauseAtEndOfEvent(G4bool vl) { pauseAtEndOfEvent = vl; }
inline G4bool GetPauseAtEndOfEvent() const { return pauseAtEndOfEvent; }
// If the Boolean flags are true, Pause() method of G4StateManager is
// invoked at the very beginning (before generating a G4Event object)
// or at the end of each event. So that, in case a (G)UI session is
// defined, the user can interact
inline G4UIcommandTree* GetTree() const { return treeTop; }
inline G4UIsession* GetSession() const { return session; }
inline G4UIsession* GetG4UIWindow() const { return g4UIWindow; }
public:
inline G4UIcommandTree * GetTree() const
{ return treeTop; }
inline G4UIsession * GetSession() const
{ return session; }
inline G4UIsession * GetG4UIWindow() const
{ return g4UIWindow; }
public: // with description
inline void SetSession(G4UIsession *const value)
{ session = value; }
inline void SetG4UIWindow(G4UIsession *const value)
{ g4UIWindow = value; }
// This method defines the active (G)UI session.
void SetCoutDestination(G4UIsession *const value);
// This method defines the destination of G4cout/G4cerr stream.
// For usual cases, this method will be invoked by a concrete
// (G)UI session class object and thus the user needs not to invoke
// this method by him(her)self.
inline void SetSession(G4UIsession* const value) { session = value; }
inline void SetG4UIWindow(G4UIsession* const value) { g4UIWindow = value; }
// These methods define the active (G)UI session
public:
inline void SetVerboseLevel(G4int val)
{ verboseLevel = val; }
inline G4int GetVerboseLevel() const
{ return verboseLevel; }
inline G4int GetNumberOfHistory() const
{ return G4int(histVec.size()); }
inline G4String GetPreviousCommand(G4int i) const
void SetCoutDestination(G4UIsession* const value);
// This method defines the destination of G4cout/G4cerr stream.
// For usual cases, this method will be invoked by a concrete
// (G)UI session class object and thus the user needs not to invoke this
inline void SetVerboseLevel(G4int val) { verboseLevel = val; }
inline G4int GetVerboseLevel() const { return verboseLevel; }
inline G4int GetNumberOfHistory() const { return G4int(histVec.size()); }
inline G4String GetPreviousCommand(G4int i) const
{
G4String st;
if(i >= 0 && i < G4int(histVec.size()))
{
G4String st;
if(i>=0 && i<G4int(histVec.size()))
{ st = histVec[i]; }
return st;
st = histVec[i];
}
inline void SetMaxHistSize(G4int mx)
{ maxHistSize = mx; }
inline G4int GetMaxHistSize() const
{ return maxHistSize; }
return st;
}
inline void SetMaxHistSize(G4int mx) { maxHistSize = mx; }
inline G4int GetMaxHistSize() const { return maxHistSize; }
inline void SetMacroSearchPath(const G4String& path)
{ searchPath = path; }
inline const G4String& GetMacroSearchPath() const
{ return searchPath; }
void ParseMacroSearchPath();
G4String FindMacroPath(const G4String& fname) const;
inline void SetMacroSearchPath(const G4String& path) { searchPath = path; }
inline const G4String& GetMacroSearchPath() const { return searchPath; }
void ParseMacroSearchPath();
G4String FindMacroPath(const G4String& fname) const;
private:
G4bool isMaster;
std::vector<G4UIbridge*>* bridges;
G4bool ignoreCmdNotFound;
G4bool stackCommandsForBroadcast;
std::vector<G4String>* commandStack;
public:
inline void SetMasterUIManager(G4bool val)
inline void SetMasterUIManager(G4bool val)
{
isMaster = val;
stackCommandsForBroadcast = val;
if(val && !bridges)
{
isMaster = val;
//ignoreCmdNotFound = val;
stackCommandsForBroadcast = val;
if(val&&!bridges)
{
bridges = new std::vector<G4UIbridge*>;
fMasterUImanager() = this;
}
bridges = new std::vector<G4UIbridge*>;
fMasterUImanager() = this;
}
inline void SetIgnoreCmdNotFound(G4bool val)
{ ignoreCmdNotFound = val; }
}
inline void SetIgnoreCmdNotFound(G4bool val) { ignoreCmdNotFound = val; }
std::vector<G4String>* GetCommandStack();
void RegisterBridge(G4UIbridge* brg);
std::vector<G4String>* GetCommandStack();
void RegisterBridge(G4UIbridge* brg);
void SetUpForAThread(G4int tId);
//Setups as before but for a non-worker thread (e.g. vis)
void SetUpForSpecialThread(G4String aPrefix);
inline G4int GetThreadID() const
{ return threadID; }
void SetUpForAThread(G4int tId);
// Setups as above but for a non-worker thread (e.g. vis)
void SetUpForSpecialThread(G4String aPrefix);
inline G4int GetThreadID() const { return threadID; }
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);
void SetThreadIgnoreInit(G4bool flg = true);
inline G4MTcoutDestination* GetThreadCout() { return threadCout; }
static void UseDoublePrecisionStr(G4bool val);
static G4bool DoublePrecisionStr();
inline G4int GetLastReturnCode() const { return lastRC; }
protected:
G4UImanager();
private:
G4int threadID;
G4MTcoutDestination* threadCout;
G4ICOMS_DLL 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);
void SetThreadIgnoreInit(G4bool flg = true);
inline G4MTcoutDestination* GetThreadCout() {return threadCout;};
void AddWorkerCommand(G4UIcommand* newCommand);
void RemoveWorkerCommand(G4UIcommand* aCommand);
void PauseSession(const char* msg);
void CreateMessenger();
G4UIcommandTree* FindDirectory(const char* dirName);
private:
G4ICOMS_DLL static G4bool doublePrecisionStr;
public:
static void UseDoublePrecisionStr(G4bool val);
static G4bool DoublePrecisionStr();
private:
G4int lastRC;
public:
G4int GetLastReturnCode() const
{ return lastRC; }
G4ICOMS_DLL static G4UImanager*& fUImanager(); // thread-local
G4ICOMS_DLL static G4bool& fUImanagerHasBeenKilled(); // thread-local
G4ICOMS_DLL static G4UImanager*& fMasterUImanager();
G4UIcommandTree* treeTop = nullptr;
G4UIsession* session = nullptr;
G4UIsession* g4UIWindow = nullptr;
G4UIcontrolMessenger* UImessenger = nullptr;
G4UnitsMessenger* UnitsMessenger = nullptr;
G4LocalThreadCoutMessenger* CoutMessenger = nullptr;
G4ProfilerMessenger* ProfileMessenger = nullptr;
G4String savedParameters;
G4UIcommand* savedCommand = nullptr;
G4int verboseLevel = 0;
std::ofstream historyFile;
G4bool saveHistory = false;
std::vector<G4String> histVec;
G4UIaliasList* aliasList = nullptr;
G4int maxHistSize = 20;
G4bool pauseAtBeginOfEvent = false;
G4bool pauseAtEndOfEvent = false;
G4String searchPath = "";
std::vector<G4String> searchDirs;
G4bool isMaster = false;
std::vector<G4UIbridge*>* bridges = nullptr;
G4bool ignoreCmdNotFound = false;
G4bool stackCommandsForBroadcast = false;
std::vector<G4String>* commandStack = nullptr;
G4int threadID = -1;
G4MTcoutDestination* threadCout = nullptr;
G4ICOMS_DLL static G4int igThreadID;
G4ICOMS_DLL static G4bool doublePrecisionStr;
G4int lastRC = 0;
};
#endif
+71 -58
View File
@@ -23,89 +23,102 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4UImessenger
//
// Class description:
//
// This class is the base class representing a messenger which keeps all basic
// commands. The user who wants to define some commands must create his/her
// own concrete class derived from this class. The user's concrete messenger
// must have a responsibility of creating and deleting commands. Also, it must
// take care of the delivering of the commands to the destination class and
// provide the current value(s) of the parameter(s)
#ifndef G4UImessenger_h
#define G4UImessenger_h 1
// Author: Makoto Asai, 1998
// --------------------------------------------------------------------
#ifndef G4UImessenger_hh
#define G4UImessenger_hh 1
#include "globals.hh"
#include "G4ios.hh"
#include "G4UIdirectory.hh"
// class description:
//
// This class is the base class which represents a messenger which maintains
// the commands. The user who wants to define some commands must create his/her
// own concrete class derived from this class. The user's concrete messenger
// must have a responsibility of creating and deleting commands. Also, it must
// take care the delivering of the command to the destination class and replying
// the current value(s) of the parameter(s).
//
class G4UImessenger
class G4UImessenger
{
public: // with description
G4UImessenger();
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();
// Destructor. In the implementation of the concrete messenger, all commands
// defined in the constructor must be deleted.
virtual G4String GetCurrentValue(G4UIcommand * command);
// The concrete implementation of this method gets the current value(s) of the
// parameter(s) of the given command from the destination class, converts the
// value(s) to a string, and returns the string. Conversion could be done by
// the ConvertToString() method of corresponding G4UIcmdXXX classes if the
// the command is an object of these G4UIcmdXXX classes.
virtual void SetNewValue(G4UIcommand * command,G4String newValue);
// The concrete implementation of this method converts the string "newValue"
// to value(s) of type(s) of the parameter(s). Convert methods corresponding
// to the type of the command can be used if the command is an object of
// G4UIcmdXXX classes.
public:
G4bool operator == (const G4UImessenger& messenger) const;
G4UImessenger();
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();
// Destructor. In the implementation of the concrete messenger,
// all commands defined in the constructor must be deleted
virtual G4String GetCurrentValue(G4UIcommand* command);
// The concrete implementation of this method gets the current value(s)
// of the parameter(s) of the given command from the destination class,
// converts the value(s) to a string, and returns the string.
// Conversion could be done by the ConvertToString() method of
// corresponding G4UIcmdXXX classes if the command is an object of
// these G4UIcmdXXX classes
virtual void SetNewValue(G4UIcommand* command, G4String newValue);
// The concrete implementation of this method converts the string
// "newValue" to value(s) of type(s) of the parameter(s).
// Converted methods corresponding to the type of the command can be
// used if the command is an object of G4UIcmdXXX classes
G4bool operator==(const G4UImessenger& messenger) const;
G4bool operator!=(const G4UImessenger& messenger) const;
inline G4bool CommandsShouldBeInMaster() const
{
return commandsShouldBeInMaster;
}
protected:
G4String ItoS(G4int i);
G4String DtoS(G4double a);
G4String BtoS(G4bool b);
G4int StoI(G4String s);
G4double StoD(G4String s);
G4bool StoB(G4String s);
G4String ItoS(G4int i);
G4String DtoS(G4double a);
G4String BtoS(G4bool b);
G4int StoI(G4String s);
G4long StoL(G4String s);
G4double StoD(G4String s);
G4bool StoB(G4String s);
void AddUIcommand(G4UIcommand* newCommand);
void CreateDirectory(const G4String& path, const G4String& dsc,
G4bool commandsToBeBroadcasted = true);
template <typename T>
T* CreateCommand(const G4String& cname, const G4String& dsc);
// Shortcut way for creating directory and commands
protected:
void AddUIcommand(G4UIcommand * newCommand);
// 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,
G4bool commandsToBeBroadcasted=true);
template <typename T> T* CreateCommand(const G4String& cname,
const G4String& dsc);
protected:
G4bool commandsShouldBeInMaster;
public:
G4bool CommandsShouldBeInMaster() const
{ return commandsShouldBeInMaster; }
G4UIdirectory* baseDir = nullptr; // used if new object is created
G4String baseDirName = ""; // used if dir already exists
G4bool commandsShouldBeInMaster = false;
};
// Inline template implementations
template <typename T>
T* G4UImessenger::CreateCommand(const G4String& cname, const G4String& dsc)
{
G4String path;
if( cname(0) != '/' ) {
if(cname(0) != '/')
{
path = baseDirName + cname;
if (path(0) != '/') path = "/" + path;
if(path(0) != '/')
path = "/" + path;
}
T* command = new T(path.c_str(), this);
command-> SetGuidance(dsc.c_str());
command->SetGuidance(dsc.c_str());
return command;
}
+133 -134
View File
@@ -23,169 +23,168 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4UIparameter
//
// Class description:
//
//
// ---------------------------------------------------------------------
// This class represents a parameter which will be taken by a G4UIcommand
// object. In case a command is defined by constructing G4UIcmdXXX class,
// it automatically creates necessary parameter objects, thus the user needs
// not to create parameter object(s). In case the user wants to create a
// command directly instantiated by G4UIcommand class, he/she must create
// a parameter object(s)
#ifndef G4UIparameter_h
#define G4UIparameter_h 1
// Author: Makoto Asai, 1997
// --------------------------------------------------------------------
#ifndef G4UIparameter_hh
#define G4UIparameter_hh 1
#include "globals.hh"
#include "G4UItokenNum.hh"
// class description:
//
// This class represents a parameter which will be taken by a G4UIcommand
// object. In case a command is defined by constructing G4UIcmdXXX class,
// it automatically creates necessary parameter objects, thus the user needs
// not to create parameter object(s) by him/herself. In case the user wants
// to create a command directly instansiated by G4UIcommand class, he/she
// must create parameter object(s) by him/herself.
class G4UIparameter
class G4UIparameter
{
public: // with description
G4UIparameter();
G4UIparameter(char theType);
G4UIparameter(const char * theName, char theType, G4bool theOmittable);
public:
G4UIparameter();
G4UIparameter(char theType);
G4UIparameter(const char* theName, char theType, G4bool theOmittable);
// Constructors, where "theName" is the name of the parameter which will
// be used by the range checking, "theType" is the type of the parameter
// (currently "b" (boolean), "i" (integer), "d" (double), and "s" (string)
// are supported), and "theOmittable" is a boolean flag to set whether
// the user of the command can ommit the parameter or not. If "theOmittable"
// is true, the default value must be given.
~G4UIparameter();
// Destructor. When a command is destructed, the delete operator(s) for
// associating parameter(s) are AUTOMATICALLY invoked. Thus the user needs
// NOT to invoke this by him/herself.
// (currently "b" (Boolean), "i" (integer), "l" (long int), "d" (double)
// and "s" (string) are supported).
// "theOmittable" is a Boolean flag to set whether
// the user of the command can omit the parameter or not.
// If "theOmittable" is true, the default value must be given
public:
G4bool operator==(const G4UIparameter &right) const;
G4bool operator!=(const G4UIparameter &right) const;
~G4UIparameter();
// Destructor. When a command is destructed, the delete operator(s) of the
// associated parameter(s) are AUTOMATICALLY invoked
G4int CheckNewValue(const char* newValue);
void List();
G4bool operator==(const G4UIparameter& right) const;
G4bool operator!=(const G4UIparameter& right) const;
private:
G4String parameterName;
G4String parameterGuidance;
G4String defaultValue;
G4String parameterRange;
G4String parameterCandidate;
char parameterType;
G4bool omittable;
G4bool currentAsDefaultFlag;
G4int widget;
G4int CheckNewValue(const char* newValue);
void List();
public: // with description
inline void SetDefaultValue(const char * theDefaultValue)
{ defaultValue = theDefaultValue; }
void SetDefaultValue(G4int theDefaultValue);
void SetDefaultValue(G4double theDefaultValue);
// These methods set the default value of the parameter.
void SetDefaultUnit(const char * theDefaultUnit);
inline void SetDefaultValue(const char* theDefaultValue)
{
defaultValue = theDefaultValue;
}
void SetDefaultValue(G4int theDefaultValue);
void SetDefaultValue(G4long theDefaultValue);
void SetDefaultValue(G4double theDefaultValue);
// These methods set the default value of the parameter
void SetDefaultUnit(const char* theDefaultUnit);
// This method can be used for a string-type parameter that is
// used to specify a unit. This method is valid only for a
// string-type parameter. With this set-method, not only the
// default unit but also candidate units that belong to the
// same unit category (a.k.a. dimension) as the default unit.
public:
inline G4String GetDefaultValue() const
{ return defaultValue; }
inline char GetParameterType() const
{ return parameterType; }
// string-type parameter
public: // with description
inline void SetParameterRange(const char * theRange)
{ parameterRange = theRange; }
// Defines the range the parameter can take.
// The variable name appear in the range expression must be same
// as the name of the parameter.
// All the C++ syntax of relational operators are allowed for the
// range expression.
public:
inline G4String GetParameterRange() const
{ return parameterRange; }
// parameterName
inline void SetParameterName(const char * theName)
{ parameterName = theName; }
inline G4String GetParameterName() const
{ return parameterName; }
public: // with description
inline void SetParameterCandidates(const char * theString)
{ parameterCandidate = theString; }
// This method is meaningful if the type of the parameter is string.
// The candidates listed in the argument must be separated by space(s).
public:
inline G4String GetParameterCandidates() const
{ return parameterCandidate; }
// omittable
inline void SetOmittable(G4bool om)
{ omittable = om; }
inline G4bool IsOmittable() const
{ return omittable; }
// currentAsDefaultFlag
inline void SetCurrentAsDefault(G4bool val)
{ currentAsDefaultFlag = val; }
inline G4bool GetCurrentAsDefault() const
{ return currentAsDefaultFlag; }
// out of date methods
inline void SetWidget(G4int theWidget)
{ widget = theWidget; }
inline const G4String GetParameterGuidance() const
{ return parameterGuidance; }
inline void SetGuidance(const char * theGuidance)
{ parameterGuidance = theGuidance; }
inline const G4String& GetDefaultValue() const { return defaultValue; }
inline char GetParameterType() const { return parameterType; }
inline void SetParameterRange(const char* theRange)
// Defines the range the parameter can take.
// The variable name appearing in the range expression must be the
// same as the name of the parameter.
// All the C++ syntax of relational operators are allowed for the
// range expression
{
parameterRange = theRange;
}
inline const G4String& GetParameterRange() const { return parameterRange; }
inline void SetParameterName(const char* pName) { parameterName = pName; }
inline const G4String& GetParameterName() const { return parameterName; }
inline void SetParameterCandidates(const char* theString)
// This method is meaningful if the type of the parameter is string.
// The candidates listed in the argument must be separated by space(s)
{
parameterCandidate = theString;
}
inline const G4String& GetParameterCandidates() const
{
return parameterCandidate;
}
inline void SetOmittable(G4bool om) { omittable = om; }
inline G4bool IsOmittable() const { return omittable; }
inline void SetCurrentAsDefault(G4bool val) { currentAsDefaultFlag = val; }
inline G4bool GetCurrentAsDefault() const { return currentAsDefaultFlag; }
// Obsolete methods
//
inline void SetWidget(G4int theWidget) { widget = theWidget; }
inline const G4String& GetParameterGuidance() const
{
return parameterGuidance;
}
inline void SetGuidance(const char* theGuidance)
{
parameterGuidance = theGuidance;
}
protected:
using yystype = G4UItokenNum::yystype;
using yystype = G4UItokenNum::yystype;
using tokenNum = G4UItokenNum::tokenNum;
private:
// --- the following is used by CheckNewValue() -------
G4int TypeCheck(const char* newValue );
G4int RangeCheck(const char* newValue );
G4int CandidateCheck(const char* newValue );
G4int IsInt(const char* str, short maxDigit);
G4int TypeCheck(const char* newValue);
G4int RangeCheck(const char* newValue);
G4int CandidateCheck(const char* newValue);
G4int IsInt(const char* str, short maxDigit); // used for both int and long int
G4int IsDouble(const char* str);
G4int ExpectExponent(const char* str);
// syntax nodes
yystype Expression( void );
yystype LogicalORExpression( void );
yystype LogicalANDExpression( void );
yystype EqualityExpression ( void );
yystype RelationalExpression( void );
yystype AdditiveExpression( void );
yystype MultiplicativeExpression( void );
yystype UnaryExpression( void );
yystype PrimaryExpression( void );
yystype Expression(void);
yystype LogicalORExpression(void);
yystype LogicalANDExpression(void);
yystype EqualityExpression(void);
yystype RelationalExpression(void);
yystype AdditiveExpression(void);
yystype MultiplicativeExpression(void);
yystype UnaryExpression(void);
yystype PrimaryExpression(void);
// semantics routines
G4int Eval2( yystype arg1, G4int op, yystype arg2 );
G4int CompareInt( G4int arg1, G4int op, G4int arg2);
G4int CompareDouble( double arg1, G4int op, double arg2);
// utility
tokenNum Yylex( void ); // returns next token
G4int G4UIpGetc( void ); // read one char from rangeBuf
G4int G4UIpUngetc( G4int c ); // put back
G4int Backslash( G4int c );
G4int Follow( G4int expect, G4int ifyes, G4int ifno );
G4String TokenToStr(G4int token);
//void PrintToken(void); // debug
// data
G4int Eval2(yystype arg1, G4int op, yystype arg2);
G4int CompareInt(G4int arg1, G4int op, G4int arg2);
G4int CompareLong(G4long arg1, G4int op, G4long arg2);
G4int CompareDouble(double arg1, G4int op, double arg2);
// utility
tokenNum Yylex(void); // returns next token
G4int G4UIpGetc(void); // read one char from rangeBuf
G4int G4UIpUngetc(G4int c); // put back
G4int Backslash(G4int c);
G4int Follow(G4int expect, G4int ifyes, G4int ifno);
//G4String TokenToStr(G4int token);
// data -----------------------------------------------------------
G4String parameterName;
G4String parameterGuidance;
G4String defaultValue;
G4String parameterRange;
G4String parameterCandidate;
char parameterType = '\0';
G4bool omittable = false;
G4bool currentAsDefaultFlag = false;
G4int widget = 0;
//------------ CheckNewValue() related data members ---------------
G4String rangeBuf;
G4int bp; // buffer pointer for rangeBuf
tokenNum token;
G4int bp = 0; // buffer pointer for rangeBuf
tokenNum token = G4UItokenNum::NONE;
yystype yylval;
yystype newVal;
G4int paramERR;
//------------ end of CheckNewValue() related member --------------
G4int paramERR = 0;
};
#endif
+28 -32
View File
@@ -23,54 +23,50 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4UIsession
//
// Class description:
//
// $id$
// This is a base class of all (G)UI sessions.
// SessionStart() method should be called to start the session
#ifndef G4UIsession_h
#define G4UIsession_h 1
// Author: Makoto Asai, 1998
// --------------------------------------------------------------------
#ifndef G4UIsession_hh
#define G4UIsession_hh 1
#include "G4coutDestination.hh"
#include "globals.hh"
#include "icomsdefs.hh"
// class description:
//
// This is a base class of all (G)UI session.
// SessionStart() method should be called to start the session.
//
class G4UIsession : public G4coutDestination
{
// Base class of UI/GUI session
public:
G4UIsession();
G4UIsession(G4int iBatch);
virtual ~G4UIsession();
virtual G4UIsession * SessionStart();
G4UIsession();
G4UIsession(G4int iBatch);
virtual ~G4UIsession();
virtual G4UIsession* SessionStart();
// This method will be invoked by main().
// Optionally, it can be invoked by another session.
virtual void PauseSessionStart(const G4String& Prompt);
// Optionally, it can be invoked by another session
virtual void PauseSessionStart(const G4String& Prompt);
// This method will be invoked by G4UImanager
// when G4kernel becomes to Pause state.
virtual G4int ReceiveG4cout(const G4String& coutString);
virtual G4int ReceiveG4cerr(const G4String& cerrString);
// These two methods will be invoked by G4strstreambuf.
// when the kernel comes to Pause state
virtual G4int ReceiveG4cout(const G4String& coutString);
virtual G4int ReceiveG4cerr(const G4String& cerrString);
// These two methods will be invoked by G4strstreambuf
static G4int InSession();
inline G4int GetLastReturnCode() const { return lastRC; }
protected:
G4ICOMS_DLL static G4int inSession;
G4int ifBatch;
G4int lastRC;
public:
static G4int InSession() { return inSession; }
G4int GetLastReturnCode() const { return lastRC; }
G4ICOMS_DLL static G4int inSession;
G4int ifBatch = 0;
G4int lastRC = 0;
};
#endif
+54 -42
View File
@@ -23,68 +23,80 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4UItokenNum
//
// Description:
//
// G4UItokenNum.hh
// Namespace with enumerator of tokens
// Author: Makoto Asai, 1998
// --------------------------------------------------------------------
#ifndef G4UItokenNum_hh
#define G4UItokenNum_hh 1
#include "globals.hh"
namespace G4UItokenNum
{
enum tokenNum
{
NONE = 0,
IDENTIFIER = 257,
CONSTINT = 258,
CONSTDOUBLE= 259,
CONSTCHAR = 260,
CONSTSTRING= 261,
GT = 262,
GE = 263,
LT = 264,
LE = 265,
EQ = 266,
NE = 267,
//LOGICALNOT = 268,
LOGICALOR = 269,
LOGICALAND = 270,
SCAREAMER = 33,
LPAREN = 40,
PLUS = 43,
MINUS = 45
};
enum tokenNum
{
NONE = 0,
IDENTIFIER = 257,
CONSTINT = 258,
CONSTDOUBLE = 259,
CONSTCHAR = 260,
CONSTSTRING = 261,
GT = 262,
GE = 263,
LT = 264,
LE = 265,
EQ = 266,
NE = 267,
// LOGICALNOT = 268,
CONSTLONG = 268,
LOGICALOR = 269,
LOGICALAND = 270,
SCAREAMER = 33,
LPAREN = 40,
PLUS = 43,
MINUS = 45
};
typedef struct yystype
{
typedef struct yystype
{
tokenNum type;
G4double D;
G4int I;
char C;
G4int I;
G4long L;
char C;
G4String S;
yystype() : type(tokenNum::NONE), D(0.0), I(0), C(' '), S("")
{
}
yystype()
: type(tokenNum::NONE)
, D(0.0)
, I(0)
, L(0)
, C(' ')
, S("")
{}
G4bool operator==(const yystype& right) const
{
return (this == &right)?1:0;
return (this == &right) ? 1 : 0;
}
yystype& operator=(const yystype& right)
{
if (&right==this) return *this;
if(&right == this)
return *this;
type = right.type;
D = right.D;
I = right.I;
C = right.C;
S = right.S;
D = right.D;
I = right.I;
L = right.L;
C = right.C;
S = right.S;
return *this;
}
yystype(const yystype& right)
{
*this=right;
}
} yystype;
}
yystype(const yystype& right) { *this = right; }
} yystype;
} // namespace G4UItokenNum
#endif
+17 -20
View File
@@ -23,19 +23,17 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4UnitsMessenger
//
// Class description
//
// class description
//
// This class is the messenger of the class which maintain the table of Units.
// (located in global/management/include/G4UnitsTable.hh)
// Its contains the commands to interact with the table of Units
// This class is the messenger for the table of units G4UnitsTable.
// It contains the commands to interact with the table of Units
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
#ifndef G4UnitsMessenger_h
#define G4UnitsMessenger_h 1
// Author: Michel Maire, 1998
// --------------------------------------------------------------------
#ifndef G4UnitsMessenger_hh
#define G4UnitsMessenger_hh 1
#include "globals.hh"
#include "G4UImessenger.hh"
@@ -43,20 +41,19 @@
class G4UIdirectory;
class G4UIcmdWithoutParameter;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
class G4UnitsMessenger: public G4UImessenger
class G4UnitsMessenger : public G4UImessenger
{
public:
G4UnitsMessenger();
~G4UnitsMessenger();
~G4UnitsMessenger();
void SetNewValue(G4UIcommand*, G4String);
private:
G4UIdirectory* UnitsTableDir;
G4UIcmdWithoutParameter* ListCmd;
private:
G4UIdirectory* UnitsTableDir = nullptr;
G4UIcmdWithoutParameter* ListCmd = nullptr;
};
#endif
@@ -23,27 +23,27 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4VFlavoredParallelWorld
//
// Class description:
//
//
// Abstract interface for GEANT4 Flavored Parallel World.
// P. Mora de Freitas & M. Verderi 14/April/1999.
//
// Abstract interface for Flavored Parallel World.
// Authors: P. Mora de Freitas & M. Verderi, 14 April 1999
// --------------------------------------------------------------------
#ifndef G4VFLAVOREDPARALLELWORLD_HH
#define G4VFLAVOREDPARALLELWORLD_HH
#define G4VFLAVOREDPARALLELWORLD_HH 1
class G4VPhysicalVolume;
class G4VFlavoredParallelWorld {
class G4VFlavoredParallelWorld
{
public:
public:
virtual ~G4VFlavoredParallelWorld() {}
virtual ~G4VFlavoredParallelWorld () {}
// G4VFlavoredParallelWorld Interface for visualisation.
virtual
G4VPhysicalVolume* GetThePhysicalVolumeWorld() const =0;
virtual G4VPhysicalVolume* GetThePhysicalVolumeWorld() const = 0;
// Interface for visualisation
};
#endif
@@ -23,36 +23,31 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//
// Abstract interface for GEANT4 Global Fast Simulation Manager.
// P. Mora de Freitas & M. Verderi 14/April/1999.
// G4VGlobalFastSimulationManager
//
// Class description:
//
// G4GlobalFastSimulationManager is a "Singleton", i.e., only one instance
// of it may exist. This is ensured by making the constructor private.
// Abstract interface for Global Fast Simulation Manager
// G4GlobalFastSimulationManager is a "Singleton".
// This class is an abstract interface for G4GlobalFastSimulationManager.
// It has the public access function GetConcreteInstance(), which is used
// to obtain a pointer to the concrete G4GlobalFastSimulationManager, should
// it exist. Then:
//
// G4VGlobalFastSimulationManager is an abstract interface for the
// G4GlobalFastSimulationManager one. It has the public access function
// GetConcreteInstance(), which is used to obtain a pointer to the concrete
// G4GlobalFastSimulationManager, should it exist. After
//
// G4VGlobalFastSimulationManager* pVFSMan =
// G4VGlobalFastSimulationManager* pVFSMan =
// G4VGlobalFastSimulationManager::GetConcreteInstance ();
//
// pVFSMan points to the real (concrete) G4GlobalFastSimulationManager if
// at least a parameterisation envelope exists, otherwise is zero.
// 'pVFSMan' points to the real (concrete) G4GlobalFastSimulationManager if
// at least a parameterisation envelope exists, otherwise is null.
//
// Thus all code must be protected, for example by:
// if (pVFSMan)
// G4FlavoredParallelWorld* =
// pVFSMan -> GetFlavoredWorldForThis(p);
//
// if (pVFSMan)
// G4FlavoredParallelWorld* = pVFSMan -> GetFlavoredWorldForThis(p);
// Authors: P. Mora de Freitas & M. Verderi, 14 April 1999
// --------------------------------------------------------------------
#ifndef G4VGLOBALFASTSIMULATIONMANAGER_HH
#define G4VGLOBALFASTSIMULATIONMANAGER_HH
#define G4VGLOBALFASTSIMULATIONMANAGER_HH 1
#include "G4Types.hh"
#include "icomsdefs.hh"
@@ -62,27 +57,26 @@ class G4ParticleDefinition;
class G4VGlobalFastSimulationManager
{
public:
public: // with description
static G4VGlobalFastSimulationManager* GetConcreteInstance();
// Returns pointer to the actual Global Fast Simulation manager if
// at least a parameterisation envelope exists
static G4VGlobalFastSimulationManager* GetConcreteInstance ();
// Returns pointer to actual Global Fast Simulation manager if
// at least a parameterisation envelope exists. Always check value.
virtual ~G4VGlobalFastSimulationManager() {}
virtual ~G4VGlobalFastSimulationManager () {}
virtual G4VFlavoredParallelWorld* GetFlavoredWorldForThis(
G4ParticleDefinition*) = 0;
// VGlobalFastSimulationManager interface for visualisation
virtual
G4VFlavoredParallelWorld* GetFlavoredWorldForThis(G4ParticleDefinition*)=0;
// VGlobalFastSimulationManager interface for visualisation.
protected:
protected:
static void SetConcreteInstance (G4VGlobalFastSimulationManager*);
// Sets the pointer to actual Global Fast Simulation manager.
G4ICOMS_DLL static G4ThreadLocal G4VGlobalFastSimulationManager* fpConcreteInstance;
// Pointer to real G4GlobalFastSimulationManager.
static void SetConcreteInstance(G4VGlobalFastSimulationManager*);
// Sets the pointer to the actual Global Fast Simulation manager
G4ICOMS_DLL
static G4ThreadLocal G4VGlobalFastSimulationManager* fpConcreteInstance;
// Pointer to real G4GlobalFastSimulationManager
};
#endif
+12 -14
View File
@@ -23,28 +23,26 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//
// Defines for Windows DLLs import/export
//
// Author: G.Cosmo, CERN
// --------------------------------------------------------------------
#ifndef G4ICOMSWDEFS_HH
#define G4ICOMSWDEFS_HH
#define G4ICOMSWDEFS_HH 1
#include "G4Types.hh"
#ifdef WIN32
//
// Unique identifier for intercoms module
//
#if defined G4ICOMS_ALLOC_EXPORT
#define G4ICOMS_DLL G4DLLEXPORT
#else
#define G4ICOMS_DLL G4DLLIMPORT
#endif
//
// Unique identifier for intercoms module
//
# if defined G4ICOMS_ALLOC_EXPORT
# define G4ICOMS_DLL G4DLLEXPORT
# else
# define G4ICOMS_DLL G4DLLIMPORT
# endif
#else
#define G4ICOMS_DLL
# define G4ICOMS_DLL
#endif
#endif /* G4ICOMSWDEFS_HH */