Class Node
Defined in File Node.hpp
Nested Relationships
Nested Types
Inheritance Relationships
Base Type
public std::enable_shared_from_this< Node >
Derived Types
public dai::NodeGroup(Class NodeGroup)public dai::ThreadedNode(Class ThreadedNode)
Class Documentation
-
class Node : public std::enable_shared_from_this<Node>
Abstract Node.
Subclassed by dai::NodeGroup, dai::ThreadedNode
Public Types
Public Functions
-
std::string createUniqueInputName()
-
std::string createUniqueOutputName()
-
inline std::string getAlias() const
Get alias.
-
inline void setAlias(std::string alias)
Set alias.
-
virtual const char *getName() const = 0
Retrieves nodes name.
-
inline virtual void start()
Start node execution.
-
inline virtual void wait()
Wait for node to finish execution.
-
inline virtual void stop()
Stop node execution.
-
void stopPipeline()
-
virtual void buildStage1()
Build stages;.
-
virtual void buildStage2()
-
virtual void buildStage3()
-
virtual bool isSourceNode() const
-
virtual ~Node() = default
-
const AssetManager &getAssetManager() const
Get node AssetManager as a const reference.
-
AssetManager &getAssetManager()
Get node AssetManager as a reference.
-
std::vector<uint8_t> loadResource(std::filesystem::path uri)
Loads resource specified by URI and returns its data.
-
std::vector<uint8_t> moveResource(std::filesystem::path uri)
Moves the resource out.
Add existing node to nodeMap.
-
ConnectionMap getConnectionMap()
Get a reference to internal node map.
-
virtual Node::Output *requestOutput(const Capability &capability, bool onHost)
-
virtual std::vector<std::pair<Input&, std::shared_ptr<Capability>>> getRequiredInputs()
-
virtual bool runOnHost() const = 0
Returns true or false whether the node should be run on host or not.
-
inline virtual void buildInternal()
Function called from within the
createfunction to build the node. This function is useful for initialization, setting up inputs and outputs = stuff that cannot be perform in the constuctor.
Public Members
-
std::string alias
alias or name
Public Static Attributes
-
static constexpr auto DEFAULT_GROUP = ""
-
static constexpr auto DEFAULT_NAME = ""
-
static constexpr auto DEFAULT_BLOCKING = true
-
static constexpr auto DEFAULT_QUEUE_SIZE = 3
-
static constexpr auto DEFAULT_WAIT_FOR_MESSAGE = false
-
static constexpr auto BLOCKING_QUEUE = true
-
static constexpr auto NON_BLOCKING_QUEUE = false
Protected Types
-
using SetConnectionInternal = std::unordered_set<ConnectionInternal, ConnectionInternal::Hash>
-
using ConnectionMap = std::unordered_map<std::shared_ptr<Node>, SetConnectionInternal>
Protected Attributes
-
bool configureMode = {false}
-
std::weak_ptr<PipelineImpl> parent
-
int parentId = {-1}
-
AssetManager assetManager
-
SetConnectionInternal connections
Friends
- friend class Subnode
-
struct Connection
Connection between an Input and Output.
Public Members
-
std::string outputName
-
std::string outputGroup
-
std::string inputName
-
std::string inputGroup
Friends
- friend struct std::hash< Connection >
-
std::string outputName
-
struct ConnectionInternal
Connection between an Input and Output internal.
Public Functions
-
bool operator==(const ConnectionInternal &rhs) const
Public Members
-
std::string outputName
-
std::string outputGroup
-
std::string inputName
-
std::string inputGroup
-
struct Hash
Public Functions
-
size_t operator()(const dai::Node::ConnectionInternal &obj) const
-
size_t operator()(const dai::Node::ConnectionInternal &obj) const
-
bool operator==(const ConnectionInternal &rhs) const
-
struct DatatypeHierarchy
Public Functions
-
inline DatatypeHierarchy(DatatypeEnum d, bool c)
-
inline DatatypeHierarchy(DatatypeEnum d, bool c)
-
class Input : public dai::MessageQueue
-
Public Functions
-
~Input() override
-
inline explicit Input(Node &par, InputDescription desc, bool ref = true)
-
void setWaitForMessage(bool waitForMessage)
Overrides default wait for message behavior. Applicable for nodes with multiple inputs. Specifies behavior whether to wait for this input when a Node processes certain data or not.
- Parameters:
waitForMessage – Whether to wait for message to arrive to this input or not
-
bool getWaitForMessage() const
Get behavior whether to wait for this input when a Node processes certain data or not
- Returns:
Whether to wait for message to arrive to this input or not
-
std::vector<DatatypeHierarchy> getPossibleDatatypes() const
Get possible datatypes that can be received
-
void setPossibleDatatypes(std::vector<DatatypeHierarchy> types)
Set possible datatypes that can be received
-
void setReusePreviousMessage(bool reusePreviousMessage)
Equivalent to setWaitForMessage but with inverted logic.
-
bool getReusePreviousMessage() const
Equivalent to getWaitForMessage but with inverted logic.
-
void setGroup(std::string group)
Set group name for this input
-
std::string getGroup() const
Get group name for this input
-
bool isConnected() const
Check if this input is connected
-
std::shared_ptr<InputQueue> createInputQueue(unsigned int maxSize = INPUT_QUEUE_DEFAULT_MAX_SIZE, bool blocking = INPUT_QUEUE_DEFAULT_BLOCKING)
Create an shared pointer to an input queue that can be used to send messages to this input from onhost.
- Parameters:
maxSize – Maximum size of the input queue
blocking – Whether the input queue should block when full
- Returns:
std::shared_ptr<InputQueue>: shared pointer to an input queue
Public Members
-
std::vector<DatatypeHierarchy> possibleDatatypes
-
~Input() override
-
struct InputDescription
Public Members
-
std::string name = DEFAULT_NAME
-
std::string group = DEFAULT_GROUP
-
bool blocking = {DEFAULT_BLOCKING}
-
int queueSize = {DEFAULT_QUEUE_SIZE}
- std::vector< DatatypeHierarchy > types DEFAULT_TYPES
-
bool waitForMessage = {DEFAULT_WAIT_FOR_MESSAGE}
-
std::string name = DEFAULT_NAME
-
class InputMap : public std::unordered_map<std::pair<std::string, std::string>, Input, PairHash>
Input map which keeps track of inputs assigned to a node Extends std::unordered_map<std::string, dai::Node::Input>
Public Functions
-
InputMap(Node &parent, InputDescription defaultInput)
-
InputMap(Node &parent, std::string name, InputDescription defaultInput)
-
Input &operator[](std::pair<std::string, std::string> groupKey)
Create or modify an input with specified group.
-
bool has(const std::string &key) const
Public Members
-
std::string name
-
InputMap(Node &parent, InputDescription defaultInput)
-
class Output
-
Public Functions
-
virtual ~Output() = default
-
inline Output(Node &par, OutputDescription desc, bool ref = true)
-
inline std::string getName() const
Get name of the output
-
inline std::string getGroup() const
Get group of the output
-
inline void setGroup(std::string group)
Set group name for this output
-
inline void setName(std::string name)
Set name for this output
-
std::vector<DatatypeHierarchy> getPossibleDatatypes() const
Get possible datatypes that can be sent
-
void setPossibleDatatypes(std::vector<DatatypeHierarchy> types)
Set possible datatypes that can be sent
-
bool isSamePipeline(const Input &in)
Check if this output and given input are on the same pipeline.
See also
canConnect for checking if connection is possible
- Returns:
True if output and input are on the same pipeline
-
bool canConnect(const Input &in)
Check if connection is possible
- Parameters:
in – Input to connect to
- Returns:
True if connection is possible, false otherwise
-
std::vector<ConnectionInternal> getConnections()
Retrieve all connections from this output
- Returns:
Vector of connections
-
inline std::vector<QueueConnection> getQueueConnections()
Retrieve all queue connections from this output
- Returns:
Vector of queue connections
-
std::shared_ptr<dai::MessageQueue> createOutputQueue(unsigned int maxSize = OUTPUT_QUEUE_DEFAULT_MAX_SIZE, bool blocking = OUTPUT_QUEUE_DEFAULT_BLOCKING)
Construct and return a shared pointer to an output message queue.
- Parameters:
maxSize – Maximum size of the output queue
blocking – Whether the output queue should block when full
- Returns:
std::shared_ptr<dai::MessageQueue>: shared pointer to an output queue
-
void link(Input &in)
Link current output to input.
Throws an error if this output cannot be linked to given input, or if they are already linked
- Parameters:
in – Input to link to
-
void unlink(Input &in)
Unlink a previously linked connection
Throws an error if not linked.
- Parameters:
in – Input from which to unlink from
Sends a Message to all connected inputs
- Parameters:
msg – Message to send to all connected inputs
Try sending a message to all connected inputs
- Parameters:
msg – Message to send to all connected inputs
- Returns:
True if ALL connected inputs got the message, false otherwise
Public Static Attributes
-
static constexpr bool OUTPUT_QUEUE_DEFAULT_BLOCKING = false
Default value for the blocking argument in the createOutputQueue method
-
static constexpr unsigned int OUTPUT_QUEUE_DEFAULT_MAX_SIZE = 16
Default value for the maxSize argument in the createOutputQueue method
-
struct QueueConnection
Public Functions
-
inline bool operator==(const QueueConnection &rhs) const
-
inline bool operator==(const QueueConnection &rhs) const
-
virtual ~Output() = default
-
struct OutputDescription
Public Members
-
std::string name = {DEFAULT_NAME}
-
std::string group = {DEFAULT_GROUP}
- std::vector< DatatypeHierarchy > types DEFAULT_TYPES
-
std::string name = {DEFAULT_NAME}
-
class OutputMap : public std::unordered_map<std::pair<std::string, std::string>, Output, PairHash>
Output map which keeps track of extra outputs assigned to a node Extends std::unordered_map<std::string, dai::Node::Output>
Public Functions
-
OutputMap(Node &parent, std::string name, OutputDescription defaultOutput, bool ref = true)
-
OutputMap(Node &parent, OutputDescription defaultOutput, bool ref = true)
Public Members
-
std::string name
-
OutputMap(Node &parent, std::string name, OutputDescription defaultOutput, bool ref = true)
-
struct PairHash
-
std::string createUniqueInputName()