Real Time Open Sound Control librtosc: rtosc::Ports Struct Reference

Real Time Open Sound Control librtosc

Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | List of all members
rtosc::Ports Struct Reference

Ports - a dispatchable collection of Port entries. More...

`#include <ports.h>`

Inheritance diagram for rtosc::Ports:

## Public Types
typedef std::vector< Port >::const_iterator | itr_t

## Public Member Functions
itr_t | begin () const
| Forwards to builtin container.
itr_t | end () const
| Forwards to builtin container.
size_t | size () const
| Forwards to builtin container.
const Port & | operator[] (unsigned i) const
| Forwards to builtin container.
| Ports (std::initializer_list< Port > l)
| Ports (const Ports &)=delete
void | dispatch (const char *m, RtData &d, bool base_dispatch=false) const
| Dispatches message to all matching ports. More...
const Port * | operator[] (const char *name) const
| Retrieve local port by name TODO implement full matching.
const Port * | apropos (const char *path) const
| Find the best match for a given path. More...

## Static Public Member Functions
static char * | collapsePath (char *p)
| Collapse path with parent path identifiers "/..". More...

## Public Attributes
std::vector< Port > | ports
std::function< void(msg_t, RtData &)> | default_handler

## Protected Member Functions
void | refreshMagic (void)

## Detailed Description

Ports - a dispatchable collection of Port entries.

This structure makes it somewhat easier to perform actions on collections of port entries and it is responsible for the dispatching of OSC messages to their respective ports. That said, it is a very simple structure, which uses a stl container to store all data in a simple dispatch table. All methods post-initialization are RT safe (assuming callbacks are RT safe)

## Member Function Documentation

## ◆ apropos()

const Port* rtosc::Ports::apropos | ( | const char * | path | ) | const

Find the best match for a given path.

Parameters

  path | partial OSC path

Returns
  first path prefixed by the argument

Example usage:

Ports p = {{"foo",0,0,dummy_method},
{"flam",0,0,dummy_method},
{"bar",0,0,dummy_method}};
p.apropos("/b")->name;//bar
p.apropos("/f")->name;//foo
p.apropos("/fl")->name;//flam
p.apropos("/gg");//NULL

## ◆ collapsePath()

static char* rtosc::Ports::collapsePath | ( | char * | p | ) |
| static

Collapse path with parent path identifiers "/..".

e.g. /foo/bar/../baz => /foo/baz

## ◆ dispatch()

void rtosc::Ports::dispatch | ( | const char * | m,
|  | RtData & | d,
|  | bool | base_dispatch = `false`
| ) |  | const

Dispatches message to all matching ports.

This uses simple pattern matching available in rtosc::match().

Invariant
  In each recursion, "d.loc + m" must make the port's full path. For further recursions, a call to scat() will append the toplevel of m to d.loc, and in the rRecur* callbacks, SNIP() will cut the toplevel from m. I.e.: loc="", m="a/b/c" => loc="/a/", m="b/c".

Parameters

  m | A valid OSC message. Note that the address part shall not contain any type specifier.
  d | The RtData object shall contain a path buffer (or null), the length of the buffer, a pointer to data. It must also contain the location if an answer is being expected.
  base_dispatch | Whether the OSC path is to be interpreted as a full OSC path beginning at the root

The documentation for this struct was generated from the following file:

- include/rtosc/ports.h