Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
zrythm::dsp::PortConnectionsManager Class Referencefinal

Port connections manager. More...

#include <src/dsp/port_connections_manager.h>

Inheritance diagram for zrythm::dsp::PortConnectionsManager:
Collaboration diagram for zrythm::dsp::PortConnectionsManager:

Public Types

using PortConnection = dsp::PortConnection
 
using PortUuid = PortConnection::PortUuid
 
using ConnectionsVector = std::vector<PortConnection *>
 

Public Member Functions

 PortConnectionsManager (QObject *parent=nullptr)
 
void regenerate_hashtables ()
 Regenerates the hash tables.
 
int get_sources_or_dests (ConnectionsVector *arr, const PortUuid &id, bool sources) const
 Adds the sources/destinations of id in the given array.
 
int get_sources (ConnectionsVector *arr, const PortUuid &id) const
 
int get_dests (ConnectionsVector *arr, const PortUuid &id) const
 
int get_num_sources (const PortUuid &id) const
 
int get_num_dests (const PortUuid &id) const
 
auto get_connection_count () const noexcept
 
int get_unlocked_sources_or_dests (ConnectionsVector *arr, const PortUuid &id, bool sources) const
 Adds the sources/destinations of id in the given array.
 
PortConnectionget_source_or_dest (const PortUuid &id, bool sources) const
 Wrapper over get_sources_or_dests() that returns the first connection.
 
PortConnectionget_connection (const PortUuid &src, const PortUuid &dest) const
 
bool connection_exists (const PortUuid &src, const PortUuid &dest) const
 
bool update_connection (const PortConnection &before, const PortConnection &after)
 Replaces the given before connection with after.
 
bool update_connection (const PortUuid &src, const PortUuid &dest, float multiplier, bool locked, bool enabled)
 
const PortConnectionadd_connection (const PortUuid &src, const PortUuid &dest, float multiplier, bool locked, bool enabled)
 Stores the connection for the given ports if it doesn't exist, otherwise updates the existing connection.
 
const PortConnectionadd_default_connection (const PortUuid &src, const PortUuid &dest, bool locked)
 Overload for default settings (multiplier = 1.0, enabled = true).
 
const PortConnectionadd_connection (const PortConnection &conn)
 
bool remove_connection (const PortUuid &src, const PortUuid &dest)
 Removes the connection for the given ports if it exists.
 
void remove_all_connections (const PortUuid &pi)
 Disconnect all sources and dests of the given port identifier.
 
void reset_connections_from_other (const PortConnectionsManager *other)
 Removes all connections from this.
 
bool contains_connection (const PortConnection &conn) const
 
void print_ht (const ConnectionHashTable &ht)
 
void print () const
 
void clear_all ()
 

Friends

void init_from (PortConnectionsManager &obj, const PortConnectionsManager &other, utils::ObjectCloneType clone_type)
 
void to_json (nlohmann::json &j, const PortConnectionsManager &pcm)
 
void from_json (const nlohmann::json &j, PortConnectionsManager &pcm)
 

Detailed Description

Port connections manager.

Definition at line 17 of file port_connections_manager.h.

Member Typedef Documentation

◆ ConnectionsVector

using zrythm::dsp::PortConnectionsManager::ConnectionsVector = std::vector<PortConnection *>

Definition at line 25 of file port_connections_manager.h.

◆ PortConnection

◆ PortUuid

Member Function Documentation

◆ add_connection() [1/2]

const PortConnection * zrythm::dsp::PortConnectionsManager::add_connection ( const PortConnection & conn)
inline

Definition at line 169 of file port_connections_manager.h.

◆ add_connection() [2/2]

const PortConnection * zrythm::dsp::PortConnectionsManager::add_connection ( const PortUuid & src,
const PortUuid & dest,
float multiplier,
bool locked,
bool enabled )

Stores the connection for the given ports if it doesn't exist, otherwise updates the existing connection.

Note
To be called from the main thread only.
Returns
The connection.

◆ add_default_connection()

const PortConnection * zrythm::dsp::PortConnectionsManager::add_default_connection ( const PortUuid & src,
const PortUuid & dest,
bool locked )
inline

Overload for default settings (multiplier = 1.0, enabled = true).

Definition at line 164 of file port_connections_manager.h.

◆ clear_all()

