1 | // This file is part of the PACPUS framework distributed under the
|
---|
2 | // CECILL-C License, Version 1.0.
|
---|
3 | //
|
---|
4 | /// @file
|
---|
5 | /// @author Stephane Bonnet <firstname.surname@utc.fr>
|
---|
6 | /// @date October, 2012
|
---|
7 | /// @version $Id: GenericObserverInterface.h 66 2013-01-09 16:54:11Z kurdejma $
|
---|
8 | /// @copyright Copyright (c) UTC/CNRS Heudiasyc 2006 - 2013. All rights reserved.
|
---|
9 | /// @brief Brief description.
|
---|
10 | ///
|
---|
11 | /// Detailed description.
|
---|
12 |
|
---|
13 | #ifndef DEF_PACPUS_GENERIC_OBSERVER_INTERFACE_H
|
---|
14 | #define DEF_PACPUS_GENERIC_OBSERVER_INTERFACE_H
|
---|
15 |
|
---|
16 | namespace pacpus {
|
---|
17 |
|
---|
18 | /** Base class for te GenericObserverInterface template.
|
---|
19 |
|
---|
20 | The purpose of this class is to be able to take generic pointers on
|
---|
21 | GenericObserverInterface<T> class template instances.
|
---|
22 | */
|
---|
23 | class GenericObserverBase {
|
---|
24 | public:
|
---|
25 | virtual ~GenericObserverBase() {}
|
---|
26 | };
|
---|
27 |
|
---|
28 | /** Template interface for generic observers.
|
---|
29 |
|
---|
30 | This is a pure virtual class that should be used as a base to classes
|
---|
31 | wishing to receive notifications from GenericObservable classes.
|
---|
32 | */
|
---|
33 | template <typename T>
|
---|
34 | class GenericObserverInterface : public GenericObserverBase {
|
---|
35 | public:
|
---|
36 | virtual ~GenericObserverInterface() {};
|
---|
37 |
|
---|
38 | /** Update function.
|
---|
39 |
|
---|
40 | This function is called each time the observables notifies its observers
|
---|
41 | of a change. It must be implemented by all classes obeying the
|
---|
42 | GenericObserverInterface interface.
|
---|
43 |
|
---|
44 | @param observable is a pointer to the observed object that was updated.
|
---|
45 | */
|
---|
46 | virtual void update(T* observable) = 0;
|
---|
47 | };
|
---|
48 |
|
---|
49 | } // namespace pacpus
|
---|
50 |
|
---|
51 |
|
---|
52 | #endif // DEF_PACPUS_GENERIC_OBSERVER_INTERFACE_H |
---|