summaryrefslogtreecommitdiff
path: root/plugins/WinterSpeak/src/Subject.h
blob: d3ae97fba670a389cec1e12a713ef1171517db43 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#pragma once

#include "Observer.h"

#include <list>
class Subject : private MNonCopyable
{
public:
    Subject();
    virtual ~Subject();

    //--------------------------------------------------------------------------
    // Description : Notify all observers of a state change
    //--------------------------------------------------------------------------
    void notify();

    //--------------------------------------------------------------------------
    // Description : Attach an observer to the subject
    // Parameters  : observer - the observer
    //--------------------------------------------------------------------------
    void attach(Observer &observer);

    //--------------------------------------------------------------------------
    // Description : Detach an observer from the subject
    // Parameters  : observer - the observer
    //--------------------------------------------------------------------------
    void detach(const Observer &observer);

  private:
    std::list<Observer *> m_observer_list;
};