예제 #1
0
void CStatsDisplay::Update(CWeatherData const & subject)
{
	m_inStats.temperatureStats.Update(subject.GetTemperature());
	m_inStats.humidityStats.Update(subject.GetHumidity());
	m_inStats.pressureStats.Update(subject.GetPressure());

	PrintWeatherData();
}
예제 #2
0
파일: main.cpp 프로젝트: bogdanov-d-a/ood
int main()
{
	CWeatherData wdIndoor;
	CWeatherWindData wdOutdoor;

	const auto senderNameProvider = [](boost::variant<IObservable<SWeatherInfo>&, IObservable<SWeatherInfoWind>&> sender) {
		return sender.apply_visitor(SenderNameProviderVisitor());
	};

	CDisplay display(senderNameProvider);
	wdIndoor.RegisterObserver(display.GetBasicObserver(), 0);
	wdOutdoor.RegisterObserver(display.GetWindObserver(), 0);

	CStatsDisplay statsDisplay(senderNameProvider);
	wdIndoor.RegisterObserver(statsDisplay.GetBasicObserver(), 0);
	wdOutdoor.RegisterObserver(statsDisplay.GetWindObserver(), 0);

	wdOutdoor.SetMeasurements(3, 0.7, 760, 2, 0);
	wdIndoor.SetMeasurements(15, 0.5, 762);
	wdOutdoor.SetMeasurements(4, 0.8, 761, 3, 10);
	wdIndoor.SetMeasurements(16, 0.6, 763);

	wdIndoor.RemoveObserver(statsDisplay.GetBasicObserver());
	wdOutdoor.RemoveObserver(display.GetWindObserver());

	wdOutdoor.SetMeasurements(10, 0.8, 761, 5, 100);
	wdIndoor.SetMeasurements(20, 0.6, 763);
	wdOutdoor.SetMeasurements(-10, 0.8, 761, 7, 145);
	wdIndoor.SetMeasurements(22, 0.6, 763);

	return 0;
}
예제 #3
0
int main()
{
	CWeatherData wdIn;
	CProWeatherData wdOut;

	CStatsDisplay statsDisplay(wdIn, wdOut);
	wdIn.SetMeasurements(7.1, 2.5, 760);
	wdOut.SetMeasurements(-5.5, 3.5, 765, 2.2, 60);

	CDisplay display(wdIn, wdOut);
	wdIn.SetMeasurements(17.2, 10.3, 760);
	wdOut.SetMeasurements(-6.5, 3.5, 765, 2.2, 60);

	return 0;
}
예제 #4
0
int main()
{
	CWeatherData wd;

	CDisplay display;
	wd.RegisterObserver(display);

	CStatsDisplay statsDisplay;
	wd.RegisterObserver(statsDisplay);

	wd.SetMeasurements(3, 0.7, 760);
	wd.SetMeasurements(4, 0.8, 761);

	wd.RemoveObserver(statsDisplay);

	wd.SetMeasurements(10, 0.8, 761);
	wd.SetMeasurements(-10, 0.8, 761);
	return 0;
}