Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Data Structures | Public Member Functions | Friends
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
 
voidAddress () 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 63 of file G4AnyType.hh.

Constructor & Destructor Documentation

G4AnyType::G4AnyType ( )
inline

Constructor

Definition at line 66 of file G4AnyType.hh.

Referenced by operator=().

66  :
67  fContent(0) {}
template<typename ValueType >
G4AnyType::G4AnyType ( ValueType &  value)
inline

Constructor

Definition at line 70 of file G4AnyType.hh.

70  :
71  fContent(new Ref<ValueType>(value)) {}
const XML_Char int const XML_Char * value
G4AnyType::G4AnyType ( const G4AnyType other)
inline

Copy Constructor

Definition at line 74 of file G4AnyType.hh.

74  :
75  fContent(other.fContent ? other.fContent->Clone() : 0) {}
G4AnyType::~G4AnyType ( )
inline

Dtor

Definition at line 78 of file G4AnyType.hh.

78  {
79  delete fContent;
80  }

Member Function Documentation

void* G4AnyType::Address ( ) const
inline

Adress

Definition at line 110 of file G4AnyType.hh.

110  {
111  return fContent ? fContent->Address() : 0;
112  }
bool G4AnyType::Empty ( ) const
inline

Query

Definition at line 102 of file G4AnyType.hh.

Referenced by operator bool().

102  {
103  return !fContent;
104  }
void G4AnyType::FromString ( const std::string &  val)
inline

String conversion

Definition at line 118 of file G4AnyType.hh.

Referenced by G4GenericMessenger::SetNewValue().

118  {
119  fContent->FromString(val);
120  }
G4AnyType::operator bool ( )
inline

bool operator

Definition at line 83 of file G4AnyType.hh.

References Empty().

83  {
84  return !Empty();
85  }
bool Empty() const
Definition: G4AnyType.hh:102
template<typename ValueType >
G4AnyType& G4AnyType::operator= ( const ValueType &  rhs)
inline

Modifier

Definition at line 92 of file G4AnyType.hh.

References G4AnyType().

92  {
93  G4AnyType(rhs).Swap(*this);
94  return *this;
95  }
G4AnyType& G4AnyType::operator= ( const G4AnyType rhs)
inline

Modifier

Definition at line 97 of file G4AnyType.hh.

References G4AnyType().

97  {
98  G4AnyType(rhs).Swap(*this);
99  return *this;
100  }
G4AnyType& G4AnyType::Swap ( G4AnyType rhs)
inline

Modifier

Definition at line 87 of file G4AnyType.hh.

References CLHEP::swap().

87  {
88  std::swap(fContent, rhs.fContent);
89  return *this;
90  }
void swap(shared_ptr< P > &, shared_ptr< P > &)
Definition: memory.h:1247
std::string G4AnyType::ToString ( ) const
inline

String conversion

Definition at line 114 of file G4AnyType.hh.

Referenced by G4GenericMessenger::GetCurrentValue().

114  {
115  return fContent->ToString();
116  }
const std::type_info& G4AnyType::TypeInfo ( ) const
inline

Query

Definition at line 106 of file G4AnyType.hh.

References void().

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

106  {
107  return fContent ? fContent->TypeInfo() : typeid(void);
108  }
typedef void(XMLCALL *XML_ElementDeclHandler)(void *userData

Friends And Related Function Documentation

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

representation

value

Definition at line 213 of file G4AnyType.hh.

213  {
214  return operand && operand->TypeInfo() == typeid(ValueType)
215  ? &static_cast<G4AnyType::Ref<ValueType>*>(operand->fContent)->fRef : 0;
216 }
const std::type_info & TypeInfo() const
Definition: G4AnyType.hh:106

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