/** * @file include/ActivOneApi/Deprecated/ITopicQueryHandler.h * * @brief Header for the deprecated ITopicQueryHandler class. */ #if (!defined ACTIV_ONE_API_DEPRECATED_ITOPIC_QUERY_HANDLER_H) #define ACTIV_ONE_API_DEPRECATED_ITOPIC_QUERY_HANDLER_H #include "ActivOneApi/External.h" #include "ActivOneApi/IQueryHandler.h" #include "ActivOneApi/TopicId.h" #include "ActivOneApi/TypeDefinitions.h" #include "ActivOneApi/Constants/DataSourceIds.h" #include "ActivOneApi/Deprecated/Topic.h" #include "ActivOneApi/Messages/QueryAddMessage.h" #include "ActivOneApi/Messages/QueryRemoveMessage.h" #include "ActivOneApi/Messages/QueryStatusMessage.h" //! Activ namespace. namespace Activ { //! OneApi namespace. namespace OneApi { //! Deprecated namespace. namespace Deprecated { //! Deprecated symbol pattern query type. typedef QuerySymbolPattern TopicQuerySymbolPattern; //! Deprecated topic query handler interface class. class ITopicQueryHandler : public IQueryHandler { public: /** * @brief Callback on topic query start. * * The initial topic query synchronization has started for a new query or due to reconnect/failover. * * @param context the context for this event. */ virtual void OnTopicQueryStart(const Context &context) { } /** * @brief Callback on topic added. * * Note that the user can move the topic. * * @param topic the topic found or added. * @param context the context for this event. */ virtual void OnTopicQueryAdd(Topic &topic, const Context &context) { } /** * @brief Callback on topic removed. * * @param topicId id of the topic that has been deleted. * @param context the context for this event. */ virtual void OnTopicQueryRemove(const TopicId &topicId, const Context &context) { } /** * @brief Callback on topic query completion. * * The initial topic query synchronization is complete. Updates will continue to be received for new, deleted and updated * topics. * * @param context the context for this event. */ virtual void OnTopicQueryComplete(const Context &context) { } /** * @brief Callback on topic query error. * * The topic query synchronization has failed, probably due to a service disconnect. Synchronization will restart on reconnect. * * Status code values: * STATUS_CODE_NOT_CONNECTED if no connected resolver available for query. * * @param statusCode * @param context the context for this event. */ virtual void OnTopicQueryError(const StatusCode statusCode, const Context &context) { } /** * @brief Callback on failure to create the topic query. * * The topic query has failed and will not recover, the handle for this query will no longer be valid once this callback is * complete. * * @param statusCode * @param context the context for this event. */ virtual void OnTopicQueryFailure(const StatusCode statusCode, const Context &context) { } private: // Override the new IQueryHandler interface to provide the old behaviour. virtual void OnQueryAdd(const QueryAddMessage &message, const Context &context) ACTIV_OVERRIDE { Topic topic(message); OnTopicQueryAdd(topic, context); } virtual void OnQueryRemove(const QueryRemoveMessage &message, const Context &context) { OnTopicQueryRemove(TopicId(message.m_dataSourceId, message.m_tableNumber, ToStringType(message.m_symbol)), context); } virtual void OnQueryStatus(const QueryStatusMessage &message, const Context &context) { switch (message.m_state) { case QUERY_STATE_PENDING: OnTopicQueryStart(context); break; case QUERY_STATE_COMPLETE: OnTopicQueryComplete(context); break; case QUERY_STATE_ERROR: OnTopicQueryError(message.m_statusCode, context); break; case QUERY_STATE_FAILURE: OnTopicQueryFailure(message.m_statusCode, context); break; default: assert(false); return; } } }; } // namespace Deprecated } // namespace OneApi } // namespace Activ #endif // (!defined ACTIV_ONE_API_DEPRECATED_ITOPIC_QUERY_HANDLER_H)