summaryrefslogtreecommitdiff
path: root/plugins/WinterSpeak/src/Subject.h
blob: 99fbba4dd7fd14343abbea2d81cb49ee893d9e33 (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
33
34
35
36
37
38
#pragma once

#include "Observer.h"

#include <list>
class Subject
{
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:
    //--------------------------------------------------------------------------
    // Description : Disallow assignment operator and copy constructor
    //--------------------------------------------------------------------------
    Subject(const Subject &rhs);
    const Subject & operator=(const Subject &rhs);

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