## BtSetup BtSetup — class with all machines and wires (BtMachine and BtWire) for a BtSong instance |

## Functions

gboolean | bt_setup_add_machine ()
gboolean | bt_setup_add_wire ()
BtMachine * | bt_setup_get_machine_by_id ()
BtMachine * | bt_setup_get_machine_by_type ()
GList * | bt_setup_get_machines_by_type ()
gchar * | bt_setup_get_unique_machine_id ()
BtWire * | bt_setup_get_wire_by_dst_machine ()
BtWire * | bt_setup_get_wire_by_machines ()
BtWire * | bt_setup_get_wire_by_src_machine ()
GList * | bt_setup_get_wires_by_dst_machine ()
GList * | bt_setup_get_wires_by_src_machine ()
BtSetup * | bt_setup_new ()
void | bt_setup_remember_missing_machine ()
void | bt_setup_remove_machine ()
void | bt_setup_remove_wire ()

## Properties

gpointer | machines | Read
gpointer | missing-machines | Read
gpointer | properties | Read
BtSong * | song | Read / Write / Construct Only
gpointer | wires | Read

## Signals

void | machine-added | No Hooks
void | machine-removed | No Hooks
void | wire-added | No Hooks
void | wire-removed | No Hooks

## Types and Values

struct | BtSetup

## Object Hierarchy

        GObject
        ╰── BtSetup

## Implemented Interfaces

BtSetup implements BtPersistence.

## Includes

    #include <libbtcore/core.h>

## Description

The setup manages virtual gear in a BtSong. This is a list of BtMachines that are used and the BtWires that connect them.

The setup manages the actual GStreamer GstPipeline content. Freshly created machines are not yet added to the pipeline. Only once a subgraph from a source is fully connected to the sink, that subgraph is added o the pipeline. Changing the machines and wires also works while the song is playing.

Applications can watch the GstObject:parent property to see whether a machine is physically inserted into the processing pipeline.

The setup takes ownership of the machines and wires. They are automatically added when they are created and destroyed together with the setup.

## Functions

### bt_setup_add_machine ()

    gboolean
    bt_setup_add_machine (const BtSetup * const self,
                          const BtMachine * const machine);

Let the setup know that the supplied machine is now part of the song.

#### Parameters

self | the setup to add the machine to |
machine | the new machine instance |

#### Returns

return `TRUE`, if the machine can be added. Returns `FALSE` if the machine is currently added to the setup.

### bt_setup_add_wire ()

    gboolean
    bt_setup_add_wire (const BtSetup * const self,
                       const BtWire * const wire);

Let the setup know that the supplied wire is now part of the song.

#### Parameters

self | the setup to add the wire to |
wire | the new wire instance |

#### Returns

returns `TRUE`, if the wire is added. Returns `FALSE`, if the setup contains a wire which is linked between the same src and dst machines (cycle check).

### bt_setup_get_machine_by_id ()

    BtMachine *
    bt_setup_get_machine_by_id (const BtSetup * const self,
                                const gchar * const id);

Search the setup for a machine by the supplied id. The machine must have been added previously to this setup with `bt_setup_add_machine()`.

#### Parameters

self | the setup to search for the machine |
id | the identifier of the machine |

#### Returns

BtMachine instance or `NULL` if not found. Unref the machine, when done with it.

[transfer full]

### bt_setup_get_machine_by_type ()

    BtMachine *
    bt_setup_get_machine_by_type (const BtSetup * const self,
                                  const GType type);

Search the setup for the first machine with the given type. The machine must have been added previously to this setup with `bt_setup_add_machine()`.

#### Parameters

self | the setup to search for the machine |
type | the gobject type (sink,processor,source) |

#### Returns

BtMachine instance or `NULL` if not found. Unref the machine, when done with it.

[transfer full]

### bt_setup_get_machines_by_type ()

    GList *
    bt_setup_get_machines_by_type (const BtSetup * const self,
                                   const GType type);

Gathers all machines of the given type from the setup.

#### Parameters

self | the setup to search for the machine |
type | the gobject type (sink,processor,source) |

#### Returns

the list instance or `NULL` if not found. Free the list (and unref the machines), when done with it.

[element-type BuzztraxCore.Machine][transfer full]

### bt_setup_get_unique_machine_id ()

    gchar *
    bt_setup_get_unique_machine_id (const BtSetup * const self,
                                    const gchar * const base_name);

The function makes the supplied base_name unique in this setup by eventually adding a number postfix. This method should be used when adding new machines.

#### Parameters

self | the setup for which the name should be unique |
base_name | the leading name part |

#### Returns

the newly allocated unique name.

[transfer full]

### bt_setup_get_wire_by_dst_machine ()

    BtWire *
    bt_setup_get_wire_by_dst_machine (const BtSetup * const self,
                                      const BtMachine * const dst);

Searches for the first wire in setup that uses the given BtMachine as a target. In other words - it returns the first wire that ends at the given BtMachine.

#### Parameters

self | the setup to search for the wire |
dst | the machine that is at the dst end of the wire |

#### Returns

the BtWire or `NULL`. Unref the wire, when done with it.

