Ref T259, Ref T243 adjusted providers to use common base classes

This commit is contained in:
Klaus Basan
2018-03-12 18:01:26 +01:00
parent d99a1cac87
commit 4b7237ce1b
21 changed files with 341 additions and 196 deletions

View File

@@ -9,19 +9,16 @@
#include "blackmisc/weather/weathergridprovider.h"
using namespace BlackMisc;
namespace BlackMisc
{
namespace Weather
{
void CWeatherGridAware::requestWeatherGrid(const BlackMisc::Weather::CWeatherGrid &weatherGrid,
const BlackMisc::CSlot<void(const BlackMisc::Weather::CWeatherGrid &)> &callback)
void CWeatherGridAware::requestWeatherGrid(
const CWeatherGrid &weatherGrid,
const CSlot<void(const CWeatherGrid &)> &callback)
{
Q_ASSERT_X(this->m_weatherGridProvider, Q_FUNC_INFO, "No object available");
this->m_weatherGridProvider->requestWeatherGrid(weatherGrid, callback);
Q_ASSERT_X(this->hasProvider(), Q_FUNC_INFO, "No object available");
this->provider()->requestWeatherGrid(weatherGrid, callback);
}
} // namespace
} // namespace

View File

@@ -12,16 +12,16 @@
#ifndef BLACKMISC_WEATHER_WEATHERGRIDPROVIDER_H
#define BLACKMISC_WEATHER_WEATHERGRIDPROVIDER_H
#include "blackmisc/weather/weathergrid.h"
#include "blackmisc/provider.h"
#include "blackmisc/blackmiscexport.h"
#include "blackmisc/slot.h"
#include "blackmisc/weather/weathergrid.h"
#include <QObject>
#include <QtGlobal>
namespace BlackMisc
{
namespace Weather
{
//! Direct threadsafe in memory access to weather grid
@@ -29,24 +29,22 @@ namespace BlackMisc
{
public:
//! Request weather grid
virtual void requestWeatherGrid(const BlackMisc::Weather::CWeatherGrid &weatherGrid,
const BlackMisc::CSlot<void(const BlackMisc::Weather::CWeatherGrid &)> &callback) = 0;
virtual void requestWeatherGrid(const CWeatherGrid &weatherGrid,
const CSlot<void(const CWeatherGrid &)> &callback) = 0;
};
//! Delegating class which can be directly used to access an \sa IWeatherGridProvider instance
class BLACKMISC_EXPORT CWeatherGridAware
class BLACKMISC_EXPORT CWeatherGridAware : public IProviderAware<IWeatherGridProvider>
{
public:
//! \copydoc IWeatherGridProvider::requestWeatherGrid
virtual void requestWeatherGrid(const BlackMisc::Weather::CWeatherGrid &weatherGrid,
const BlackMisc::CSlot<void(const BlackMisc::Weather::CWeatherGrid &)> &callback);
virtual void requestWeatherGrid(const CWeatherGrid &weatherGrid,
const CSlot<void(const CWeatherGrid &)> &callback);
protected:
//! Constructor
CWeatherGridAware(IWeatherGridProvider *weatherGridProvider) : m_weatherGridProvider(weatherGridProvider) { Q_ASSERT(weatherGridProvider); }
IWeatherGridProvider *m_weatherGridProvider = nullptr; //!< access to object
CWeatherGridAware(IWeatherGridProvider *weatherGridProvider) : IProviderAware(weatherGridProvider) { Q_ASSERT(weatherGridProvider); }
};
} // namespace
} // namespace