summaryrefslogtreecommitdiffstats
path: root/veslibrary/ves_cpplibrary/src/lib/transport/include/XQueue.h
blob: c2a08b68aa5aba0ccacb5aa23255c125489b0051 (plain)
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
#pragma once

#include <string>
#include <memory>

namespace vagt
{
    namespace queue
    {
        /*************************************************************************************************//**
        * @brief Error codes
        *****************************************************************************************************/
        enum XErrorCode : unsigned short
        {
            XErrorOk,       /**< The operation is successful */
            XErrorNok,      /**< General failure */
            XErrorFull,     /**< The buffer is full */
            XErrorEmpty,    /**< The buffer is empty */
        };

        class XQueue
        {
        public:
            virtual bool empty() = 0;
            virtual XErrorCode push(const std::string& val) = 0;
            virtual void pop() = 0;
            virtual std::string front() = 0;

            /*************************************************************************************************//**
            *    Create a queue in memory with specified capacity.
            *****************************************************************************************************/
            static std::shared_ptr<XQueue> create(int capacity);

            /*************************************************************************************************//**
            *    Create a queue on disk.
            *****************************************************************************************************/
            static std::shared_ptr<XQueue> create(const std::string& path);
        };
    }
}