// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. /** * @class storage::api::MessageHandler * @ingroup messageapi * * @brief Class to prevent manual casting and switches of message types. * * MessageHandler defines an interface for processing StorageMessage objects * of various subclasses. * * @version $Id$ */ #pragma once #include namespace storage::api { // Commands class GetCommand; // Retrieve document class PutCommand; // Add document class UpdateCommand; // Update document class RemoveCommand; // Remove document class CreateVisitorCommand; // Create a new visitor class DestroyVisitorCommand; // Destroy a running visitor class VisitorInfoCommand; // Sends visitor info to visitor controller class MapVisitorCommand; class QueryResultCommand; class InternalCommand; class CreateBucketCommand; class DeleteBucketCommand; class MergeBucketCommand; class GetBucketDiffCommand; class ApplyBucketDiffCommand; class SplitBucketCommand; class JoinBucketsCommand; class SetBucketStateCommand; class RequestBucketInfoCommand; class NotifyBucketChangeCommand; class SetNodeStateCommand; class GetNodeStateCommand; class SetSystemStateCommand; class ActivateClusterStateVersionCommand; class ActivateClusterStateVersionReply; class GetSystemStateCommand; class BucketsAddedCommand; class BucketsRemovedCommand; // Replies class GetReply; class PutReply; class UpdateReply; class RemoveReply; class CreateVisitorReply; class DestroyVisitorReply; class VisitorInfoReply; class MapVisitorReply; class QueryResultReply; class InternalReply; class CreateBucketReply; class DeleteBucketReply; class MergeBucketReply; class GetBucketDiffReply; class ApplyBucketDiffReply; class SplitBucketReply; class JoinBucketsReply; class SetBucketStateReply; class RequestBucketInfoReply; class NotifyBucketChangeReply; class SetNodeStateReply; class GetNodeStateReply; class SetSystemStateReply; class GetSystemStateReply; class BucketsAddedReply; class BucketsRemovedReply; class StatBucketCommand; class StatBucketReply; class GetBucketListCommand; class GetBucketListReply; class EmptyBucketsCommand; class EmptyBucketsReply; class RemoveLocationCommand; class RemoveLocationReply; #define _INTERNAL_DEF_ON_MC(m, c) bool m(const std::shared_ptr & ) override #define _INTERNAL_DEF_IMPL_ON_MC(m, c) bool m(const std::shared_ptr & ) override { return false; } #define _INTERNAL_IMPL_ON_MC(cl, m, c, p) bool cl::m(const std::shared_ptr & p) #define DEF_IMPL_MSG_COMMAND_H(m) _INTERNAL_DEF_IMPL_ON_MC(on##m, m##Command) #define DEF_IMPL_MSG_REPLY_H(m) _INTERNAL_DEF_IMPL_ON_MC(on##m##Reply, m##Reply) #define DEF_MSG_COMMAND_H(m) _INTERNAL_DEF_ON_MC(on##m, m##Command) #define DEF_MSG_REPLY_H(m) _INTERNAL_DEF_ON_MC(on##m##Reply, m##Reply) #define IMPL_MSG_COMMAND_ARG_H(cl, m, p) _INTERNAL_IMPL_ON_MC(cl, on##m, m##Command, p) #define IMPL_MSG_REPLY_ARG_H(cl, m, p) _INTERNAL_IMPL_ON_MC(cl, on##m##Reply, m##Reply, p) #define IMPL_MSG_COMMAND_H(cl, m) IMPL_MSG_COMMAND_ARG_H(cl, m, cmd) #define IMPL_MSG_REPLY_H(cl, m) IMPL_MSG_REPLY_ARG_H(cl, m, reply) #define ON_M(m) DEF_IMPL_MSG_COMMAND_H(m); DEF_IMPL_MSG_REPLY_H(m) class MessageHandler { public: // Basic operations virtual bool onGet(const std::shared_ptr&) { return false; } virtual bool onGetReply(const std::shared_ptr&) { return false; } virtual bool onPut(const std::shared_ptr&) { return false; } virtual bool onPutReply(const std::shared_ptr&) { return false; } virtual bool onUpdate(const std::shared_ptr&) { return false; } virtual bool onUpdateReply(const std::shared_ptr&) { return false; } virtual bool onRemove(const std::shared_ptr&) { return false; } virtual bool onRemoveReply(const std::shared_ptr&) { return false; } virtual bool onCreateVisitor(const std::shared_ptr&) { return false; } virtual bool onCreateVisitorReply(const std::shared_ptr&) { return false; } virtual bool onDestroyVisitor(const std::shared_ptr&) { return false; } virtual bool onDestroyVisitorReply(const std::shared_ptr&) { return false; } virtual bool onVisitorInfo(const std::shared_ptr&) { return false; } virtual bool onVisitorInfoReply(const std::shared_ptr&) { return false; } virtual bool onMapVisitor(const std::shared_ptr&) { return false; } virtual bool onMapVisitorReply(const std::shared_ptr&) { return false; } virtual bool onQueryResult(const std::shared_ptr&) { return false; } virtual bool onQueryResultReply(const std::shared_ptr&) { return false; } virtual bool onEmptyBuckets(const std::shared_ptr&) { return false; } virtual bool onEmptyBucketsReply(const std::shared_ptr&) { return false; } virtual bool onInternal(const std::shared_ptr&) { return false; } virtual bool onInternalReply(const std::shared_ptr&) { return false; } virtual bool onCreateBucket(const std::shared_ptr&) { return false; } virtual bool onCreateBucketReply(const std::shared_ptr&) { return false; } virtual bool onDeleteBucket(const std::shared_ptr&) { return false; } virtual bool onDeleteBucketReply(const std::shared_ptr&) { return false; } virtual bool onMergeBucket(const std::shared_ptr&) { return false; } virtual bool onMergeBucketReply(const std::shared_ptr&) { return false; } virtual bool onGetBucketDiff(const std::shared_ptr&) { return false; } virtual bool onGetBucketDiffReply(const std::shared_ptr&) { return false; } virtual bool onApplyBucketDiff(const std::shared_ptr&) { return false; } virtual bool onApplyBucketDiffReply(const std::shared_ptr&) { return false; } virtual bool onSplitBucket(const std::shared_ptr&) { return false; } virtual bool onSplitBucketReply(const std::shared_ptr&) { return false; } virtual bool onJoinBuckets(const std::shared_ptr&) { return false; } virtual bool onJoinBucketsReply(const std::shared_ptr&) { return false; } virtual bool onSetBucketState(const std::shared_ptr&) { return false; } virtual bool onSetBucketStateReply(const std::shared_ptr&) { return false; } virtual bool onRequestBucketInfo(const std::shared_ptr&) { return false; } virtual bool onRequestBucketInfoReply(const std::shared_ptr&) { return false; } virtual bool onNotifyBucketChange(const std::shared_ptr&) { return false; } virtual bool onNotifyBucketChangeReply(const std::shared_ptr&) { return false; } virtual bool onSetNodeState(const std::shared_ptr&) { return false; } virtual bool onSetNodeStateReply(const std::shared_ptr&) { return false; } virtual bool onGetNodeState(const std::shared_ptr&) { return false; } virtual bool onGetNodeStateReply(const std::shared_ptr&) { return false; } virtual bool onSetSystemState(const std::shared_ptr&) { return false; } virtual bool onSetSystemStateReply(const std::shared_ptr&) { return false; } virtual bool onActivateClusterStateVersion(const std::shared_ptr&) { return false; } virtual bool onActivateClusterStateVersionReply(const std::shared_ptr&) { return false; } virtual bool onGetSystemState(const std::shared_ptr&) { return false; } virtual bool onGetSystemStateReply(const std::shared_ptr&) { return false; } virtual bool onBucketsAdded(const std::shared_ptr&) { return false; } virtual bool onBucketsAddedReply(const std::shared_ptr&) { return false; } virtual bool onBucketsRemoved(const std::shared_ptr&) { return false; } virtual bool onBucketsRemovedReply(const std::shared_ptr&) { return false; } virtual bool onStatBucket(const std::shared_ptr&) { return false; } virtual bool onStatBucketReply(const std::shared_ptr&) { return false; } virtual bool onGetBucketList(const std::shared_ptr&) { return false; } virtual bool onGetBucketListReply(const std::shared_ptr&) { return false; } virtual bool onRemoveLocation(const std::shared_ptr&) { return false; } virtual bool onRemoveLocationReply(const std::shared_ptr&) { return false; } virtual ~MessageHandler() = default; }; #undef ON_M }