[transfer full]

### bt_setup_get_wire_by_machines ()

    BtWire *
    bt_setup_get_wire_by_machines (const BtSetup * const self,
                                   const BtMachine * const src,
                                   const BtMachine * const dst);

Searches for a wire in setup that uses the given BtMachine instances as a source and dest.

#### Parameters

self | the setup to search for the wire |
src | the machine that is at the src end of the wire |
dst | the machine that is at the dst end of the wire |

#### Returns

the BtWire or `NULL`. Unref the wire, when done with it.

[transfer full]

### bt_setup_get_wire_by_src_machine ()

    BtWire *
    bt_setup_get_wire_by_src_machine (const BtSetup * const self,
                                      const BtMachine * const src);

Searches for the first wire in setup that uses the given BtMachine as a source. In other words - it returns the first wire that starts at the given BtMachine.

#### Parameters

self | the setup to search for the wire |
src | the machine that is at the src end of the wire |

#### Returns

the BtWire or `NULL`. Unref the wire, when done with it.

[transfer full]

### bt_setup_get_wires_by_dst_machine ()

    GList *
    bt_setup_get_wires_by_dst_machine (const BtSetup * const self,
                                       const BtMachine * const dst);

Searches for all wires in setup that use the given BtMachine as a target.

#### Parameters

self | the setup to search for the wire |
dst | the machine that is at the dst end of the wire |

#### Returns

a GList with the BtWires or `NULL`. Free the list (and unref the wires), when done with it.

[element-type BuzztraxCore.Wire][transfer full]

### bt_setup_get_wires_by_src_machine ()

    GList *
    bt_setup_get_wires_by_src_machine (const BtSetup * const self,
                                       const BtMachine * const src);

Searches for all wires in setup that use the given BtMachine as a source.

#### Parameters

self | the setup to search for the wire |
src | the machine that is at the src end of the wire |

#### Returns

a GList with the BtWires or `NULL`. Free the list (and unref the wires), when done with it.

[element-type BuzztraxCore.Wire][transfer full]

### bt_setup_new ()

    BtSetup *
    bt_setup_new (const BtSong * const song);

Create a new instance

#### Parameters

song | the song the new instance belongs to |

#### Returns

the new instance or `NULL` in case of an error

### bt_setup_remember_missing_machine ()

    void
    bt_setup_remember_missing_machine (const BtSetup * const self,
                                       const gchar * const str);

Loaders can use this function to collect information about machines that failed to load. The front-end can access this later by reading BtSetup::missing-machines property.

#### Parameters

self | the setup |
str | human readable description of the missing machine |

### bt_setup_remove_machine ()

    void
    bt_setup_remove_machine (const BtSetup * const self,
                             const BtMachine * const machine);

Let the setup know that the supplied machine is removed from the song.

#### Parameters

self | the setup to remove the machine from |
machine | the machine instance to remove |

### bt_setup_remove_wire ()

    void
    bt_setup_remove_wire (const BtSetup * const self,
                          const BtWire * const wire);

Let the setup know that the supplied wire is removed from the song.

#### Parameters

self | the setup to remove the wire from |
wire | the wire instance to remove |

## Types and Values

### struct BtSetup

    struct BtSetup;

virtual hardware setup (contains BtMachine and BtWire objects)

## Property Details

### The `“machines”` property

      “machines”                 gpointer

A copy of the list of machines.

Flags: Read

### The `“missing-machines”` property

      “missing-machines”         gpointer

The list of missing machines, don't change.

Flags: Read

### The `“properties”` property

      “properties”               gpointer

hashtable of setup properties.

Flags: Read

### The `“song”` property

      “song”                     BtSong *

Set song object, the setup belongs to.

Flags: Read / Write / Construct Only

### The `“wires”` property

      “wires”                    gpointer

A copy of the list of wires.

Flags: Read

## Signal Details

### The `“machine-added”` signal

    void
    user_function (BtSetup   *self,
                   BtMachine *machine,
                   gpointer   user_data)

A new machine item has been added to the setup.

#### Parameters

self | the setup object that emitted the signal |
machine | the new machine |
user_data | user data set when the signal handler was connected. |

Flags: No Hooks

### The `“machine-removed”` signal

    void
    user_function (BtSetup   *self,
                   BtMachine *machine,
                   gpointer   user_data)

A machine item has been removed from the setup.

#### Parameters

self | the setup object that emitted the signal |
machine | the old machine |
user_data | user data set when the signal handler was connected. |

Flags: No Hooks

### The `“wire-added”` signal

    void
    user_function (BtSetup *self,
                   BtWire  *wire,
                   gpointer user_data)

A new wire item has been added to the setup.

#### Parameters

self | the setup object that emitted the signal |
wire | the new wire |
user_data | user data set when the signal handler was connected. |

Flags: No Hooks

### The `“wire-removed”` signal

    void
    user_function (BtSetup *self,
                   BtWire  *wire,
                   gpointer user_data)

A wire item has been removed from the setup.

#### Parameters

self | the setup object that emitted the signal |
wire | the old wire |
user_data | user data set when the signal handler was connected. |

Flags: No Hooks