summaryrefslogtreecommitdiffstats
path: root/storageapi/src/vespa/storageapi/mbusprot/storagecommand.h
blob: bf5174f8f6203f7d5ea6d04f8414c71833dfb55d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once

#include "storagemessage.h"
#include "storageprotocol.h"
#include <vespa/messagebus/message.h>
#include <vespa/storageapi/messageapi/storagecommand.h>

namespace storage {
namespace mbusprot {

class StorageCommand : public mbus::Message, public StorageMessage {
public:
    typedef std::unique_ptr<StorageCommand> UP;

    StorageCommand(const storage::api::StorageCommand::SP&);

    const mbus::string & getProtocol() const override { return StorageProtocol::NAME; }
    uint32_t getType() const override { return _cmd->getType().getId(); }
    const api::StorageCommand::SP& getCommand() { return _cmd; }
    api::StorageCommand::CSP getCommand() const { return _cmd; }
    api::StorageMessage::SP getInternalMessage() override { return _cmd; }
    api::StorageMessage::CSP getInternalMessage() const override { return _cmd; }

    uint8_t priority() const override {
        return ((getInternalMessage()->getPriority()) / 255) * 16;
    }

private:
    api::StorageCommand::SP _cmd;
};

} // mbusprot
} // storage