Geant4 10.7.0
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 ()
 
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 ( )
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 {}

◆ 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 {}

◆ ~G4AnyType()

G4AnyType::~G4AnyType ( )
inline

Destructor

Definition at line 85 of file G4AnyType.hh.

85{ delete 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; }

◆ Empty()

G4bool G4AnyType::Empty ( ) const
inline

Queries

Definition at line 114 of file G4AnyType.hh.

114{ return !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); }

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

◆ 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 }

◆ 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 }

◆ 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 }

◆ ToString()

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

String conversions

Definition at line 127 of file G4AnyType.hh.

127{ return fContent->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 }

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}
const std::type_info & TypeInfo() const
Definition: G4AnyType.hh:116

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