DLG4::VolumeBuilders
A fluent interface for Geant4 geometry definition.
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
Unit< T > Class Template Reference

#include <DLG4Units.hh>

Collaboration diagram for Unit< T >:
[legend]

Classes

struct  PropertySetter
 

Public Member Functions

PropertySetter InUnits (const Unit< T > &u)
 
PropertySetter InDefaultUnits ()
 
G4double InUnits (const Unit< T > &u) const
 
G4double InDefaultUnits () const
 
virtual ~Unit ()=default
 
 Unit (const Unit &other)
 
Unitoperator= (const Unit &other)
 
 Unit ()
 
 Unit (double f, Derived u)
 

Static Public Member Functions

static T FromNative (G4double)
 

Public Attributes

PropertySetter Native
 

Static Public Attributes

static T native {1.0}
 

Protected Member Functions

G4double NativeValue () const
 
 operator G4double () const
 
 Unit (G4double f)
 

Static Protected Member Functions

static Derived GetGlobalDefault ()
 

Protected Attributes

std::optional< G4double > NativeValue_
 

Detailed Description

template<class T>
class DLG4::Units::Unit< T >

CRTP base methods for Unit classes.

Template Parameters
T

Definition at line 154 of file DLG4Units.hh.

Constructor & Destructor Documentation

◆ ~Unit()

template<class T >
virtual ~Unit ( )
virtualdefault

◆ Unit() [1/4]

template<class T >
Unit ( const Unit< T > &  other)
inline

Definition at line 201 of file DLG4Units.hh.

202 : Native{*this, 1.0}, NativeValue_(other.NativeValue_) {
203 }
std::optional< G4double > NativeValue_
Definition DLG4Units.hh:247
PropertySetter Native
Definition DLG4Units.hh:182

◆ Unit() [2/4]

template<class T >
Unit ( )
inline

Definition at line 212 of file DLG4Units.hh.

212: Native{*this, 1.0}, NativeValue_(std::nullopt) {}

◆ Unit() [3/4]

template<class T >
Unit ( double  f,
Derived  u 
)
inlineexplicit

Definition at line 214 of file DLG4Units.hh.

215 : Native{*this, 1.0}, NativeValue_(f * u.NativeValue()) {
216 }

◆ Unit() [4/4]

template<class T >
Unit ( G4double  f)
inlineexplicitprotected

Definition at line 235 of file DLG4Units.hh.

242 : Native{*this, 1.0}, NativeValue_(f) {
243 };

Member Function Documentation

◆ FromNative()

template<typename T >
T FromNative ( G4double  native_value)
inlinestatic

Definition at line 253 of file DLG4Units.hh.

253 {
254 // This calls the protected explicit Unit(double) constructor
255 return T(native_value);
256 }

◆ GetGlobalDefault()

template<typename T >
T GetGlobalDefault ( )
inlinestaticprotected

Definition at line 299 of file DLG4Units.hh.

299{ return T(global_default_unit<T>); }

◆ InDefaultUnits() [1/2]

template<class T >
PropertySetter InDefaultUnits ( )
inline

Definition at line 184 of file DLG4Units.hh.

184{ return {*this, GetGlobalDefault().NativeValue()}; }
static Derived GetGlobalDefault()
Definition DLG4Units.hh:299

◆ InDefaultUnits() [2/2]

template<class T >
G4double InDefaultUnits ( ) const
inline

Definition at line 188 of file DLG4Units.hh.

188{ return InUnits(GetGlobalDefault()); }
PropertySetter InUnits(const Unit< T > &u)
Definition DLG4Units.hh:183

◆ InUnits() [1/2]

template<class T >
PropertySetter InUnits ( const Unit< T > &  u)
inline

Definition at line 183 of file DLG4Units.hh.

183{ return {*this, u.NativeValue()}; }

◆ InUnits() [2/2]

template<class T >
G4double InUnits ( const Unit< T > &  u) const
inline

Definition at line 187 of file DLG4Units.hh.

187{ return GetScaled(1.0 / u.NativeValue()); }

◆ NativeValue()

template<class T >
G4double NativeValue ( ) const
inlineprotected

Definition at line 192 of file DLG4Units.hh.

192{ return GetScaled(1.0); }

◆ operator G4double()

template<class T >
operator G4double ( ) const
inlineexplicitprotected

Definition at line 193 of file DLG4Units.hh.

193{ return GetScaled(1.0); }

◆ operator=()

template<class T >
Unit & operator= ( const Unit< T > &  other)
inline

Definition at line 205 of file DLG4Units.hh.

205 {
206 if (this != &other) {
207 this->NativeValue_ = other.NativeValue_;
208 }
209 return *this;
210 }

Member Data Documentation

◆ Native

template<class T >
PropertySetter Native

Definition at line 182 of file DLG4Units.hh.

◆ native

template<class T >
T native {1.0}
inlinestatic

Definition at line 196 of file DLG4Units.hh.

196{1.0};

◆ NativeValue_

template<class T >
std::optional<G4double> NativeValue_
protected

Definition at line 247 of file DLG4Units.hh.


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