Program Listing for File InputQueue.hpp

Return to documentation for file (include/depthai/pipeline/InputQueue.hpp)

#pragma once

#include "depthai/pipeline/Node.hpp"
#include "depthai/pipeline/ThreadedHostNode.hpp"

namespace dai {

class InputQueue {
    friend class Node::Input;

   public:
    void send(const std::shared_ptr<ADatatype>& msg);

   private:
    explicit InputQueue(unsigned int maxSize = 16, bool blocking = false);

    class InputQueueNode : public node::ThreadedHostNode {
       public:
        InputQueueNode(unsigned int maxSize, bool blocking);

        void send(const std::shared_ptr<ADatatype>& msg);

        void run() override;
        const char* getName() const override;

        Node::Input input{*this, {"input", DEFAULT_GROUP, DEFAULT_BLOCKING, DEFAULT_QUEUE_SIZE, {{{DatatypeEnum::Buffer, true}}}, DEFAULT_WAIT_FOR_MESSAGE}};
        Node::Output output{*this, {"output", DEFAULT_GROUP, {{{DatatypeEnum::Buffer, true}}}}};
    };

    // Helper access functions
    inline Node::Output& getNodeOutput() {
        return inputQueueNode->output;
    }
    inline std::shared_ptr<Node> getNode() {
        return inputQueueNode;
    }

    std::shared_ptr<InputQueueNode> inputQueueNode;
};
}  // namespace dai