#include <observer.h>
Public Types | |
| typedef int | priority_t |
Public Member Functions | |
| IObserver () | |
| virtual void | notify (boost::shared_ptr< T > newValue, boost::shared_ptr< const IChangeContext< T > > context) const =0 throw () |
| virtual priority_t | getPriority () const =0 throw () |
| bool | setActive (bool active) |
| bool | isActive () const |
| virtual | ~IObserver () throw () |
Private Attributes | |
| bool | active |
Observer interface (pure abstract class).
Observer is mechanism how to be informed that somethig has changed. Implementator of this interface produces handler for this change event.
This should be used in following way:
Interface is template to enable different value types to be used (type parameter stands for value type to be managed - informed about change). This enables only one type to be handled by one implementator (with all subtypes).
Value change handling is done in notify method (see for more details). This method is called after value has been changed.
Each observer implementation has its priority which is used be value keeper to determine order in which to notify obsevers, if there is more then one.
Observer can be in active/inactive state depending on the active flag value. See setActive, isActive methods.
Exception NOTE: No method throws an exception.
| typedef int observer::IObserver< T >::priority_t |
Type for priority.
| observer::IObserver< T >::IObserver | ( | ) | [inline] |
Default constructor.
| virtual observer::IObserver< T >::~IObserver | ( | ) | throw () [inline, virtual] |
Virtual destructor.
| virtual priority_t observer::IObserver< T >::getPriority | ( | ) | const throw () [pure virtual] |
Returns priority of obsever.
Lower number means higher priority.
Implemented in pdfobjects::CContentStream::CStreamObserver, pdfobjects::CContentStream::OperandObserver, pdfobjects::CPageAnnots::PropWatchDog, pdfobjects::CPageAnnots::ArrayWatchDog, pdfobjects::CPageContents::ContentsWatchDog, pdfobjects::CPdf::PageTreeRootObserver, pdfobjects::CPdf::PageTreeNodeObserver, pdfobjects::CPdf::PageTreeKidsObserver, pdfobjects::utils::ProgressObserver, gui::TreeItemGenericObserver< ObservedItem >, gui::TreeItemGenericObserver< pdfobjects::IProperty >, gui::TreeItemGenericObserver< pdfobjects::CContentStream >, and gui::TreeItemGenericObserver< pdfobjects::CPage >.
| bool observer::IObserver< T >::isActive | ( | ) | const [inline] |
Returns current value of the active flag.
| virtual void observer::IObserver< T >::notify | ( | boost::shared_ptr< T > | newValue, | |
| boost::shared_ptr< const IChangeContext< T > > | context | |||
| ) | const throw () [pure virtual] |
Notify method.
| newValue | New value of changed value or its part. | |
| context | Value change context. |
Each time value keeper, which implements ObserverHandler, changes value (or its part), all registered observers are notified about that by this method calling.
newValue stands for new value or its part (if value is complex).
contex contains additional information about change. It depends on value keeper which information is provided (if any). It may be NULL (value stored in shared_ptr may be NULL - more precisely - use contex.get()==NULL condition for checking) which means that no information is provided. Method implementator should check context type (using getType() method). Accoring this type cast to correct IChangeContext subclass and use information.
Example:
Lets say that T is IProperty. If observer is registered on simple type, newValue contains new value of this simple one. If it is registered on complex type, it contains changed value (item) inside this complex type (value keeper part is changed).
Implemented in gui::TreeItemGenericObserver< ObservedItem >.
| bool observer::IObserver< T >::setActive | ( | bool | active | ) | [inline] |
Sets active flag value.
| active | Flag value to be set. |
bool observer::IObserver< T >::active [private] |
Active flag. Observer is ignored by observer handler if it is false.
Referenced by observer::IObserver< ObservedItem >::isActive().