Belle II Software development
Parameter< AType > Class Template Reference

This class represents a quantity which value can be set both permanently and temporarily. More...

#include <HistogramFactory.h>

Public Member Functions

 Parameter (const AType &defaultValue)
 Constructor.
 
void Set (const AType &value)
 Permanently sets inner quantity to given value.
 
void Set (const Parameter< AType > &parameter)
 Copy permanent value from another parameter but only if its permanent value is set.
 
void SetTemporarily (const AType &value)
 Temporarily sets inner quantity to given value.
 
void SetTemporarily (const Parameter< AType > &parameter)
 Copy temporary value from another parameter but only if its temporary value is set.
 
AType Get ()
 Returns value of the inner quantity.
 

Private Attributes

AType m_value
 permanent value
 
AType m_temporaryValue
 temporary value
 
bool m_isSet
 determines if the permanent value is set
 
bool m_isSetTemporarily
 determines if the temporary value is set
 

Detailed Description

template<typename AType>
class Belle2::HistogramFactory::Parameter< AType >

This class represents a quantity which value can be set both permanently and temporarily.

Temporary value has priority but is invalidated when is read for the first time. Quantity can be of any type. The class used in Factory to save some lines of code.

Definition at line 21 of file HistogramFactory.h.

Constructor & Destructor Documentation

◆ Parameter()

Parameter ( const AType &  defaultValue)
inlineexplicit

Constructor.

Parameters
defaultValue- a value which is returned when permanent nor temporary value is set.

Definition at line 25 of file HistogramFactory.h.

25 :
26 m_value(defaultValue), m_temporaryValue(defaultValue), m_isSet(false), m_isSetTemporarily(false)
27 {}
bool m_isSet
determines if the permanent value is set
bool m_isSetTemporarily
determines if the temporary value is set

Member Function Documentation

◆ Get()

AType Get

Returns value of the inner quantity.

Get value and reset temporary setting.

Order is: temporary value (if is set), permanent value (if is set), default value. Temporary value is invalidated.

Returns
value - a temporary value if it's set, then permanent value if it's set, then default value.

Definition at line 92 of file HistogramFactory.h.

93 {
95 m_isSetTemporarily = false;
96 return m_temporaryValue;
97 } else {
98 return m_value;
99 }
100 }

◆ Set() [1/2]

void Set ( const AType &  value)

Permanently sets inner quantity to given value.

Sets the permanent value.

Parameters
value- a value we want to set

Definition at line 59 of file HistogramFactory.h.

60 {
61 m_value = value;
62 m_isSet = true;
63 }

◆ Set() [2/2]

void Set ( const Parameter< AType > &  parameter)

Copy permanent value from another parameter but only if its permanent value is set.

Copy the permanent value setting.

Parameters
parameter- another parameter whose permanent value is copied

Definition at line 67 of file HistogramFactory.h.

68 {
69 if (parameter.m_isSet)
70 Set(parameter.m_value);
71 }
void Set(const AType &value)
Permanently sets inner quantity to given value.

◆ SetTemporarily() [1/2]

void SetTemporarily ( const AType &  value)

Temporarily sets inner quantity to given value.

Sets the temporary value.

Parameters
value- a value we want to set

Definition at line 75 of file HistogramFactory.h.

76 {
77 m_temporaryValue = value;
78 m_isSetTemporarily = true;
79 }

◆ SetTemporarily() [2/2]

void SetTemporarily ( const Parameter< AType > &  parameter)

Copy temporary value from another parameter but only if its temporary value is set.

Copy the temporary value setting.

Parameters
parameter- another parameter whose temporary value is copied

Definition at line 83 of file HistogramFactory.h.

84 {
85 if (parameter.m_isSet)
86 SetTemporarily(parameter.m_value);
87 }
void SetTemporarily(const AType &value)
Temporarily sets inner quantity to given value.

Member Data Documentation

◆ m_isSet

bool m_isSet
private

determines if the permanent value is set

Definition at line 52 of file HistogramFactory.h.

◆ m_isSetTemporarily

bool m_isSetTemporarily
private

determines if the temporary value is set

Definition at line 54 of file HistogramFactory.h.

◆ m_temporaryValue

AType m_temporaryValue
private

temporary value

Definition at line 50 of file HistogramFactory.h.

◆ m_value

AType m_value
private

permanent value

Definition at line 48 of file HistogramFactory.h.


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