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