Skip to content

Commit

Permalink
Referse connection API
Browse files Browse the repository at this point in the history
  • Loading branch information
SirBob01 committed May 17, 2023
1 parent 65a555b commit 5c15a60
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
18 changes: 9 additions & 9 deletions src/Sound/EffectNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Dynamo::Sound {
if (visited.count(&node) > 0) {
return true;
}
for (EffectNode &child : node._outgoing) {
for (EffectNode &child : node._dependencies) {
stack.push_back(child);
}
visited.insert(&node);
Expand All @@ -21,20 +21,20 @@ namespace Dynamo::Sound {
}

void EffectNode::connect(EffectNode &destination) {
_outgoing.push_back(destination);
_dependencies.push_back(destination);
if (has_cycles()) {
Log::error("Jukebox EffectNode graph disallows cycles.");
}
}

void EffectNode::disconnect() { _outgoing.clear(); }
void EffectNode::disconnect() { _dependencies.clear(); }

void EffectNode::disconnect(EffectNode &destination) {
auto it = _outgoing.begin();
while (it != _outgoing.end()) {
EffectNode &node = *it;
if (&node == &destination) {
it = _outgoing.erase(it);
void EffectNode::disconnect(EffectNode &node) {
auto it = _dependencies.begin();
while (it != _dependencies.end()) {
EffectNode &curr = *it;
if (&curr == &node) {
it = _dependencies.erase(it);
return;
} else {
it++;
Expand Down
16 changes: 8 additions & 8 deletions src/Sound/EffectNode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace Dynamo::Sound {
*
*/
class EffectNode {
std::vector<std::reference_wrapper<EffectNode>> _outgoing;
std::vector<std::reference_wrapper<EffectNode>> _dependencies;

private:
/**
Expand All @@ -32,26 +32,26 @@ namespace Dynamo::Sound {
virtual ~EffectNode() = default;

/**
* @brief Connect an outgoing EffectNode.
* @brief Connect a dependency.
*
* The resulting graph must not result in a cycle.
*
* @param destination
* @param node
*/
void connect(EffectNode &destination);
void connect(EffectNode &node);

/**
* @brief Disconnect all outgoing nodes.
* @brief Disconnect all dependencies.
*
*/
void disconnect();

/**
* @brief Disconnect an outgoing node.
* @brief Disconnect a dependency.
*
* @param destination
* @param node
*/
void disconnect(EffectNode &destination);
void disconnect(EffectNode &node);

/**
* @brief Run the Sound through the graph rooted at this node.
Expand Down

0 comments on commit 5c15a60

Please sign in to comment.