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

#include <G4AnyType.hh>

Data Structures

class  Placeholder
 
class  Ref
 

Public Member Functions

void * Address () const
 
G4bool Empty () const
 
void FromString (const std::string &val)
 
 G4AnyType ()
 
 G4AnyType (const G4AnyType &other)
 
template<typename ValueType >
 G4AnyType (ValueType &value)
 
 operator bool ()
 
G4AnyTypeoperator= (const G4AnyType &rhs)
 
template<typename ValueType >
G4AnyTypeoperator= (const ValueType &rhs)
 
G4AnyTypeSwap (G4AnyType &rhs)
 
std::string ToString () const
 
const std::type_info & TypeInfo () const
 
 ~G4AnyType ()
 

Private Attributes

PlaceholderfContent = nullptr
 

Friends

template<typename ValueType >
ValueType * any_cast (G4AnyType *)
 

Detailed Description

Definition at line 63 of file G4AnyType.hh.

Constructor & Destructor Documentation

◆ G4AnyType() [1/3]

G4AnyType::G4AnyType ( )
inline

Constructors

Definition at line 69 of file G4AnyType.hh.

70 {}

Referenced by operator=().

◆ G4AnyType() [2/3]

template<typename ValueType >
G4AnyType::G4AnyType ( ValueType &  value)
inline

Definition at line 73 of file G4AnyType.hh.

74 : fContent(new Ref<ValueType>(value))
75 {}
Placeholder * fContent
Definition: G4AnyType.hh:209

◆ G4AnyType() [3/3]

G4AnyType::G4AnyType ( const G4AnyType other)
inline

Copy Constructor

Definition at line 79 of file G4AnyType.hh.

80 : fContent(other.fContent ? other.fContent->Clone() : 0)
81 {}
virtual Placeholder * Clone() const =0

◆ ~G4AnyType()

G4AnyType::~G4AnyType ( )
inline

Destructor

Definition at line 85 of file G4AnyType.hh.

85{ delete fContent; }

References fContent.

Member Function Documentation

◆ Address()

void * G4AnyType::Address ( ) const
inline

Address

Definition at line 123 of file G4AnyType.hh.

123{ return fContent ? fContent->Address() : 0; }
virtual void * Address() const =0

References G4AnyType::Placeholder::Address(), and fContent.

◆ Empty()

G4bool G4AnyType::Empty ( ) const
inline

Queries

Definition at line 114 of file G4AnyType.hh.

114{ return !fContent; }

References fContent.

Referenced by operator bool().

◆ FromString()

void G4AnyType::FromString ( const std::string &  val)
inline

Definition at line 129 of file G4AnyType.hh.

129{ fContent->FromString(val); }
virtual void FromString(const std::string &val)=0

References fContent, and G4AnyType::Placeholder::FromString().

Referenced by G4GenericMessenger::SetNewValue().

◆ operator bool()

G4AnyType::operator bool ( )
inline

bool operator

Definition at line 89 of file G4AnyType.hh.

89{ return !Empty(); }
G4bool Empty() const
Definition: G4AnyType.hh:114

References Empty().

◆ operator=() [1/2]

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

Definition at line 106 of file G4AnyType.hh.

107 {
108 G4AnyType(rhs).Swap(*this);
109 return *this;
110 }

References G4AnyType().

◆ operator=() [2/2]

template<typename ValueType >
G4AnyType & G4AnyType::operator= ( const ValueType &  rhs)
inline

Definition at line 100 of file G4AnyType.hh.

101 {
102 G4AnyType(rhs).Swap(*this);
103 return *this;
104 }

References G4AnyType().

◆ Swap()

G4AnyType & G4AnyType::Swap ( G4AnyType rhs)
inline

Modifiers

Definition at line 93 of file G4AnyType.hh.

94 {
95 std::swap(fContent, rhs.fContent);
96 return *this;
97 }

References fContent.

◆ ToString()

std::string G4AnyType::ToString ( ) const
inline

String conversions

Definition at line 127 of file G4AnyType.hh.

127{ return fContent->ToString(); }
virtual std::string ToString() const =0

References fContent, and G4AnyType::Placeholder::ToString().

Referenced by G4GenericMessenger::GetCurrentValue().

◆ TypeInfo()

const std::type_info & G4AnyType::TypeInfo ( ) const
inline

Definition at line 116 of file G4AnyType.hh.

117 {
118 return fContent ? fContent->TypeInfo() : typeid(void);
119 }
virtual const std::type_info & TypeInfo() const =0

References fContent, and G4AnyType::Placeholder::TypeInfo().

Referenced by G4GenericMessenger::DeclareProperty(), and G4GenericMessenger::DeclarePropertyWithUnit().

Friends And Related Function Documentation

◆ any_cast

template<typename ValueType >
ValueType * any_cast ( G4AnyType operand)
friend

representation

value

Definition at line 256 of file G4AnyType.hh.

257{
258 return operand && operand->TypeInfo() == typeid(ValueType)
259 ? &static_cast<G4AnyType::Ref<ValueType>*>(operand->fContent)->fRef
260 : nullptr;
261}
static int operand(pchar begin, pchar end, double &result, pchar &endp, const dic_type &dictionary)
Definition: Evaluator.cc:163
ValueType & fRef
Definition: G4AnyType.hh:201

Field Documentation

◆ fContent

Placeholder* G4AnyType::fContent = nullptr
private

Definition at line 209 of file G4AnyType.hh.

Referenced by Address(), Empty(), FromString(), Swap(), ToString(), TypeInfo(), and ~G4AnyType().


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