90 lines
2.0 KiB
C++
90 lines
2.0 KiB
C++
#ifndef PORTMANAGER_H
|
|
#define PORTMANAGER_H
|
|
|
|
#include <jack/jack.h>
|
|
#include <vector>
|
|
#include "port.h"
|
|
|
|
struct Alias
|
|
{
|
|
std::string m_match;
|
|
std::string m_replace;
|
|
|
|
Alias(std::string match, std::string replace);
|
|
bool Match(std::string name);
|
|
std::string Replace(std::string name);
|
|
};
|
|
|
|
struct Connection
|
|
{
|
|
std::string m_match1;
|
|
std::string m_match2;
|
|
int m_disconnect:1;
|
|
int m_continue:1;
|
|
int m_condition:1;
|
|
|
|
bool Match(std::string port1, std::string port2);
|
|
};
|
|
|
|
typedef std::vector<Alias> AliasList;
|
|
typedef std::vector<Connection> ConnectionList;
|
|
|
|
class PortManager
|
|
{
|
|
public:
|
|
ClientList m_clients;
|
|
PortList m_ports;
|
|
AliasList m_aliases;
|
|
|
|
public:
|
|
void Refresh();
|
|
void RefreshConnections();
|
|
void Add(jack_port_t *port);
|
|
void Delete(jack_port_t *port);
|
|
|
|
void Connect(jack_port_t *port_a, jack_port_t *port_b);
|
|
void Disconnect(jack_port_t *port_a, jack_port_t *port_b);
|
|
|
|
void Rename(jack_port_t *port);
|
|
bool PollPortRenames();
|
|
|
|
Client *FindOrMakeClient(std::string name, bool is_input, bool is_midi);
|
|
PortGroup *FindOrMakeGroup(Client *client, std::string name);
|
|
Port *FindPort(jack_port_t *port);
|
|
|
|
void Sort();
|
|
|
|
void ToggleConnect(Port *a, Port *b);
|
|
void ToggleConnect(Port *a, PortGroup *b);
|
|
void ToggleConnect(PortGroup *a, Port *b);
|
|
void ToggleConnect(PortGroup *a, PortGroup *b);
|
|
void ToggleConnect(Base *a, Base *b)
|
|
{
|
|
switch (a->get_type()) {
|
|
case 1:
|
|
switch (b->get_type()) {
|
|
case 1: ToggleConnect((PortGroup *)a, (PortGroup *)b); break;
|
|
case 2: ToggleConnect((PortGroup *)a, (Port *)b); break;
|
|
}
|
|
break;
|
|
case 2:
|
|
switch (b->get_type()) {
|
|
case 1: ToggleConnect((Port *)a, (PortGroup *)b); break;
|
|
case 2: ToggleConnect((Port *)a, (Port *)b); break;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
std::string GetAlias(std::string port_name);
|
|
void AliasBay(jack_port_t *port, int num_aliases, char *aliases[2]);
|
|
void AliasClear();
|
|
void AliasAdd(std::string source, std::string target);
|
|
|
|
AliasList &AliasGetList() { return m_aliases; }
|
|
};
|
|
|
|
extern PortManager pm;
|
|
|
|
#endif // PORTMANAGER_H
|