Geant4 11.1.1
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 *)
 

Detailed Description

Definition at line 63 of file G4AnyType.hh.

Constructor & Destructor Documentation

◆ G4AnyType() [1/3]

G4AnyType::G4AnyType ( )
default

Constructors

Referenced by operator=().

◆ G4AnyType() [2/3]

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

Definition at line 72 of file G4AnyType.hh.

73 : fContent(new Ref<ValueType>(value))
74 {}

◆ G4AnyType() [3/3]

G4AnyType::G4AnyType ( const G4AnyType other)
inline

Copy Constructor

Definition at line 78 of file G4AnyType.hh.

79 : fContent(other.fContent != nullptr ? other.fContent->Clone() : nullptr)
80 {}

◆ ~G4AnyType()

G4AnyType::~G4AnyType ( )
inline

Destructor

Definition at line 84 of file G4AnyType.hh.

84{ delete fContent; }

Member Function Documentation

◆ Address()

void * G4AnyType::Address ( ) const
inline

Address

Definition at line 122 of file G4AnyType.hh.

122 {
123 return fContent != nullptr ? fContent->Address() : nullptr;
124 }

◆ Empty()

G4bool G4AnyType::Empty ( ) const
inline

Queries

Definition at line 113 of file G4AnyType.hh.

113{ return fContent == nullptr; }

Referenced by operator bool().

◆ FromString()

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

Definition at line 130 of file G4AnyType.hh.

130{ fContent->FromString(val); }

Referenced by G4GenericMessenger::SetNewValue().

◆ operator bool()

G4AnyType::operator bool ( )
inline

bool operator

Definition at line 88 of file G4AnyType.hh.

88{ return !Empty(); }
G4bool Empty() const
Definition: G4AnyType.hh:113

◆ operator=() [1/2]

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

Definition at line 105 of file G4AnyType.hh.

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

◆ operator=() [2/2]

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

Definition at line 99 of file G4AnyType.hh.

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

◆ Swap()

G4AnyType & G4AnyType::Swap ( G4AnyType rhs)
inline

Modifiers

Definition at line 92 of file G4AnyType.hh.

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

◆ ToString()

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

String conversions

Definition at line 128 of file G4AnyType.hh.

128{ return fContent->ToString(); }

Referenced by G4GenericMessenger::GetCurrentValue().

◆ TypeInfo()

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

Definition at line 115 of file G4AnyType.hh.

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

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 259 of file G4AnyType.hh.

260{
261 return operand && operand->TypeInfo() == typeid(ValueType)
262 ? &static_cast<G4AnyType::Ref<ValueType>*>(operand->fContent)->fRef
263 : nullptr;
264}
const std::type_info & TypeInfo() const
Definition: G4AnyType.hh:115

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