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 | Protected Attributes | List of all members
UnitBase< T, NativeType > Class Template Reference

#include <DLG4Units.hh>

Collaboration diagram for UnitBase< T, NativeType >:
[legend]

Classes

struct  DefaultUnitsProxy
 
struct  Evaluator
 
struct  NativeProxy
 
struct  ScalableProxy
 

Public Member Functions

 UnitBase ()
 
 UnitBase (const UnitBase &other)
 
virtual ~UnitBase ()=default
 
UnitBaseoperator= (const UnitBase &other)
 
 UnitBase (double f, Derived u)
 
void CheckValue (const G4String &context) const
 
void CheckUnit (const G4String &context) const
 

Static Public Member Functions

static T FromNative (NativeType native_value)
 
static T GetGlobalDefault ()
 

Public Attributes

ScalableProxy< T > InUnits {*this}
 
DefaultUnitsProxy InDefaultUnits {*this}
 
NativeProxy Native {*this}
 

Static Public Attributes

static T native {1.0}
 

Protected Member Functions

 UnitBase (G4double f)
 

Protected Attributes

std::optional< NativeTypeNativeValue_
 

Detailed Description

template<class T, typename NativeType>
class DLG4::Units::UnitBase< T, NativeType >

CRTP base methods for Unit classes.

Template Parameters
T

Definition at line 92 of file DLG4Units.hh.

Constructor & Destructor Documentation

◆ UnitBase() [1/4]

template<class T , typename NativeType >
UnitBase ( )
inline

Definition at line 234 of file DLG4Units.hh.

235 : NativeValue_(std::nullopt) {
236 }
std::optional< NativeType > NativeValue_
Definition DLG4Units.hh:98

◆ UnitBase() [2/4]

template<class T , typename NativeType >
UnitBase ( const UnitBase< T, NativeType > &  other)
inline

Definition at line 238 of file DLG4Units.hh.

240 : NativeValue_(other.NativeValue_),
241 InUnits(*this),
242 InDefaultUnits(*this),
243 Native(*this) {
244 }
ScalableProxy< T > InUnits
Definition DLG4Units.hh:227
DefaultUnitsProxy InDefaultUnits
Definition DLG4Units.hh:228

◆ ~UnitBase()

template<class T , typename NativeType >
virtual ~UnitBase ( )
virtualdefault

◆ UnitBase() [3/4]

template<class T , typename NativeType >
UnitBase ( double  f,
Derived  u 
)
inlineexplicit

Definition at line 255 of file DLG4Units.hh.

256 : NativeValue_(f * u.Native) {u.CheckUnit("UnitBase");}

◆ UnitBase() [4/4]

template<class T , typename NativeType >
UnitBase ( G4double  f)
inlineexplicitprotected

Definition at line 284 of file DLG4Units.hh.

285 : NativeValue_(f) {
286 };

Member Function Documentation

◆ CheckUnit()

template<class T , typename NativeType >
void CheckUnit ( const G4String &  context) const
inline

Definition at line 271 of file DLG4Units.hh.

271 {
272 CheckValue(context);
273 if (!(NativeValue_ > 0.0)) {
274 G4Exception(context, "InvalidScale", FatalException,
275 "\n Attempted to apply a negative Unit\n");
276 exit(1);
277 }
278 }
void CheckValue(const G4String &context) const
Definition DLG4Units.hh:260

◆ CheckValue()

template<class T , typename NativeType >
void CheckValue ( const G4String &  context) const
inline

Definition at line 260 of file DLG4Units.hh.

260 {
261 // volatile may help with debugging dangling references.
262 volatile bool engagement_flag = NativeValue_.has_value();
263 if (!engagement_flag) {
264 //if (!NativeValue_.has_value()) {
265 G4Exception(context, "InvalidScale", FatalException,
266 "\n Attempted to use a Unit (or measure) before setting it;\n");
267 exit(1);
268 }
269 }

◆ FromNative()

template<class T , typename NativeType >
static T FromNative ( NativeType  native_value)
inlinestatic

Definition at line 232 of file DLG4Units.hh.

232{ return T(native_value); }

◆ GetGlobalDefault()

template<class T , typename NativeType >
static T GetGlobalDefault ( )
inlinestatic

Definition at line 258 of file DLG4Units.hh.

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

◆ operator=()

template<class T , typename NativeType >
UnitBase & operator= ( const UnitBase< T, NativeType > &  other)
inline

Definition at line 250 of file DLG4Units.hh.

250 {
251 this->NativeValue_ = other.NativeValue_;
252 return *this;
253 }

Member Data Documentation

◆ InDefaultUnits

template<class T , typename NativeType >
DefaultUnitsProxy InDefaultUnits {*this}

Definition at line 228 of file DLG4Units.hh.

228{*this};

◆ InUnits

template<class T , typename NativeType >
ScalableProxy<T> InUnits {*this}

Definition at line 227 of file DLG4Units.hh.

227{*this};

◆ Native

template<class T , typename NativeType >
NativeProxy Native {*this}

Definition at line 229 of file DLG4Units.hh.

229{*this};

◆ native

template<class T , typename NativeType >
T native {1.0}
inlinestatic

Definition at line 231 of file DLG4Units.hh.

231{1.0};

◆ NativeValue_

template<class T , typename NativeType >
std::optional<NativeType> NativeValue_
protected

Definition at line 98 of file DLG4Units.hh.


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