Geant4 9.6.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)
 
bool 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

This class represents any data type. The class only holds a reference to the type and not the value.

Definition at line 61 of file G4AnyType.hh.

Constructor & Destructor Documentation

◆ G4AnyType() [1/3]

G4AnyType::G4AnyType ( )
inline

Constructor

Definition at line 64 of file G4AnyType.hh.

64 :
65 fContent(0) {}

Referenced by operator=().

◆ G4AnyType() [2/3]

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

Constructor

Definition at line 68 of file G4AnyType.hh.

68 :
69 fContent(new Ref<ValueType>(value)) {}

◆ G4AnyType() [3/3]

G4AnyType::G4AnyType ( const G4AnyType other)
inline

Copy Constructor

Definition at line 72 of file G4AnyType.hh.

72 :
73 fContent(other.fContent ? other.fContent->Clone() : 0) {}

◆ ~G4AnyType()

G4AnyType::~G4AnyType ( )
inline

Dtor

Definition at line 76 of file G4AnyType.hh.

76 {
77 delete fContent;
78 }

Member Function Documentation

◆ Address()

void * G4AnyType::Address ( ) const
inline

Adress

Definition at line 108 of file G4AnyType.hh.

108 {
109 return fContent ? fContent->Address() : 0;
110 }

◆ Empty()

bool G4AnyType::Empty ( ) const
inline

Query

Definition at line 100 of file G4AnyType.hh.

100 {
101 return !fContent;
102 }

Referenced by operator bool().

◆ FromString()

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

String conversion

Definition at line 116 of file G4AnyType.hh.

116 {
117 fContent->FromString(val);
118 }

Referenced by G4GenericMessenger::SetNewValue().

◆ operator bool()

G4AnyType::operator bool ( )
inline

bool operator

Definition at line 81 of file G4AnyType.hh.

81 {
82 return !Empty();
83 }
bool Empty() const
Definition: G4AnyType.hh:100

◆ operator=() [1/2]

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

Modifier

Definition at line 95 of file G4AnyType.hh.

95 {
96 G4AnyType(rhs).Swap(*this);
97 return *this;
98 }

◆ operator=() [2/2]

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

Modifier

Definition at line 90 of file G4AnyType.hh.

90 {
91 G4AnyType(rhs).Swap(*this);
92 return *this;
93 }

◆ Swap()

G4AnyType & G4AnyType::Swap ( G4AnyType rhs)
inline

Modifier

Definition at line 85 of file G4AnyType.hh.

85 {
86 std::swap(fContent, rhs.fContent);
87 return *this;
88 }

◆ ToString()

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

String conversion

Definition at line 112 of file G4AnyType.hh.

112 {
113 return fContent->ToString();
114 }

Referenced by G4GenericMessenger::GetCurrentValue().

◆ TypeInfo()

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

Query

Definition at line 104 of file G4AnyType.hh.

104 {
105 return fContent ? fContent->TypeInfo() : typeid(void);
106 }

Referenced by G4GenericMessenger::DeclareProperty().

Friends And Related Function Documentation

◆ any_cast

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

representation

value

Definition at line 201 of file G4AnyType.hh.

201 {
202 return operand && operand->TypeInfo() == typeid(ValueType)
203 ? &static_cast<G4AnyType::Ref<ValueType>*>(operand->fContent)->fRef : 0;
204}
const std::type_info & TypeInfo() const
Definition: G4AnyType.hh:104

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