aboutsummaryrefslogtreecommitdiffstats
path: root/fnet/src/vespa/fnet/ipacketfactory.h
blob: d13e05a30521312e60cdafa743c0a854140d88d7 (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include "context.h"

/**
 * Interface describing objects that are able to create packets. An
 * object implementing this interface is needed in order to use the
 * SimplePacketStreamer class.
 **/
class FNET_IPacketFactory
{
public:
    /**
     * Destructor.  No cleanup needed for base class.
     */
    virtual ~FNET_IPacketFactory() { }

    /**
     * Create a packet.
     *
     * @return the newly created packet.
     * @param pcode what kind of packet to create. The semantic of this
     *        field is left to the implementing object to allow
     *        parallell dimensions of packet types in the same
     *        application.
     * @param context application context. When this class is used by
     *        the SimplePacketStreamer, this is the application context
     *        for the channel that will receive the packet after it is
     *        created and un-streamed.
     **/
    virtual FNET_Packet *CreatePacket(uint32_t pcode, FNET_Context context) = 0;
};