Vuo  2.3.2
Classes | Public Member Functions | Friends | List of all members
VuoCompilerCompositionDiff Class Reference

Description

Computes the diff between composition versions before and after a live-editing reload.

Definition at line 20 of file VuoCompilerCompositionDiff.hh.

Public Member Functions

string diff (const string &oldCompositionGraphvizDeclaration, VuoCompilerComposition *newComposition, VuoCompiler *compiler)
 Returns a JSON-formatted comparison between the old and the new composition, including subcompositions. More...
 
void addNodeReplacement (const string &compositionIdentifier, const string &oldNodeIdentifier, const string &newNodeIdentifier)
 Adds a mapping for a node replaced in a composition. More...
 
void addNodeReplacement (const string &compositionIdentifier, const string &oldNodeIdentifier, const string &newNodeIdentifier, const map< string, string > &oldAndNewPortNames)
 Adds a mapping for a node replaced in a composition. More...
 
void addNodeClassReplacement (VuoCompilerNodeClass *oldNodeClass, VuoCompilerNodeClass *newNodeClass)
 Adds a mapping for a node class replaced with a new implementation. More...
 
void addModuleReplacement (const string &moduleKey)
 Adds a mapping for a module replaced with a new implementation. More...
 
void addRefactoring (const string &compositionIdentifier, const set< VuoCompilerNode * > &nodesMoved, VuoCompilerNode *subcompositionMovedTo)
 Adds a mapping for nodes refactored into a subcomposition. More...
 
set< string > getModuleKeysReplaced (void) const
 Returns the names of all node classes and other modules being replaced with a new implementation. More...
 

Friends

class TestVuoCompilerComposition
 
bool operator< (const NodeReplacement &lhs, const NodeReplacement &rhs)
 Needed so this type can be used in STL containers. More...
 
bool operator< (const NodeClassReplacement &lhs, const NodeClassReplacement &rhs)
 Needed so this type can be used in STL containers. More...
 
bool operator< (const Refactoring &lhs, const Refactoring &rhs)
 Needed so this type can be used in STL containers. More...
 

Member Function Documentation

◆ addModuleReplacement()

void VuoCompilerCompositionDiff::addModuleReplacement ( const string &  moduleKey)

Adds a mapping for a module replaced with a new implementation.

If not calling addNodeClassReplacement, call this.

Definition at line 701 of file VuoCompilerCompositionDiff.cc.

◆ addNodeClassReplacement()

void VuoCompilerCompositionDiff::addNodeClassReplacement ( VuoCompilerNodeClass oldNodeClass,
VuoCompilerNodeClass newNodeClass 
)

Adds a mapping for a node class replaced with a new implementation.

This class does not keep references to oldNodeClass and newNodeClass. It's safe to delete them after calling this function.

Definition at line 666 of file VuoCompilerCompositionDiff.cc.

◆ addNodeReplacement() [1/2]

void VuoCompilerCompositionDiff::addNodeReplacement ( const string &  compositionIdentifier,
const string &  oldNodeIdentifier,
const string &  newNodeIdentifier 
)

Adds a mapping for a node replaced in a composition.

Ports in the old node are mapped to identically-named ports in the new node.

Definition at line 636 of file VuoCompilerCompositionDiff.cc.

◆ addNodeReplacement() [2/2]

void VuoCompilerCompositionDiff::addNodeReplacement ( const string &  compositionIdentifier,
const string &  oldNodeIdentifier,
const string &  newNodeIdentifier,
const map< string, string > &  oldAndNewPortNames 
)

Adds a mapping for a node replaced in a composition.

Definition at line 649 of file VuoCompilerCompositionDiff.cc.

◆ addRefactoring()

void VuoCompilerCompositionDiff::addRefactoring ( const string &  compositionIdentifier,
const set< VuoCompilerNode * > &  nodesMoved,
VuoCompilerNode subcompositionMovedTo 
)

Adds a mapping for nodes refactored into a subcomposition.

Parameters
compositionIdentifierThe composition containing the nodes in the old composition.
nodesMovedThe nodes factored out, moved inside a subcomposition in the new composition.
subcompositionMovedToThe subcomposition in the new composition.

