Skip to content

Commit 44bade4

Browse files
committed
allow naming the tracer
1 parent 2432766 commit 44bade4

9 files changed

Lines changed: 29 additions & 25 deletions

js/module/array1d.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
function Array1DTracer(module) {
2-
return Array2DTracer.call(this);
1+
function Array1DTracer() {
2+
return Array2DTracer.apply(this, arguments);
33
}
44

55
Array1DTracer.prototype = $.extend(true, Object.create(Array2DTracer.prototype), {

js/module/array2d.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
function Array2DTracer(module) {
2-
if (Tracer.call(this)) {
1+
function Array2DTracer() {
2+
if (Tracer.apply(this, arguments)) {
33
Array2DTracer.prototype.init.call(this);
44
return true;
55
}

js/module/directed_graph.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
function DirectedGraphTracer(module) {
2-
if (Tracer.call(this)) {
1+
function DirectedGraphTracer() {
2+
if (Tracer.apply(this, arguments)) {
33
DirectedGraphTracer.prototype.init.call(this);
44
return true;
55
}

js/module/log_tracer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
function LogTracer(module) {
2-
if (Tracer.call(this)) {
1+
function LogTracer() {
2+
if (Tracer.apply(this, arguments)) {
33
LogTracer.prototype.init.call(this);
44
return true;
55
}

js/module/tracer.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
1-
function Tracer() {
1+
function Tracer(name) {
22
this.module = this.constructor;
33
this.capsule = tm.allocate(this);
44
$.extend(this, this.capsule);
5-
if (this.new) {
6-
Tracer.prototype.init.call(this);
7-
return true;
8-
}
9-
return false;
5+
this.setName(name);
6+
return this.new;
107
}
118

129
Tracer.prototype = {
1310
constructor: Tracer,
14-
init: function () {
15-
this.$container.append($('<span class="name">').text(this.name));
16-
},
1711
_setData: function () {
1812
var args = Array.prototype.slice.call(arguments);
1913
tm.pushStep(this.capsule, {type: 'setData', args: toJSON(args)});
@@ -37,6 +31,16 @@ Tracer.prototype = {
3731
break;
3832
}
3933
},
34+
setName: function (name) {
35+
var $name;
36+
if (this.new) {
37+
$name = $('<span class="name">');
38+
this.$container.append($name);
39+
} else {
40+
$name = this.$container.find('span.name');
41+
}
42+
$name.text(name || this.defaultName);
43+
},
4044
setData: function () {
4145
var data = toJSON(arguments);
4246
if (!this.new && this.lastData == data) return true;

js/module/tracer_manager.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ TracerManager.prototype = {
1515
module: tracer.module,
1616
tracer: tracer,
1717
allocated: true,
18-
name: null,
18+
defaultName: null,
1919
$container: $container,
2020
new: true
2121
};
@@ -41,7 +41,7 @@ TracerManager.prototype = {
4141
count++;
4242
selectedCapsule = this.add(newTracer);
4343
}
44-
selectedCapsule.name = newTracer.constructor.name + count;
44+
selectedCapsule.defaultName = newTracer.constructor.name + ' ' + count;
4545
return selectedCapsule;
4646
},
4747
deallocateAll: function () {

js/module/undirected_graph.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
function UndirectedGraphTracer(module) {
2-
if (DirectedGraphTracer.call(this)) {
1+
function UndirectedGraphTracer() {
2+
if (DirectedGraphTracer.apply(this, arguments)) {
33
UndirectedGraphTracer.prototype.init.call(this);
44
return true;
55
}

js/module/weighted_directed_graph.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
function WeightedDirectedGraphTracer(module) {
2-
if (DirectedGraphTracer.call(this)) {
1+
function WeightedDirectedGraphTracer() {
2+
if (DirectedGraphTracer.apply(this, arguments)) {
33
WeightedDirectedGraphTracer.prototype.init.call(this);
44
return true;
55
}

js/module/weighted_undirected_graph.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
function WeightedUndirectedGraphTracer(module) {
2-
if (WeightedDirectedGraphTracer.call(this)) {
1+
function WeightedUndirectedGraphTracer() {
2+
if (WeightedDirectedGraphTracer.apply(this, arguments)) {
33
WeightedUndirectedGraphTracer.prototype.init.call(this);
44
return true;
55
}

0 commit comments

Comments
 (0)