Back to index

nux  3.0.0
Public Types | Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
nux::RWProperty< VALUE_TYPE > Class Template Reference

A read/write property that uses a functions to get and set the value. More...

#include <Property.h>

Inheritance diagram for nux::RWProperty< VALUE_TYPE >:
Inheritance graph
[legend]
Collaboration diagram for nux::RWProperty< VALUE_TYPE >:
Collaboration graph
[legend]

List of all members.

Public Types

typedef VALUE_TYPE ValueType
typedef PropertyChangedSignal
< VALUE_TYPE > 
SignalBase
typedef sigc::slot< bool,
VALUE_TYPE const & > 
SetterFunction
typedef sigc::slot< VALUE_TYPE > GetterFunction

Public Member Functions

 RWProperty ()
 RWProperty (GetterFunction getter_function, SetterFunction setter_function)
VALUE_TYPE operator= (VALUE_TYPE const &value)
 operator VALUE_TYPE () const
VALUE_TYPE operator() () const
VALUE_TYPE operator() (VALUE_TYPE const &value)
VALUE_TYPE Get () const
VALUE_TYPE Set (VALUE_TYPE const &value)
void SetGetterFunction (GetterFunction getter_function)
void SetSetterFunction (SetterFunction setter_function)
void DisableNotifications ()
void EnableNotifications ()
void EmitChanged (VALUE_TYPE const &new_value)

Public Attributes

sigc::signal< void, VALUE_TYPE
const & > 
changed

Private Member Functions

 RWProperty (RWProperty const &)
RWPropertyoperator= (RWProperty const &)
VALUE_TYPE DefaultGetter () const
bool DefaultSetter (VALUE_TYPE const &value)

Private Attributes

GetterFunction getter_function_
SetterFunction setter_function_

Detailed Description

template<typename VALUE_TYPE>
class nux::RWProperty< VALUE_TYPE >

A read/write property that uses a functions to get and set the value.

The value type is not stored in the propery, but maintained by the setter and getter functions.

A changed signal is emitted if the setter function specifies that the value has changed.

The default setter does nothing and emits no signal, and the default getter returns a default constructed VALUE_TYPE. The default getter and setter should be overridden through either the constructor args or through the SetGetterFunction / SetSetterFunction.

Definition at line 152 of file Property.h.


Member Typedef Documentation

template<typename VALUE_TYPE>
typedef sigc::slot<VALUE_TYPE> nux::RWProperty< VALUE_TYPE >::GetterFunction

Definition at line 158 of file Property.h.

template<typename VALUE_TYPE>
typedef sigc::slot<bool, VALUE_TYPE const&> nux::RWProperty< VALUE_TYPE >::SetterFunction

Definition at line 157 of file Property.h.

template<typename VALUE_TYPE>
typedef PropertyChangedSignal<VALUE_TYPE> nux::RWProperty< VALUE_TYPE >::SignalBase

Definition at line 156 of file Property.h.

template<typename VALUE_TYPE>
typedef VALUE_TYPE nux::RWProperty< VALUE_TYPE >::ValueType

Definition at line 155 of file Property.h.


Constructor & Destructor Documentation

template<typename VALUE_TYPE >
nux::RWProperty< VALUE_TYPE >::RWProperty ( )

Definition at line 171 of file Property-inl.h.

  : getter_function_(sigc::mem_fun(this, &RWProperty<VALUE_TYPE>::DefaultGetter))
  , setter_function_(sigc::mem_fun(this, &RWProperty<VALUE_TYPE>::DefaultSetter))
{}
template<typename VALUE_TYPE >
nux::RWProperty< VALUE_TYPE >::RWProperty ( GetterFunction  getter_function,
SetterFunction  setter_function 
)

Definition at line 177 of file Property-inl.h.

  : getter_function_(getter_function)
  , setter_function_(setter_function)
{}
template<typename VALUE_TYPE>
nux::RWProperty< VALUE_TYPE >::RWProperty ( RWProperty< VALUE_TYPE > const &  ) [private]

