Last active
July 22, 2018 18:32
-
-
Save gayashanbc/6de4f00d684083f42804c4ab19436d7f to your computer and use it in GitHub Desktop.
Header file of the Subject class (Observer Pattern in C++)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Created by shan on 4/7/17. | |
// | |
#ifndef OBSERVER_PATTERN_SUBJECT_HPP | |
#define OBSERVER_PATTERN_SUBJECT_HPP | |
#include "Observer.hpp" | |
/** | |
* Interface for the Subject | |
*/ | |
class Subject { | |
public: | |
/** | |
* Register an observer | |
* @param observer the observer object to be registered | |
*/ | |
virtual void registerObserver(Observer *observer) = 0; | |
/** | |
* Unregister an observer | |
* @param observer the observer object to be unregistered | |
*/ | |
virtual void removeObserver(Observer *observer) = 0; | |
/** | |
* Notify all the registered observers when a change happens | |
*/ | |
virtual void notifyObservers() = 0; | |
}; | |
#endif //OBSERVER_PATTERN_SUBJECT_HPP |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment