xronos-sdk 0.14.0
Xronos C++ SDK
Loading...
Searching...
No Matches
node.hh File Reference
#include <cstdint>
#include <functional>
#include <memory>
#include <source_location>
#include <string_view>
#include <type_traits>
#include <utility>
#include "xronos/abi/backend.hh"
#include "xronos/abi/node.hh"
#include "xronos/abi/types.hh"
#include "xronos/abi/version.hh"
#include "xronos/sdk/context.hh"
#include "xronos/sdk/detail/context_access.hh"
#include "xronos/sdk/detail/program_context.hh"
#include "xronos/sdk/detail/source_location.hh"
#include "xronos/sdk/gen/config.hh"
#include "xronos/sdk/port.hh"
#include "xronos/sdk/reactor.hh"
#include "xronos/sdk/value_type.hh"

Classes

class  xronos::sdk::Node
 A Xronos program's entry point, launched with xronos run. More...

Namespaces

namespace  xronos::sdk
 Main Xronos SDK namespace.

Macros

#define XRONOS_REGISTER_NODE(NodeClass, default_name)
 Register NodeClass as the node that xronos run loads from this module.

Macro Definition Documentation

◆ XRONOS_REGISTER_NODE

#define XRONOS_REGISTER_NODE ( NodeClass,
default_name )
Value:
extern "C" __attribute__((visibility("default"))) auto xronos_node_descriptor() \
-> const ::xronos::abi::NodeDescriptor* { \
static constexpr ::xronos::abi::NodeDescriptor descriptor{::xronos::abi::version_major, \
::xronos::abi::version_minor, \
::xronos::sdk::config::VERSION.data(), default_name}; \
return &descriptor; \
} \
extern "C" __attribute__((visibility("default"))) auto xronos_create_node( \
const char* name, ::xronos::abi::Backend* backend, ::xronos::abi::ElementUid parent) -> ::xronos::abi::Node* { \
return ::xronos::sdk::detail::create_node<NodeClass>(name, backend, parent); \
} \
extern "C" __attribute__((visibility("default"))) auto xronos_create_top_level_node( \
const char* name, ::xronos::abi::Backend* backend) -> ::xronos::abi::Node* { \
return ::xronos::sdk::detail::create_node<NodeClass>(name, backend); \
}

Register NodeClass as the node that xronos run loads from this module.

Invoke once at namespace scope, after defining NodeClass. This is what turns a compiled .so into a runnable Xronos module: xronos run finds the registered node, checks that the module is compatible with the CLI, then constructs it under default_name (or the name passed to xronos run --name) and runs it.

Parameters
NodeClassA concrete subclass of xronos::sdk::Node, constructible from a std::string_view name and a const xronos::sdk::Context& (inheriting Node's constructor with using Node::Node; is enough when it has no other members to construct).
default_nameThe node's default name, overridable with xronos run --name.
See also
Node