Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4AnyType Class Reference

#include <G4AnyType.hh>

Public Member Functions

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

Friends

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

Detailed Description

Definition at line 63 of file G4AnyType.hh.

Constructor & Destructor Documentation

◆ G4AnyType() [1/3]

G4AnyType::G4AnyType ( )
default

Constructors

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

◆ G4AnyType() [2/3]

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

Definition at line 71 of file G4AnyType.hh.

71 : fContent(new Ref<ValueType>(value))
72 {}

◆ G4AnyType() [3/3]

G4AnyType::G4AnyType ( const G4AnyType & other)
inline

Copy Constructor

Definition at line 76 of file G4AnyType.hh.

77 : fContent(other.fContent != nullptr ? other.fContent->Clone() : nullptr)
78 {}

◆ ~G4AnyType()

G4AnyType::~G4AnyType ( )
inline

Destructor

Definition at line 82 of file G4AnyType.hh.

82{ delete fContent; }

Member Function Documentation

◆ Address()

void * G4AnyType::Address ( ) const
inline

Address

Definition at line 120 of file G4AnyType.hh.

120{ return fContent != nullptr ? fContent->Address() : nullptr; }

◆ Empty()

G4bool G4AnyType::Empty ( ) const
inline

Queries

Definition at line 111 of file G4AnyType.hh.

111{ return fContent == nullptr; }

Referenced by operator bool().

◆ FromString()

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

Definition at line 126 of file G4AnyType.hh.

126{ fContent->FromString(val); }

Referenced by G4GenericMessenger::SetNewValue().

◆ operator bool()

G4AnyType::operator bool ( )
inline

bool operator

Definition at line 86 of file G4AnyType.hh.

86{ return !Empty(); }
G4bool Empty() const
Definition G4AnyType.hh:111

◆ operator=() [1/2]

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

Definition at line 103 of file G4AnyType.hh.

104 {
105 G4AnyType(rhs).Swap(*this);
106 return *this;
107 }
G4AnyType()=default

◆ operator=() [2/2]

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

Definition at line 97 of file G4AnyType.hh.

98 {
99 G4AnyType(rhs).Swap(*this);
100 return *this;
101 }

◆ Swap()

G4AnyType & G4AnyType::Swap ( G4AnyType & rhs)
inline

Modifiers

Definition at line 90 of file G4AnyType.hh.

91 {
92 std::swap(fContent, rhs.fContent);
93 return *this;
94 }

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

◆ ToString()

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

String conversions

Definition at line 124 of file G4AnyType.hh.

124{ return fContent->ToString(); }

Referenced by G4GenericMessenger::GetCurrentValue().

◆ TypeInfo()

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

Definition at line 113 of file G4AnyType.hh.

114 {
115 return fContent != nullptr ? fContent->TypeInfo() : typeid(void);
116 }

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

Friends And Related Symbol Documentation

◆ any_cast

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

representation

value

Definition at line 246 of file G4AnyType.hh.

247{
248 return operand && operand->TypeInfo() == typeid(ValueType)
249 ? &static_cast<G4AnyType::Ref<ValueType>*>(operand->fContent)->fRef
250 : nullptr;
251}
const std::type_info & TypeInfo() const
Definition G4AnyType.hh:113

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