-
Notifications
You must be signed in to change notification settings - Fork 10
/
WeatherData.hpp
44 lines (31 loc) · 899 Bytes
/
WeatherData.hpp
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
39
40
41
42
43
44
//
// Created by shan on 4/7/17.
//
#ifndef OBSERVER_PATTERN_WEATHERDATA_HPP
#define OBSERVER_PATTERN_WEATHERDATA_HPP
#include <vector>
#include <algorithm>
#include <iostream>
#include "Subject.hpp"
#include "Observer.hpp"
/**
* A concrete implementation of the Subject interface
*/
class WeatherData : public Subject {
std::vector<Observer *> observers; // observers
float temp = 0.0f;
float humidity = 0.0f;
float pressure = 0.0f;
public:
void registerObserver(Observer *observer) override;
void removeObserver(Observer *observer) override;
void notifyObservers() override;
/**
* Set the new state of the weather station
* @param temp new temperature
* @param humidity new humidity
* @param pressure new pressure
*/
void setState(float temp, float humidity, float pressure);
};
#endif //OBSERVER_PATTERN_WEATHERDATA_HPP