aboutsummaryrefslogtreecommitdiffstats
path: root/fnet/src/vespa/fnet/dummypacket.h
blob: 9894daf017b98f968b1e01e81587d144f9558d38 (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include "packet.h"

/**
 * A dummy packet is neither a regular packet nor a control
 * packet. The idea with this class is that you subclass it to make
 * packets that perform certain tasks when they are freed. The default
 * Free method simply deletes the packet object, so you may chose to
 * override either the Free method or the destructor, depending on the
 * intended lifetime of the packet.
 **/
class FNET_DummyPacket : public FNET_Packet
{
public:
    /**
     * Empty constructor.
     **/
    FNET_DummyPacket();

    /**
     * @return false
     **/
    bool IsRegularPacket() override;

    /**
     * @return false
     **/
    bool IsControlPacket() override;

    /**
     * @return FNET_NOID
     **/
    uint32_t GetPCODE() override;

    /**
     * @return 0
     **/
    uint32_t GetLength() override;

    /**
     * This method should never be called and will abort the program.
     **/
    void Encode(FNET_DataBuffer *) override;

    /**
     * This method should never be called and will abort the program.
     **/
    bool Decode(FNET_DataBuffer *, uint32_t) override;

    /**
     * Identify as dummy packet.
     **/
    vespalib::string Print(uint32_t indent = 0) override;
};