libmapper 2.4.12
mapper::Signal Class Reference

#include <mapper_cpp.h>

Inheritance diagram for mapper::Signal:
mapper::Object

Data Structures

class  Instance
 

Public Types

enum class  Event {
}
 
enum class  InstanceStatus {
  NEW = MPR_STATUS_NEW , STAGED = MPR_STATUS_STAGED , ACTIVE = MPR_STATUS_ACTIVE , HAS_VALUE = MPR_STATUS_HAS_VALUE ,
  NEW_VALUE = MPR_STATUS_NEW_VALUE , UPDATE_LOC = MPR_STATUS_UPDATE_LOC , UPDATE_REM = MPR_STATUS_UPDATE_REM , REL_UPSTRM = MPR_STATUS_REL_UPSTRM ,
  REL_DNSTRM = MPR_STATUS_REL_DNSTRM , INST_OFLW = MPR_STATUS_OVERFLOW , ANY = MPR_STATUS_ANY
}
 
enum class  Stealing { NONE = MPR_STEAL_NONE , OLDEST = MPR_STEAL_OLDEST , NEWEST = MPR_STEAL_NEWEST }
 
- Public Types inherited from mapper::Object
enum class  Status {
  UNDEFINED = MPR_STATUS_UNDEFINED , EXPIRED = MPR_STATUS_EXPIRED , NEW = MPR_STATUS_NEW , MODIFIED = MPR_STATUS_MODIFIED ,
  STAGED = MPR_STATUS_STAGED , ACTIVE = MPR_STATUS_ACTIVE , REMOVED = MPR_STATUS_REMOVED , HAS_VALUE = MPR_STATUS_HAS_VALUE ,
  NEW_VALUE = MPR_STATUS_NEW_VALUE , UPDATE_LOC = MPR_STATUS_UPDATE_LOC , UPDATE_REM = MPR_STATUS_UPDATE_REM , REL_UPSTRM = MPR_STATUS_REL_UPSTRM ,
  REL_DNSTRM = MPR_STATUS_REL_DNSTRM , INST_OFLW = MPR_STATUS_OVERFLOW , ANY = MPR_STATUS_ANY
}
 

Public Member Functions

Device device () const
 
List< Mapmaps (Direction dir=Direction::ANY) const
 
template<typename... Values>
Signalset_value (Values... vals)
 
template<typename H >
Signalset_callback (H &h, Signal::Event events=Signal::Event::UPDATE)
 
Signalremove_callback ()
 
Instance instance ()
 
Instance instance (Id id)
 
Signalreserve_instances (int num)
 
Signalreserve_instances (int num, mpr_id *ids)
 
Signalreserve_instances (int num, Id *ids, void **data)
 
Signalreserve_instance ()
 
Signalreserve_instance (mpr_id id)
 
Signalreserve_instance (mpr_id id, void *data)
 
Instance instance (int idx, InstanceStatus status=InstanceStatus::ANY) const
 
Signalremove_instance (Instance instance)
 
Instance oldest_instance ()
 
Instance newest_instance ()
 
int num_instances (Status status=Status::ACTIVE) const
 
const Signalpush () const
 
- Public Member Functions inherited from mapper::Object
 operator bool () const
 
Type type () const
 
Graph graph () const
 
int get_status () const
 
Objectreset_status ()
 
template<typename... Values>
Objectset_property (const Values... vals)
 
template<typename... Values>
Objectset_local_property (const Values... vals)
 
virtual Objectremove_property (Property prop)
 
virtual Objectremove_property (const str_type &key)
 
int num_props (bool staged=false) const
 
PropVal property (const str_type &key=NULL) const
 
PropVal property (Property prop) const
 
PropVal property (int idx) const
 

Detailed Description

Signals define inputs or outputs for Devices. A Signal consists of a scalar or vector value of some integer or floating-point type. A Signal is created by adding an input or output to a Device. It can optionally be provided with some metadata such as a range, unit, or other properties. Signals can be mapped by creating Maps using remote requests on the network, usually generated by a standalone GUI.

Member Enumeration Documentation

◆ Event

enum class mapper::Signal::Event
strong

The set of possible signal events, used to register and inform callbacks.

Enumerator
INST_NEW 

New instance has been created.

UPDATE 

Instance value has been set remotely.

REL_UPSTRM 

Instance was released upstream.

REL_DNSTRM 

Instance was released downstream.

INST_OFLW 

No local instances left.

◆ InstanceStatus

enum class mapper::Signal::InstanceStatus
strong

The set of possible voice-stealing modes for instances.

Enumerator
NEW 

Instance is new since last check.

STAGED 

Instance is reserved but not active.

ACTIVE 

Instance is active.

HAS_VALUE 

Instance has a value.

NEW_VALUE 

Value has changed since last check.

UPDATE_LOC 

Value was set locally since last check.

UPDATE_REM 

Value was set remotely since last check.

REL_UPSTRM 

