line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Tree::Template::Declare::DAG_Node; |
2
|
|
|
|
|
|
|
{ |
3
|
|
|
|
|
|
|
$Tree::Template::Declare::DAG_Node::DIST = 'Tree-Template-Declare'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
$Tree::Template::Declare::DAG_Node::VERSION = '0.7'; |
6
|
3
|
|
|
3
|
|
10
|
use strict; |
|
3
|
|
|
|
|
2
|
|
|
3
|
|
|
|
|
85
|
|
7
|
3
|
|
|
3
|
|
8
|
use warnings; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
59
|
|
8
|
3
|
|
|
3
|
|
9
|
use Carp; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
750
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new { |
11
|
4
|
|
|
4
|
0
|
5
|
my ($class,$node_class)=@_; |
12
|
4
|
|
50
|
|
|
603
|
$node_class||='Tree::DAG_Node'; |
13
|
|
|
|
|
|
|
|
14
|
4
|
50
|
|
|
|
194
|
eval "require $node_class" or ## no critic (ProhibitStringyEval) |
15
|
|
|
|
|
|
|
croak "Can't load $node_class: $@"; ## no critic (ProhibitPunctuationVars) |
16
|
|
|
|
|
|
|
|
17
|
4
|
|
|
|
|
54458
|
return bless {nc=>$node_class},$class; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub new_tree { |
21
|
4
|
|
|
4
|
0
|
5
|
my ($self)=@_; |
22
|
|
|
|
|
|
|
|
23
|
4
|
|
|
|
|
29
|
return bless [],'Tree::Template::Declare::DAG_Node::Tree'; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub finalize_tree { |
27
|
4
|
|
|
4
|
0
|
5
|
my ($self,$tree)=@_; |
28
|
|
|
|
|
|
|
|
29
|
4
|
|
|
|
|
19
|
return $tree->[0]; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub new_node { |
33
|
19
|
|
|
19
|
0
|
18
|
my ($self)=@_; |
34
|
|
|
|
|
|
|
|
35
|
19
|
|
|
|
|
52
|
return $self->{nc}->new(); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub add_child_node { |
39
|
19
|
|
|
19
|
0
|
17
|
my ($self,$parent,$child)=@_; |
40
|
|
|
|
|
|
|
|
41
|
19
|
100
|
|
|
|
89
|
if ($parent->isa('Tree::Template::Declare::DAG_Node::Tree')) { |
42
|
4
|
|
|
|
|
5
|
push @{$parent},$child; |
|
4
|
|
|
|
|
6
|
|
43
|
4
|
|
|
|
|
8
|
return $parent; |
44
|
|
|
|
|
|
|
} |
45
|
15
|
|
|
|
|
27
|
return $parent->add_daughter($child); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub set_node_name { |
49
|
19
|
|
|
19
|
0
|
22
|
my ($self,$node,$name)=@_; |
50
|
|
|
|
|
|
|
|
51
|
19
|
|
|
|
|
34
|
return $node->name($name); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub set_node_attributes { |
55
|
9
|
|
|
9
|
0
|
6
|
my ($self,$node,$attrs)=@_; |
56
|
|
|
|
|
|
|
|
57
|
9
|
|
|
|
|
15
|
my %all_attributes=( |
58
|
9
|
|
|
|
|
40
|
%{$node->attributes}, |
59
|
9
|
|
|
|
|
7
|
%{$attrs}, |
60
|
|
|
|
|
|
|
); |
61
|
|
|
|
|
|
|
|
62
|
9
|
|
|
|
|
15
|
return $node->attributes(\%all_attributes); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
1; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=pod |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=encoding UTF-8 |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 NAME |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Tree::Template::Declare::DAG_Node - adaptor for Tree::DAG_Node |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 VERSION |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
version 0.7 |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 SYNOPSIS |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
See L. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 SPECIFICITIES |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
This module will build trees using L. You can make it |
86
|
|
|
|
|
|
|
use another module (assuming it has the same interface, for example |
87
|
|
|
|
|
|
|
L) by passing the class name to the C |
88
|
|
|
|
|
|
|
method. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
use Tree::Template::Declare builder => '+DAG_Node'; # default |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
use Tree::Template::Declare builder => |
93
|
|
|
|
|
|
|
Tree::Template::Declare::DAG_Node->new('Tree::DAG_Node::XPath'); |
94
|
|
|
|
|
|
|
# custom class |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=for Pod::Coverage add_child_node finalize_tree new new_node new_tree set_node_attributes set_node_name |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 AUTHOR |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Gianni Ceccarelli |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
This software is copyright (c) 2015 by Gianni Ceccarelli . |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
107
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=cut |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
__END__ |