Back to index

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

A read/write property that stores the value type. More...

#include <Property.h>

Inheritance diagram for nux::Property< VALUE_TYPE >:
Inheritance graph
[legend]
Collaboration diagram for nux::Property< 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 &, VALUE_TYPE const & > 
SetterFunction

Public Member Functions

 Property ()
 Property (VALUE_TYPE const &initial)
 Property (VALUE_TYPE const &initial, 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 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

 Property (Property const &)
Propertyoperator= (Property const &)
bool DefaultSetter (VALUE_TYPE &target, VALUE_TYPE const &value)

Private Attributes

VALUE_TYPE value_
SetterFunction setter_function_

Detailed Description

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

A read/write property that stores the value type.

The default setter emits the changed event if and only if the value changes. A custom setter can be provided by passing in a setter function using sigc::mem_fun or sigc::ptr_fun.

Definition at line 66 of file Property.h.


Member Typedef Documentation

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

Definition at line 71 of file Property.h.

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

Definition at line 70 of file Property.h.

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

Reimplemented in nux::SerializableProperty< VALUE_TYPE >.

Definition at line 69 of file Property.h.


Constructor & Destructor Documentation

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

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

  : value_(VALUE_TYPE())
  , setter_function_(sigc::mem_fun(this, &Property<VALUE_TYPE>::DefaultSetter))
{}
template<typename VALUE_TYPE>
nux::Property< VALUE_TYPE >::Property ( VALUE_TYPE const &  initial) [explicit]

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

  : value_(initial)
  , setter_function_(sigc::mem_fun(this, &Property<VALUE_TYPE>::DefaultSetter))
{}
template<typename VALUE_TYPE>
nux::Property< VALUE_TYPE >::Property ( VALUE_TYPE const &  initial,
SetterFunction  setter_function 
)

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

  : value_(initial)
  , setter_function_(setter_function)
{}
template<typename VALUE_TYPE>
nux::Property< VALUE_TYPE >::Property ( Property< VALUE_TYPE > const &  ) [private]

Member Function Documentation

template<typename VALUE_TYPE>
bool nux::Property< VALUE_TYPE >::DefaultSetter ( VALUE_TYPE &  target,
VALUE_TYPE const &  value 
) [private]

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

{
  bool changed = false;
  if (target != value) {
    target = value;
    changed = true;
  }
  return changed;
}
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::Property< VALUE_TYPE >::Get ( ) const

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

{
  return value_;
}
template<typename VALUE_TYPE >
nux::Property< VALUE_TYPE >::operator VALUE_TYPE ( ) const

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

{
  return value_;
}
template<typename VALUE_TYPE >
VALUE_TYPE nux::Property< VALUE_TYPE >::operator() ( ) const

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

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

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

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

Reimplemented in nux::SerializableProperty< VALUE_TYPE >.

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

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

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

template<typename VALUE_TYPE >
void nux::Property< VALUE_TYPE >::SetSetterFunction ( SetterFunction  setter_function)

Definition at line 123 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>
SetterFunction nux::Property< VALUE_TYPE >::setter_function_ [private]

Definition at line 99 of file Property.h.

template<typename VALUE_TYPE>
VALUE_TYPE nux::Property< VALUE_TYPE >::value_ [private]

Definition at line 98 of file Property.h.


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