Definition at line 713 of file VuoCompilerCompositionDiff.cc.

◆ diff()

string VuoCompilerCompositionDiff::diff ( const string &  oldCompositionGraphvizDeclaration,
VuoCompilerComposition newComposition,
VuoCompiler compiler 
)

Returns a JSON-formatted comparison between the old and the new composition, including subcompositions.

The comparison is a JSON array loosely based on the JSON Patch format. The key used for each node is a path constructed from its Graphviz identifier and the identifiers of the (sub)compositions containing the node. Unlike the examples below (spaced for readability), the returned string contains no whitespace.

The comparison follows the compiler's rule that the PublishedInputs and PublishedOutputs pseudo-nodes are either both present or both absent in a compiled composition.

Example:
// The new composition contains (added) node FireOnStart. The old composition contains (removed) node Round.
[
{"add" : "Top/FireOnStart"},
{"remove" : "Top/Round"}
]
Example:
// From the old composition to the new composition, a drawer has been expanded from 2 to 3 inputs.
[
{"replace" : "Top/MakeList1", "with" : "Top/MakeList2",
"ports" : [
{"map" : "1", "to" : "1"},
{"map" : "2", "to" : "2"},
{"map" : "list", "to" : "list}
]
}
]
Example:
// From the old to the new composition, the ports on a node have changed (some added, some removed)
// because its node class has been replaced with a new implementation. Port "keptPort" stays the same.
[
{"replace" : "Top/MyNode", "with" : "Top/MyNode",
"ports" : [
{"map" : "keptPort", "to" : "keptPort"}
]
}
]
Example:
// From the old to the new composition, a published input port has been added.
// Published input port "firstInput" and published output port "firstOutput" stay the same.
[
{"replace" : "Top/PublishedInputs", "with" : "Top/PublishedInputs",
"ports" : [
{"map" : "firstInput", "to" : "firstInput"}
]
},
{"replace" : "Top/PublishedOutputs", "with" : "Top/PublishedOutputs",
"ports" : [
{"map" : "firstOutput", "to" : "firstOutput"}
]
}
]
Example:
// From the old to the new composition, a published input port has been added.
// The old composition doesn't have any published ports.
[
{"add" : "Top/PublishedInputs"},
{"add" : "Top/PublishedOutputs"}
]
Example:
// From the old to the new composition, nodes have been refactored into a subcomposition.
[
{"add" : "Top/Sub"},
{"move" : "Top/Node1", "to" : "Top/Sub/Node1",
"ports" : [
{"copy" : "inputOnNode1", "to" : "Top/Sub:someInput"}
]
},
{"move" : "Top/Node2", "to" : "Top/Sub/Node2"
"ports" : [
{"copy" : "inputOnNode2", "to" : "Top/Sub:otherInput"}
]
}

This needs to be kept in sync with VuoCompositionDiff::findNode.

Definition at line 112 of file VuoCompilerCompositionDiff.cc.

◆ getModuleKeysReplaced()

set< string > VuoCompilerCompositionDiff::getModuleKeysReplaced ( void  ) const

Returns the names of all node classes and other modules being replaced with a new implementation.

Definition at line 729 of file VuoCompilerCompositionDiff.cc.

Friends And Related Function Documentation

◆ operator< [1/3]

bool operator< ( const NodeClassReplacement &  lhs,
const NodeClassReplacement &  rhs 
)
friend

Needed so this type can be used in STL containers.

Definition at line 599 of file VuoCompilerCompositionDiff.cc.

◆ operator< [2/3]

bool operator< ( const NodeReplacement &  lhs,
const NodeReplacement &  rhs 
)
friend

Needed so this type can be used in STL containers.

Definition at line 587 of file VuoCompilerCompositionDiff.cc.

◆ operator< [3/3]

bool operator< ( const Refactoring &  lhs,
const Refactoring &  rhs 
)
friend

Needed so this type can be used in STL containers.

Definition at line 607 of file VuoCompilerCompositionDiff.cc.


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