void zrythm::dsp::PortConnectionsManager::clear_all ( )
inline

Definition at line 220 of file port_connections_manager.h.

◆ connection_exists()

bool zrythm::dsp::PortConnectionsManager::connection_exists ( const PortUuid & src,
const PortUuid & dest ) const
inline

Definition at line 125 of file port_connections_manager.h.

◆ get_connection()

PortConnection * zrythm::dsp::PortConnectionsManager::get_connection ( const PortUuid & src,
const PortUuid & dest ) const
Parameters
src
dest
Returns
The connection, owned by this, or null.

◆ get_connection_count()

auto zrythm::dsp::PortConnectionsManager::get_connection_count ( ) const
inlinenoexcept

Definition at line 86 of file port_connections_manager.h.

◆ get_dests()

int zrythm::dsp::PortConnectionsManager::get_dests ( ConnectionsVector * arr,
const PortUuid & id ) const
inline

Definition at line 72 of file port_connections_manager.h.

◆ get_num_dests()

int zrythm::dsp::PortConnectionsManager::get_num_dests ( const PortUuid & id) const
inline

Definition at line 81 of file port_connections_manager.h.

◆ get_num_sources()

int zrythm::dsp::PortConnectionsManager::get_num_sources ( const PortUuid & id) const
inline

Definition at line 77 of file port_connections_manager.h.

◆ get_source_or_dest()

PortConnection * zrythm::dsp::PortConnectionsManager::get_source_or_dest ( const PortUuid & id,
bool sources ) const

Wrapper over get_sources_or_dests() that returns the first connection.

It is a programming error to call this for ports that are not expected to have exactly 1 matching connection.

Returns
The connection, owned by this, or null.

◆ get_sources()

int zrythm::dsp::PortConnectionsManager::get_sources ( ConnectionsVector * arr,
const PortUuid & id ) const
inline

Definition at line 67 of file port_connections_manager.h.

◆ get_sources_or_dests()

int zrythm::dsp::PortConnectionsManager::get_sources_or_dests ( ConnectionsVector * arr,
const PortUuid & id,
bool sources ) const

Adds the sources/destinations of id in the given array.

The returned instances of PortConnection are owned by this and must not be free'd.

Parameters
idThe identifier of the port to look for.
arrOptional array to fill.
sourcesTrue to look for sources, false for destinations.
Returns
The number of ports found.

◆ get_unlocked_sources_or_dests()

int zrythm::dsp::PortConnectionsManager::get_unlocked_sources_or_dests ( ConnectionsVector * arr,
const PortUuid & id,
bool sources ) const

Adds the sources/destinations of id in the given array.

The returned instances of PortConnection are owned by this and must not be free'd.

Parameters
idThe identifier of the port to look for.
arrOptional array to fill.
sourcesTrue to look for sources, false for destinations.
Returns
The number of ports found.

◆ regenerate_hashtables()

void zrythm::dsp::PortConnectionsManager::regenerate_hashtables ( )

Regenerates the hash tables.

Must be called when a change is made in the connections.

◆ remove_all_connections()

void zrythm::dsp::PortConnectionsManager::remove_all_connections ( const PortUuid & pi)

Disconnect all sources and dests of the given port identifier.

Note
To be called from the main thread only.

◆ remove_connection()

bool zrythm::dsp::PortConnectionsManager::remove_connection ( const PortUuid & src,
const PortUuid & dest )

Removes the connection for the given ports if it exists.

Note
To be called from the main thread only.
Returns
Whether a connection was removed.

◆ reset_connections_from_other()

void zrythm::dsp::PortConnectionsManager::reset_connections_from_other ( const PortConnectionsManager * other)

Removes all connections from this.

Parameters
srcIf non-nullptr, the connections are copied from this to this.

◆ update_connection()

bool zrythm::dsp::PortConnectionsManager::update_connection ( const PortConnection & before,
const PortConnection & after )

Replaces the given before connection with after.

Returns
Whether the connection was replaced.

Friends And Related Symbol Documentation

◆ from_json

void from_json ( const nlohmann::json & j,
PortConnectionsManager & pcm )
friend

Definition at line 232 of file port_connections_manager.h.

◆ to_json

void to_json ( nlohmann::json & j,
const PortConnectionsManager & pcm )
friend

Definition at line 228 of file port_connections_manager.h.


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