Geant4-11
Data Structures | Public Member Functions | Private Attributes
G4AnyMethod Class Reference

#include <G4AnyMethod.hh>

Data Structures

struct  FuncRef
 
struct  FuncRef1
 
struct  FuncRef2
 
class  Placeholder
 

Public Member Functions

const std::type_info & ArgType (size_t n=0) const
 
G4bool Empty () const
 
 G4AnyMethod ()
 
 G4AnyMethod (const G4AnyMethod &other)
 
template<class S , class T >
 G4AnyMethod (S(T::*f)())
 
template<class S , class T , class A0 >
 G4AnyMethod (S(T::*f)(A0))
 
template<class S , class T , class A0 , class A1 >
 G4AnyMethod (S(T::*f)(A0, A1))
 
std::size_t NArg () const
 
void operator() (void *obj)
 
void operator() (void *obj, const std::string &a0)
 
G4AnyMethodoperator= (const G4AnyMethod &rhs)
 
template<class S , class T >
G4AnyMethodoperator= (S(T::*f)())
 
template<class S , class T , class A0 >
G4AnyMethodoperator= (S(T::*f)(A0))
 
template<class S , class T , class A0 , class A1 >
G4AnyMethodoperator= (S(T::*f)(A0, A1))
 
G4AnyMethodSwap (G4AnyMethod &rhs)
 
 ~G4AnyMethod ()
 

Private Attributes

PlaceholderfContent = nullptr
 
std::size_t narg = 0
 

Detailed Description

Definition at line 67 of file G4AnyMethod.hh.

Constructor & Destructor Documentation

◆ G4AnyMethod() [1/5]

G4AnyMethod::G4AnyMethod ( )
inline

contructors

Definition at line 73 of file G4AnyMethod.hh.

74 {}

Referenced by operator=().

◆ G4AnyMethod() [2/5]

template<class S , class T >
G4AnyMethod::G4AnyMethod ( S(T::*)()  f)
inline

Definition at line 77 of file G4AnyMethod.hh.

78 {
79 fContent = new FuncRef<S, T>(f);
80 }
Placeholder * fContent
Definition: G4AnyMethod.hh:251

References fContent.

◆ G4AnyMethod() [3/5]

template<class S , class T , class A0 >
G4AnyMethod::G4AnyMethod ( S(T::*)(A0)  f)
inline

Definition at line 83 of file G4AnyMethod.hh.

84 : narg(1)
85 {
86 fContent = new FuncRef1<S, T, A0>(f);
87 }
std::size_t narg
Definition: G4AnyMethod.hh:252

References fContent.

◆ G4AnyMethod() [4/5]

template<class S , class T , class A0 , class A1 >
G4AnyMethod::G4AnyMethod ( S(T::*)(A0, A1)  f)
inline

Definition at line 90 of file G4AnyMethod.hh.

91 : narg(2)
92 {
93 fContent = new FuncRef2<S, T, A0, A1>(f);
94 }

References fContent.

◆ G4AnyMethod() [5/5]

G4AnyMethod::G4AnyMethod ( const G4AnyMethod other)
inline

Definition at line 96 of file G4AnyMethod.hh.

97 : fContent(other.fContent ? other.fContent->Clone() : nullptr)
98 , narg(other.narg)
99 {}
virtual Placeholder * Clone() const =0

◆ ~G4AnyMethod()

G4AnyMethod::~G4AnyMethod ( )
inline

destructor

Definition at line 103 of file G4AnyMethod.hh.

103{ delete fContent; }

References fContent.

Member Function Documentation

◆ ArgType()

const std::type_info & G4AnyMethod::ArgType ( size_t  n = 0) const
inline

Definition at line 160 of file G4AnyMethod.hh.

161 {
162 return fContent ? fContent->ArgType(n) : typeid(void);
163 }
virtual const std::type_info & ArgType(size_t) const =0

References G4AnyMethod::Placeholder::ArgType(), fContent, and CLHEP::detail::n.

Referenced by G4GenericMessenger::DeclareMethod().

◆ Empty()

G4bool G4AnyMethod::Empty ( ) const
inline

Query

Definition at line 146 of file G4AnyMethod.hh.

146{ return !fContent; }

References fContent.

◆ NArg()

std::size_t G4AnyMethod::NArg ( ) const
inline

Number of arguments

Definition at line 158 of file G4AnyMethod.hh.

158{ return narg; }

References narg.

Referenced by G4GenericMessenger::DeclareMethod(), and G4GenericMessenger::DeclareMethodWithUnit().

◆ operator()() [1/2]

void G4AnyMethod::operator() ( void *  obj)
inline

call operators

Definition at line 150 of file G4AnyMethod.hh.

150{ fContent->operator()(obj); }

References fContent.

◆ operator()() [2/2]

void G4AnyMethod::operator() ( void *  obj,
const std::string &  a0 
)
inline

Definition at line 151 of file G4AnyMethod.hh.

152 {
153 fContent->operator()(obj, a0);
154 }
const G4double a0

References a0, and fContent.

◆ operator=() [1/4]

G4AnyMethod & G4AnyMethod::operator= ( const G4AnyMethod rhs)
inline

Definition at line 137 of file G4AnyMethod.hh.

138 {
139 G4AnyMethod(rhs).Swap(*this);
140 narg = rhs.narg;
141 return *this;
142 }

References G4AnyMethod(), and narg.

◆ operator=() [2/4]

template<class S , class T >
G4AnyMethod & G4AnyMethod::operator= ( S(T::*)()  f)
inline

Assignment operators

Definition at line 115 of file G4AnyMethod.hh.

116 {
117 G4AnyMethod(f).Swap(*this);
118 narg = 0;
119 return *this;
120 }

References G4AnyMethod(), and narg.

◆ operator=() [3/4]

template<class S , class T , class A0 >
G4AnyMethod & G4AnyMethod::operator= ( S(T::*)(A0)  f)
inline

Definition at line 123 of file G4AnyMethod.hh.

124 {
125 G4AnyMethod(f).Swap(*this);
126 narg = 1;
127 return *this;
128 }

References G4AnyMethod(), and narg.

◆ operator=() [4/4]

template<class S , class T , class A0 , class A1 >
G4AnyMethod & G4AnyMethod::operator= ( S(T::*)(A0, A1)  f)
inline

Definition at line 130 of file G4AnyMethod.hh.

131 {
132 G4AnyMethod(f).Swap(*this);
133 narg = 1;
134 return *this;
135 }

References G4AnyMethod(), and narg.

◆ Swap()

G4AnyMethod & G4AnyMethod::Swap ( G4AnyMethod rhs)
inline

Definition at line 105 of file G4AnyMethod.hh.

106 {
107 std::swap(fContent, rhs.fContent);
108 std::swap(narg, rhs.narg);
109 return *this;
110 }

References fContent, and narg.

Field Documentation

◆ fContent

Placeholder* G4AnyMethod::fContent = nullptr
private

Definition at line 251 of file G4AnyMethod.hh.

Referenced by ArgType(), Empty(), G4AnyMethod(), operator()(), Swap(), and ~G4AnyMethod().

◆ narg

std::size_t G4AnyMethod::narg = 0
private

Definition at line 252 of file G4AnyMethod.hh.

Referenced by NArg(), operator=(), and Swap().


The documentation for this class was generated from the following file: