diff --git a/src/domain/livequery.h b/src/domain/livequery.h --- a/src/domain/livequery.h +++ b/src/domain/livequery.h @@ -29,21 +29,54 @@ namespace Domain { +template +class LiveQueryInput +{ +public: + typedef QSharedPointer> Ptr; + typedef QWeakPointer> WeakPtr; + typedef QList List; + typedef QList WeakList; + + typedef std::function AddFunction; + typedef std::function FetchFunction; + typedef std::function PredicateFunction; + + virtual ~LiveQueryInput() {} + + virtual void reset() = 0; + virtual void onAdded(const InputType &input) = 0; + virtual void onChanged(const InputType &input) = 0; + virtual void onRemoved(const InputType &input) = 0; +}; + +template +class LiveQueryOutput +{ +public: + typedef QSharedPointer> Ptr; + typedef QList List; + typedef QueryResult Result; + + virtual ~LiveQueryOutput() {} + virtual typename Result::Ptr result() = 0; + virtual void reset() = 0; +}; template -class LiveQuery +class LiveQuery : public LiveQueryInput, public LiveQueryOutput { public: typedef QSharedPointer> Ptr; typedef QList List; typedef QueryResultProvider Provider; typedef QueryResult Result; - typedef std::function AddFunction; + typedef typename LiveQueryInput::AddFunction AddFunction; + typedef typename LiveQueryInput::FetchFunction FetchFunction; + typedef typename LiveQueryInput::PredicateFunction PredicateFunction; - typedef std::function FetchFunction; - typedef std::function PredicateFunction; typedef std::function ConvertFunction; typedef std::function UpdateFunction; typedef std::function RepresentsFunction; @@ -53,7 +86,7 @@ clear(); } - typename Result::Ptr result() + typename Result::Ptr result() Q_DECL_OVERRIDE { typename Provider::Ptr provider(m_provider.toStrongRef()); @@ -93,13 +126,13 @@ m_represents = represents; } - void reset() + void reset() Q_DECL_OVERRIDE { clear(); doFetch(); } - void onAdded(const InputType &input) + void onAdded(const InputType &input) Q_DECL_OVERRIDE { typename Provider::Ptr provider(m_provider.toStrongRef()); @@ -110,7 +143,7 @@ addToProvider(provider, input); } - void onChanged(const InputType &input) + void onChanged(const InputType &input) Q_DECL_OVERRIDE { typename Provider::Ptr provider(m_provider.toStrongRef()); @@ -143,7 +176,7 @@ } } - void onRemoved(const InputType &input) + void onRemoved(const InputType &input) Q_DECL_OVERRIDE { typename Provider::Ptr provider(m_provider.toStrongRef());