Scroom 0.14-48-ga0fee447
Loading...
Searching...
No Matches
Freezable< T > Class Template Reference

#include <view.hh>

Collaboration diagram for Freezable< T >:
Collaboration graph

Public Types

using value_type = T
 
using Me = Freezable< T >
 

Public Member Functions

 Freezable ()=default
 
 Freezable (value_type v)
 
const value_typeget () const
 
bool set (value_type v)
 
void lock ()
 
void unlock ()
 
bool is_locked () const
 
 operator const value_type & () const
 
Meoperator= (value_type v)
 
const value_typeoperator* () const
 
const value_typeoperator-> () const
 
Meoperator+= (value_type v)
 
Meoperator-= (value_type v)
 

Private Attributes

value_type value
 
unsigned locked {0}
 

Detailed Description

template<typename T>
class Freezable< T >

Protect a value from being assigned.

When the presentation position changes, scroll-bars and textboxes need updating, which in turn generate their own value-changed events, sometimes with different values. It is a mess.

By locking the current position, we keep those events from changing (and thereby corrupting) the updated value.

Member Typedef Documentation

◆ Me

template<typename T >
using Freezable< T >::Me = Freezable<T>

◆ value_type

template<typename T >
using Freezable< T >::value_type = T

Constructor & Destructor Documentation

◆ Freezable() [1/2]

template<typename T >
Freezable< T >::Freezable ( )
default

◆ Freezable() [2/2]

template<typename T >
Freezable< T >::Freezable ( value_type  v)
inlineexplicit
57 : value(std::move(v))
58 {
59 }
value_type value
Definition view.hh:50

Member Function Documentation

◆ get()

template<typename T >
const value_type & Freezable< T >::get ( ) const
inline
61{ return value; }

Referenced by View::on_scrollbar_value_changed(), and View::updateXY().

Here is the caller graph for this function:

◆ is_locked()

template<typename T >
bool Freezable< T >::is_locked ( ) const
inline
79{ return locked; }
unsigned locked
Definition view.hh:51

◆ lock()

template<typename T >
void Freezable< T >::lock ( )
inline
72{ locked++; }

◆ operator const value_type &()

template<typename T >
Freezable< T >::operator const value_type & ( ) const
inline
81{ return value; } // NOLINT(hicpp-explicit-conversions)

◆ operator*()

template<typename T >
const value_type * Freezable< T >::operator* ( ) const
inline
87{ return &value; }

◆ operator+=()

template<typename T >
Me & Freezable< T >::operator+= ( value_type  v)
inline
89{ return operator=(value + v); }
Me & operator=(value_type v)
Definition view.hh:82
Here is the call graph for this function:

◆ operator-=()

template<typename T >
Me & Freezable< T >::operator-= ( value_type  v)
inline
90{ return operator=(value - v); }
Here is the call graph for this function:

◆ operator->()

template<typename T >
const value_type * Freezable< T >::operator-> ( ) const
inline
88{ return &value; }

◆ operator=()

template<typename T >
Me & Freezable< T >::operator= ( value_type  v)
inline
83 {
84 set(std::move(v));
85 return *this;
86 }
bool set(value_type v)
Definition view.hh:63

Referenced by Freezable< T >::operator+=(), and Freezable< T >::operator-=().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set()

template<typename T >
bool Freezable< T >::set ( value_type  v)
inline
64 {
65 if(!locked)
66 {
67 value = std::move(v);
68 }
69 return locked;
70 }

Referenced by Freezable< T >::operator=().

Here is the caller graph for this function:

◆ unlock()

template<typename T >
void Freezable< T >::unlock ( )
inline
75 {
76 require(locked > 0);
77 locked--;
78 }
#define require(expr)
Definition assertions.hh:30

Member Data Documentation

◆ locked

template<typename T >
unsigned Freezable< T >::locked {0}
private

◆ value


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