diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2016-11-21 23:53:17 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2016-11-22 00:27:06 +0000 |
commit | 53749f10b873d23fd997949c5a664df1cedd3ff5 (patch) | |
tree | 0551eab0058e6e3c7c9083f4a0188b12a29154b7 /storageapi | |
parent | 84b04793f98cd6af2a7ca48e344bb48bbcf79727 (diff) |
Further ensure that we do not generate code for expensive methods more than once.
Diffstat (limited to 'storageapi')
9 files changed, 63 insertions, 48 deletions
diff --git a/storageapi/src/vespa/storageapi/message/CMakeLists.txt b/storageapi/src/vespa/storageapi/message/CMakeLists.txt index a263f495a1d..f48f40e5e82 100644 --- a/storageapi/src/vespa/storageapi/message/CMakeLists.txt +++ b/storageapi/src/vespa/storageapi/message/CMakeLists.txt @@ -14,5 +14,6 @@ vespa_add_library(storageapi_message OBJECT removelocation.cpp queryresult.cpp batch.cpp + internal.cpp DEPENDS ) diff --git a/storageapi/src/vespa/storageapi/message/internal.cpp b/storageapi/src/vespa/storageapi/message/internal.cpp new file mode 100644 index 00000000000..ecc332cf6a2 --- /dev/null +++ b/storageapi/src/vespa/storageapi/message/internal.cpp @@ -0,0 +1,45 @@ +// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#include "internal.h" + +namespace storage { +namespace api { + +InternalCommand::InternalCommand(uint32_t type) + : StorageCommand(MessageType::INTERNAL), + _type(type) +{ } + +InternalCommand::~InternalCommand() { } + +InternalReply::InternalReply(uint32_t type, const InternalCommand& cmd) + : StorageReply(cmd), + _type(type) +{ } + +InternalReply::~InternalReply() { } + +void +InternalCommand::print(std::ostream& out, bool verbose, const std::string& indent) const +{ + out << "InternalCommand(" << _type << ")"; + if (verbose) { + out << " : "; + StorageCommand::print(out, verbose, indent); + } +} + +void +InternalReply::print(std::ostream& out, bool verbose, const std::string& indent) const +{ + out << "InternalReply(" << _type << ")"; + if (verbose) { + out << " : "; + StorageReply::print(out, verbose, indent); + } +} + + +} // api +} // storage + diff --git a/storageapi/src/vespa/storageapi/message/internal.h b/storageapi/src/vespa/storageapi/message/internal.h index 9b92d956919..f2f1a1fe22d 100644 --- a/storageapi/src/vespa/storageapi/message/internal.h +++ b/storageapi/src/vespa/storageapi/message/internal.h @@ -32,23 +32,16 @@ class InternalCommand : public StorageCommand { uint32_t _type; public: - InternalCommand(uint32_t type) - : StorageCommand(MessageType::INTERNAL), _type(type) {} + InternalCommand(uint32_t type); + ~InternalCommand(); uint32_t getType() const { return _type; } - virtual bool callHandler(MessageHandler& h, - const std::shared_ptr<StorageMessage> & m) const - { + bool callHandler(MessageHandler& h, const std::shared_ptr<StorageMessage> & m) const override { return h.onInternal(std::static_pointer_cast<InternalCommand>(m)); } - /** - * Enforcing that subclasses implement print such that we can see what kind - * of message it is when debugging. - */ - virtual void print(std::ostream& out, bool verbose, - const std::string& indent) const = 0; + void print(std::ostream& out, bool verbose, const std::string& indent) const override; }; /** @@ -61,50 +54,18 @@ class InternalReply : public StorageReply { uint32_t _type; public: - InternalReply(uint32_t type, const InternalCommand& cmd) - : StorageReply(cmd), - _type(type) - { - } + InternalReply(uint32_t type, const InternalCommand& cmd); + ~InternalReply(); uint32_t getType() const { return _type; } - virtual bool callHandler(MessageHandler& h, - const std::shared_ptr<StorageMessage> & m) const - { + bool callHandler(MessageHandler& h, const std::shared_ptr<StorageMessage> & m) const override { return h.onInternalReply(std::static_pointer_cast<InternalReply>(m)); } - /** - * Enforcing that subclasses implement print such that we can see what kind - * of message it is when debugging. - */ - virtual void print(std::ostream& out, bool verbose, - const std::string& indent) const = 0; + void print(std::ostream& out, bool verbose, const std::string& indent) const override; }; -inline void -InternalCommand::print(std::ostream& out, bool verbose, - const std::string& indent) const -{ - out << "InternalCommand(" << _type << ")"; - if (verbose) { - out << " : "; - StorageCommand::print(out, verbose, indent); - } -} - -inline void -InternalReply::print(std::ostream& out, bool verbose, - const std::string& indent) const -{ - out << "InternalReply(" << _type << ")"; - if (verbose) { - out << " : "; - StorageReply::print(out, verbose, indent); - } -} - } // api } // storage diff --git a/storageapi/src/vespa/storageapi/messageapi/storagecommand.cpp b/storageapi/src/vespa/storageapi/messageapi/storagecommand.cpp index 015ed5154e1..65027712905 100644 --- a/storageapi/src/vespa/storageapi/messageapi/storagecommand.cpp +++ b/storageapi/src/vespa/storageapi/messageapi/storagecommand.cpp @@ -27,6 +27,8 @@ StorageCommand::StorageCommand(const MessageType& type, Priority p) setPriority(p); } +StorageCommand::~StorageCommand() { } + void StorageCommand::print(std::ostream& out, bool verbose, const std::string& indent) const diff --git a/storageapi/src/vespa/storageapi/messageapi/storagecommand.h b/storageapi/src/vespa/storageapi/messageapi/storagecommand.h index c71a5097bc4..73616936aec 100644 --- a/storageapi/src/vespa/storageapi/messageapi/storagecommand.h +++ b/storageapi/src/vespa/storageapi/messageapi/storagecommand.h @@ -31,7 +31,7 @@ protected: public: DECLARE_POINTER_TYPEDEFS(StorageCommand); - virtual ~StorageCommand() {} + virtual ~StorageCommand(); bool sourceIndexSet() const { return (_sourceIndex != 0xffff); } void setSourceIndex(uint16_t sourceIndex) { _sourceIndex = sourceIndex; } diff --git a/storageapi/src/vespa/storageapi/messageapi/storagemessage.cpp b/storageapi/src/vespa/storageapi/messageapi/storagemessage.cpp index c084106a3ab..bfdf56e63bd 100644 --- a/storageapi/src/vespa/storageapi/messageapi/storagemessage.cpp +++ b/storageapi/src/vespa/storageapi/messageapi/storagemessage.cpp @@ -214,6 +214,8 @@ StorageMessageAddress::StorageMessageAddress( _route.addHop(hop); } +StorageMessageAddress::~StorageMessageAddress() { } + uint16_t StorageMessageAddress::getIndex() const { diff --git a/storageapi/src/vespa/storageapi/messageapi/storagemessage.h b/storageapi/src/vespa/storageapi/messageapi/storagemessage.h index 4b16b78a796..afb394e6d8b 100644 --- a/storageapi/src/vespa/storageapi/messageapi/storagemessage.h +++ b/storageapi/src/vespa/storageapi/messageapi/storagemessage.h @@ -312,6 +312,7 @@ public: StorageMessageAddress(const vespalib::stringref & clusterName, const lib::NodeType& type, uint16_t index, Protocol protocol = STORAGE); + ~StorageMessageAddress(); void setProtocol(Protocol p) { _protocol = p; } void enableRetry(bool enable = true) { _retryEnabled = enable; } diff --git a/storageapi/src/vespa/storageapi/messageapi/storagereply.cpp b/storageapi/src/vespa/storageapi/messageapi/storagereply.cpp index aa473cd90a1..b44cdba1765 100644 --- a/storageapi/src/vespa/storageapi/messageapi/storagereply.cpp +++ b/storageapi/src/vespa/storageapi/messageapi/storagereply.cpp @@ -20,6 +20,8 @@ StorageReply::StorageReply(const StorageCommand& cmd, ReturnCode code) setTransportContext(cmd.getTransportContext()); } +StorageReply::~StorageReply() { } + void StorageReply::print(std::ostream& out, bool verbose, const std::string& indent) const diff --git a/storageapi/src/vespa/storageapi/messageapi/storagereply.h b/storageapi/src/vespa/storageapi/messageapi/storagereply.h index 65475335519..518c5474b34 100644 --- a/storageapi/src/vespa/storageapi/messageapi/storagereply.h +++ b/storageapi/src/vespa/storageapi/messageapi/storagereply.h @@ -28,6 +28,7 @@ protected: ReturnCode code = ReturnCode(ReturnCode::OK)); public: + ~StorageReply(); DECLARE_POINTER_TYPEDEFS(StorageReply); void setResult(const ReturnCode& r) { _result = r; } |