OSSIA
Open Scenario System for Interactive Application
|
Inherited by ossia::net::generic_node_base, ossia::net::midi::midi_node, ossia::net::wrapped_node< T, Parameter_T >, ossia::phidget_hub_port_node, and ossia::phidget_node.
The node_base class.
Base class for nodes. A node_base is part of the hierarchy of a device_base.
The node_base has ownership of its children.
If a node is meant to send and receive data, an parameter_base should be created with node_base::create_parameter.
Some device trees may provide immutable node hierarchies : child nodes cannot be added nor removed. This is the case for the midi_device. Other device trees allow the user to create nodes as he sees fit : generic_node is used for this common case.
Public Types | |
using | children_t = std::vector< std::unique_ptr< node_base > > |
Public Member Functions | |
node_base (const node_base &)=delete | |
node_base (node_base &&)=delete | |
node_base & | operator= (const node_base &)=delete |
node_base & | operator= (node_base &&)=delete |
virtual device_base & | get_device () const =0 |
The device in which this node is. | |
virtual node_base * | get_parent () const =0 |
Parent of this node. May be null if it is the device (i.e. root). | |
const std::string & | get_name () const |
The name of this node, e.g. "foo". More... | |
virtual node_base & | set_name (std::string)=0 |
virtual parameter_base * | create_parameter (val_type=val_type::IMPULSE)=0 |
Allows a node to carry a value. | |
virtual void | set_parameter (std::unique_ptr< ossia::net::parameter_base >) |
Default implementation does nothing. | |
virtual bool | remove_parameter ()=0 |
virtual parameter_base * | get_parameter () const =0 |
const extended_attributes & | get_extended_attributes () const |
void | set_extended_attributes (const extended_attributes &) |
ossia::any | get_attribute (std::string_view str) const |
template<typename T > | |
void | set (std::string_view str, const T &val) |
template<typename T > | |
void | set (std::string_view str, T &&val) |
template<typename T > | |
void | set (std::string_view str, const std::optional< T > &val) |
template<typename T > | |
void | set (std::string_view str, std::optional< T > &&val) |
void | set (std::string_view str, bool value) |
template<typename Attribute , typename T > | |
void | set (Attribute a, const T &value) |
template<typename Attribute , typename T > | |
void | set (Attribute a, T &value) |
template<typename Attribute , typename T > | |
void | set (Attribute a, T &&value) |
node_base * | create_child (std::string name) |
create_child Adds a sub-child of the given name. More... | |
node_base * | add_child (std::unique_ptr< node_base >) |
Adds a new child if it can be added. More... | |
node_base * | find_child (std::string_view name) |
Find a direct child of this node. More... | |
bool | has_child (ossia::net::node_base &) |
Return true if this node is parent of this children. | |
bool | remove_child (const std::string &name) |
bool | remove_child (const node_base &name) |
void | clear_children () |
Remove all the children. | |
operator const extended_attributes & () const | |
operator extended_attributes & () | |
locked_container< const children_t > | children () const |
const auto & | unsafe_children () const TS_REQUIRES(m_mutex) |
Non mutex-protected version. With great powers, yada yada etc etc. | |
std::vector< node_base * > | children_copy () const |
Return a copy of the children vector to iterate without deadlocking. | |
std::vector< std::string > | children_names () const |
A vector with all the names of the children. | |
bool | is_root_instance (const ossia::net::node_base &child) const |
If childrens are /foo, /bar, bar.1, returns true only for bar. | |
const std::string & | osc_address () const |
virtual void | on_address_change () |
Public Attributes | |
shared_mutex_t | m_mutex |
Nano::Signal< void(const node_base &)> | about_to_be_deleted |
The node subclasses must call this in their destructor. | |
Protected Member Functions | |
virtual std::unique_ptr< node_base > | make_child (const std::string &name)=0 |
Should return nullptr if no child is to be added. | |
virtual void | removing_child (node_base &node_base)=0 |
Reimplement for a specific removal action. | |
children_t m_children | TS_GUARDED_BY (m_mutex) |
Protected Attributes | |
std::string | m_name |
extended_attributes | m_extended {0} |
std::string | m_oscAddressCache |
|
inline |
The name of this node, e.g. "foo".
const extended_attributes & ossia::net::node_base::get_extended_attributes | ( | ) | const |
Allows to add arbitrary key-value metadata to nodes. There is a list of pre-defined attributes available in node_attributes.hpp
ossia::any ossia::net::node_base::get_attribute | ( | std::string_view | str | ) | const |
Get a specific attribute. Usage :
node_base * ossia::net::node_base::create_child | ( | std::string | name | ) |
create_child Adds a sub-child of the given name.
If you need to add multiple childs in one go (for instance /foo/bar/baz/blop
if this node is foo
), see ossia::net::find_or_create_node.
Adds a new child if it can be added.
For instance if the name is already taken, it won't be added and the returned pointer will be null.
node_base * ossia::net::node_base::find_child | ( | std::string_view | name | ) |
Find a direct child of this node.
e.g. foo.findChild("bar")
will find /foo/bar
, but not /foo/blop/bar
.
If you need to find a child recursively, see ossia::net::find_node.