Released upstream since last check.

REL_DNSTRM 

Released downstream since last check.

INST_OFLW 

No local instances left.

◆ Stealing

enum class mapper::Signal::Stealing
strong

The set of possible voice-stealing modes for instances.

Enumerator
NONE 

No stealing will take place.

OLDEST 

Steal the oldest instance.

NEWEST 

Steal the newest instance.

Member Function Documentation

◆ device()

Device mapper::Signal::device ( ) const
inline

Get the parent Device for this Signal.

Returns
The parent Device.

◆ instance() [1/3]

Instance mapper::Signal::instance ( )
inline

Activate and return a new Instance with an automatically-generated id.

Returns
The new Instance.

◆ instance() [2/3]

Instance mapper::Signal::instance ( Id id)
inline

Retrieve an Instance with the provided id, activating a reserved instance if necessary.

Parameters
idId of the Instance to retrieve or activate.
Returns
An Instance.

◆ instance() [3/3]

Instance mapper::Signal::instance ( int idx,
InstanceStatus status = InstanceStatus::ANY ) const
inline

Retrieve an Instance from the pool using an index and status.

Parameters
idxThe index of the Instance to retrieve.
statusThe status pool to query: ACTIVE, RESERVED, or ANY.
Returns
An Instance.

◆ maps()

List< Map > mapper::Signal::maps ( Direction dir = Direction::ANY) const
inline

Get a list of Maps involving this Signal.

Parameters
dirThe directionality of the Maps (with reference to the Signal) to include in the list. Use Direction::ANY to include all Maps.
Returns
A List of Maps.

◆ newest_instance()

Instance mapper::Signal::newest_instance ( )
inline

Retrieve the newest active Instance.

Returns
An Instance.

◆ num_instances()

int mapper::Signal::num_instances ( Status status = Status::ACTIVE) const
inline

Retrieve the number of Instances belonging to this Signal.

Parameters
statusThe status of the Instance to count: ACTIVE, RESERVED, or ALL.
Returns
The number of Instances with the given status.

◆ oldest_instance()

Instance mapper::Signal::oldest_instance ( )
inline

Retrieve the oldest active Instance.

Returns
An Instance.

◆ push()

const Signal & mapper::Signal::push ( ) const
inlinevirtual

Push "staged" property changes out to the distributed graph.

Returns
Self.

Reimplemented from mapper::Object.

◆ remove_callback()

Signal & mapper::Signal::remove_callback ( )
inline

Remove the callback from a Signal.

Returns
Self.

◆ remove_instance()

Signal & mapper::Signal::remove_instance ( Instance instance)
inline

Remove an Instance and free its resources.

Parameters
instanceThe Instance to remove.
Returns
Self.

◆ reserve_instance() [1/3]

Signal & mapper::Signal::reserve_instance ( )
inline

Reserve a single Instance.

Returns
Self.

◆ reserve_instance() [2/3]

Signal & mapper::Signal::reserve_instance ( mpr_id id)
inline

Reserve a single Instance with the provided id.

Parameters
idThe id to associate with the Instance.
Returns
Self.

◆ reserve_instance() [3/3]

Signal & mapper::Signal::reserve_instance ( mpr_id id,
void * data )
inline

Reserve a single Instance with the provided id and user_data.

Parameters
idThe id to associate with the Instance.
dataUser data to associate with the Instance.
Returns
Self.

◆ reserve_instances() [1/3]

Signal & mapper::Signal::reserve_instances ( int num)
inline

Reserve a number of Instances.

Parameters
numThe number of Instances to reserve.
Returns
Self.

◆ reserve_instances() [2/3]

Signal & mapper::Signal::reserve_instances ( int num,
Id * ids,
void ** data )
inline

Reserve a number of Instances with provided ids and user_data.

Parameters
numThe number of Instances to reserve.
idsAn array of num ids to associate with the reserved Instances. Must be NULL or have size num.
dataAn array of num data pointers to associate with the reserved Instances. Must be NULL or have size num.
Returns
Self.

◆ reserve_instances() [3/3]

Signal & mapper::Signal::reserve_instances ( int num,
mpr_id * ids )
inline

Reserve a number of Instances with provided ids.

Parameters
numThe number of Instances to reserve.
idsAn array of ids to associate with the reserved Instances. Must be NULL or have size num.
Returns
Self.

◆ set_callback()

template<typename H >
Signal & mapper::Signal::set_callback ( H & h,
Signal::Event events = Signal::Event::UPDATE )
inline

Add an Event Callback to a signal.

Parameters
hCallback function to call on Signal Events. Function signature can be any of the following:
eventsTypes of Events to listen for.
Returns
Self.

◆ set_value()

template<typename... Values>
Signal & mapper::Signal::set_value ( Values... vals)
inline

Set the current value for this Signal.

Parameters
valsThe value to set. Can be scalar, array, std::array, or std::vector of int, float, or double
Returns
Self.