Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
EntryModelBounded< T > Class Template Reference

Specialization of EntryModel with upper and lower bounds. More...

#include <EntryModel.hxx>

Inheritance diagram for EntryModelBounded< T >:
EntryModel< T >

Public Member Functions

 EntryModelBounded ()
 Constructor.
 
void init (unsigned max_size, int base, T value, T min, T max, T default_val, bool automatic_clamp=true)
 Initialize with a value.
 
void set_default ()
 Set the value to the default.
 
- Public Member Functions inherited from EntryModel< T >
 EntryModel ()
 Constructor.
 
void clear ()
 Clear the entry string.
 
void init (unsigned max_size, int base)
 Initialize empty.
 
void init (unsigned max_size, int base, T value, bool automatic_clamp=true)
 Initialize with a value.
 
void push_back (uint8_t val)
 Append a value to the "back".
 
void push_back_char (char c)
 Append a character to the "back".
 
EntryModelappend (uint8_t val)
 Append a value to the "back".
 
EntryModelappend_char (char c)
 Append a character to the "back".
 
void pop_back ()
 Removes (deletes) a character off the end.
 
void set_base (int base)
 Set the radix base.
 
void set_base (int base, bool convert)
 Set the radix base.
 
void set_value (T value)
 Set the value, keep the max number of digits and base the same.
 
size_t size ()
 Get the size (actual number of digits).
 
size_t max_size ()
 Get the max size (in digits).
 
bool empty ()
 Test if the entry is "empty".
 
bool cursor_visible ()
 Test if cursor is visible.
 
bool is_at_initial_value ()
 Determine if this object is holding an initial or modified value.
 
bool has_leading_zeros ()
 It is not always possible with get_string() to return the leading zeros.
 
void set_leading_zeros (unsigned num)
 Sets the number of leading zeros without changing the value.
 
get_value (bool force_clamp=false)
 Get the entry as an unsigned integer value.
 
string get_string (bool right_justify=false)
 Get the value as a string.
 
void set_min ()
 Set the value to the minimum.
 
void set_max ()
 Set the value to the maximum.
 
void change_sign ()
 Change the sign of the data.
 
operator++ ()
 Pre-increment value.
 
operator-- ()
 Pre-decrement value.
 

Private Member Functions

void clamp (bool force=false) override
 Clamp the value at the min or max.
 
void set_boundaries () override
 Override base class to do nothing.
 
 DISALLOW_COPY_AND_ASSIGN (EntryModelBounded)
 

Private Attributes

valueDefault_
 default value
 

Additional Inherited Members

- Protected Member Functions inherited from EntryModel< T >
void auto_clamp (bool force=false)
 Calls clamp() only if automatic clamping is enabled (autoClamp_ = true).
 
void calculate_size ()
 Calculate the size in digits.
 
 DISALLOW_COPY_AND_ASSIGN (EntryModel)
 
- Protected Attributes inherited from EntryModel< T >
value_
 present value held
 
valueMin_
 minimum value representable by maxSize_
 
valueMax_
 maximum value representable by maxSize_
 
unsigned numLeadingZeros_: 5
 number of leading zeros
 
unsigned maxSize_: 5
 maximum number of digits
 
unsigned size_: 5
 actual number of digits
 
unsigned isAtInitialValue_: 1
 true if still has the initial value
 
unsigned empty_: 1
 true if the value_ is "empty"
 
unsigned base_: 6
 radix base
 
unsigned autoClamp_: 1
 true to auto clamp the values
 

Detailed Description

template<class T>
class EntryModelBounded< T >

Specialization of EntryModel with upper and lower bounds.

Template Parameters
Tthe data type up to 64-bits in size
Nthe size of the entry in max number of visible digits.

Definition at line 511 of file EntryModel.hxx.

Constructor & Destructor Documentation

◆ EntryModelBounded()

template<class T >
EntryModelBounded< T >::EntryModelBounded ( )
inline

Constructor.

Definition at line 515 of file EntryModel.hxx.

Member Function Documentation

◆ clamp()

template<class T >
void EntryModelBounded< T >::clamp ( bool  force = false)
inlineoverrideprivatevirtual

Clamp the value at the min or max.

Clamping will not occur if the value is zero and there is space for more leading zeros.

Parameters
forceNormally, clamping doesn't occur if the entry is "empty". However, if force is set to true, we will clamp anyways.

Reimplemented from EntryModel< T >.

Definition at line 550 of file EntryModel.hxx.

◆ init()

template<class T >
void EntryModelBounded< T >::init ( unsigned  max_size,
int  base,
value,
min,
max,
default_val,
bool  automatic_clamp = true 
)
inline

Initialize with a value.

Parameters
max_sizemax number of digits in the base type
basebase type, 10 or 16
valuevalue to initialize with
minminumum value
maxmaximum value
default_valdefault value
automatic_clamp

Definition at line 528 of file EntryModel.hxx.

◆ set_boundaries()

template<class T >
void EntryModelBounded< T >::set_boundaries ( )
inlineoverrideprivatevirtual

Override base class to do nothing.

The boundaries come from EntryModelBounded::init().

Reimplemented from EntryModel< T >.

Definition at line 564 of file EntryModel.hxx.

◆ set_default()

template<class T >
void EntryModelBounded< T >::set_default ( )
inline

Set the value to the default.

Definition at line 540 of file EntryModel.hxx.

Member Data Documentation

◆ valueDefault_

template<class T >
T EntryModelBounded< T >::valueDefault_
private

default value

Definition at line 568 of file EntryModel.hxx.


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