Member Function Documentation

template<typename VALUE_TYPE >
VALUE_TYPE nux::RWProperty< VALUE_TYPE >::DefaultGetter ( ) const [private]

Definition at line 226 of file Property-inl.h.

{
  return VALUE_TYPE();
}
template<typename VALUE_TYPE >
bool nux::RWProperty< VALUE_TYPE >::DefaultSetter ( VALUE_TYPE const &  value) [private]

Definition at line 232 of file Property-inl.h.

{
  return false;
}
template<typename VALUE_TYPE >
void nux::PropertyChangedSignal< VALUE_TYPE >::DisableNotifications ( ) [inherited]

Definition at line 34 of file Property-inl.h.

{
  notify_ = false;
}
template<typename VALUE_TYPE>
void nux::PropertyChangedSignal< VALUE_TYPE >::EmitChanged ( VALUE_TYPE const &  new_value) [inherited]

Definition at line 46 of file Property-inl.h.

{
  if (notify_)
    changed.emit(new_value);
}
template<typename VALUE_TYPE >
void nux::PropertyChangedSignal< VALUE_TYPE >::EnableNotifications ( ) [inherited]

Definition at line 40 of file Property-inl.h.

{
  notify_ = true;
}
template<typename VALUE_TYPE >
VALUE_TYPE nux::RWProperty< VALUE_TYPE >::Get ( ) const

Definition at line 208 of file Property-inl.h.

{
  return getter_function_();
}
template<typename VALUE_TYPE >
nux::RWProperty< VALUE_TYPE >::operator VALUE_TYPE ( ) const

Definition at line 190 of file Property-inl.h.

{
  return getter_function_();
}
template<typename VALUE_TYPE >
VALUE_TYPE nux::RWProperty< VALUE_TYPE >::operator() ( ) const

Definition at line 196 of file Property-inl.h.

{
  return getter_function_();
}
template<typename VALUE_TYPE >
VALUE_TYPE nux::RWProperty< VALUE_TYPE >::operator() ( VALUE_TYPE const &  value)

Definition at line 202 of file Property-inl.h.

{
  return Set(value);
}
template<typename VALUE_TYPE >
VALUE_TYPE nux::RWProperty< VALUE_TYPE >::operator= ( VALUE_TYPE const &  value)

Definition at line 184 of file Property-inl.h.

{
  return Set(value);
}
template<typename VALUE_TYPE>
RWProperty& nux::RWProperty< VALUE_TYPE >::operator= ( RWProperty< VALUE_TYPE > const &  ) [private]
template<typename VALUE_TYPE >
VALUE_TYPE nux::RWProperty< VALUE_TYPE >::Set ( VALUE_TYPE const &  value)

Definition at line 214 of file Property-inl.h.

{
  if (setter_function_(value))
  {
    VALUE_TYPE new_value = getter_function_();
    SignalBase::EmitChanged(new_value);
    return new_value;
  }
  return getter_function_();
}
template<typename VALUE_TYPE >
void nux::RWProperty< VALUE_TYPE >::SetGetterFunction ( GetterFunction  getter_function)

Definition at line 244 of file Property-inl.h.

{
  getter_function_ = getter_function;
}
template<typename VALUE_TYPE >
void nux::RWProperty< VALUE_TYPE >::SetSetterFunction ( SetterFunction  setter_function)

Definition at line 238 of file Property-inl.h.

{
  setter_function_ = setter_function;
}

Member Data Documentation

template<typename VALUE_TYPE>
sigc::signal<void, VALUE_TYPE const&> nux::PropertyChangedSignal< VALUE_TYPE >::changed [inherited]

Definition at line 47 of file Property.h.

template<typename VALUE_TYPE>
GetterFunction nux::RWProperty< VALUE_TYPE >::getter_function_ [private]

Definition at line 186 of file Property.h.

template<typename VALUE_TYPE>
SetterFunction nux::RWProperty< VALUE_TYPE >::setter_function_ [private]

Definition at line 187 of file Property.h.


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