line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package TM::Tied::Topic; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
509
|
|
|
1
|
|
|
|
|
32
|
|
4
|
1
|
|
|
1
|
|
5
|
use Data::Dumper; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
46
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
3
|
use Tie::Hash; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
15
|
|
7
|
1
|
|
|
1
|
|
4
|
use base qw(Tie::StdHash); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
1169
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub STORE { |
10
|
0
|
|
|
0
|
|
|
my ($self, $key, $value) = @_; |
11
|
0
|
|
|
|
|
|
warn "STORE topic $key, not implemented"; |
12
|
0
|
|
|
|
|
|
return FETCH ($self, $key); |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
sub FETCH { |
15
|
0
|
|
|
0
|
|
|
my ($self, $key) = @_; |
16
|
|
|
|
|
|
|
# warn "FETCH topic '$key'"; |
17
|
|
|
|
|
|
|
|
18
|
0
|
0
|
0
|
|
|
|
if ($key =~ /^__/) { # internal information |
|
|
0
|
0
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
19
|
0
|
|
|
|
|
|
return undef ; # will not be passed on |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
} elsif ($key eq '!') { # just the id |
22
|
0
|
|
|
|
|
|
return $self->{__tid}; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
} elsif ($key eq '=') { # subject address |
25
|
0
|
|
|
|
|
|
return $self->{__tm}->toplet ($self->{__tid})->[TM->ADDRESS]; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
} elsif ($key eq '~') { # all indicators |
28
|
0
|
|
|
|
|
|
return [ @{ $self->{__tm}->toplet ($self->{__tid})->[TM->INDICATORS] } ]; # as copy |
|
0
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
} elsif ($key =~ /<->\s*(.+)/) { # we want to jump over assocs |
31
|
|
|
|
|
|
|
|
32
|
0
|
|
0
|
|
|
|
my $type = $self->{__tm}->tids ($1) || return undef; |
33
|
|
|
|
|
|
|
return [ |
34
|
0
|
|
|
|
|
|
map { new TM::Easy::Topic ($_, $self->{__tm}) } # create a new topic for ... |
|
0
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
grep { $_ ne $self->{__tid} } # ... those which are not me |
36
|
0
|
|
|
|
|
|
map { $self->{__tm}->get_players ($_) } # .... in all the players of .. |
37
|
|
|
|
|
|
|
$self->{__tm}->match (TM->FORALL, type => $type, # ... the assocs of this type ... |
38
|
|
|
|
|
|
|
iplayer => $self->{__tid} ) # I play in |
39
|
|
|
|
|
|
|
]; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
} elsif ($key =~ /^-(.*)_s$/ || $key =~ /\s*<-\s*(.*)_s$/) { # we follow a role towards an assoc, PLURAL |
42
|
0
|
|
0
|
|
|
|
my $role = $self->{__tm}->tids ($1) || return undef; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
return [ |
45
|
0
|
|
|
|
|
|
map { new TM::Easy::Association ($_->[TM->LID], $self->{__tm}) } |
|
0
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
$self->{__tm}->match (TM->FORALL, |
47
|
|
|
|
|
|
|
irole => $role, iplayer => $self->{__tid} ) # look for the assocs |
48
|
|
|
|
|
|
|
]; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
} elsif ($key =~ /^-(.*)$/ || $key =~ /\s*<-\s*(.*)$/) { # we follow a role towards an assoc |
51
|
0
|
|
0
|
|
|
|
my $role = $self->{__tm}->tids ($1) || return undef; |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
my ($a) = $self->{__tm}->match (TM->FORALL, |
54
|
|
|
|
|
|
|
irole => $role, iplayer => $self->{__tid} ); # look for the assocs |
55
|
0
|
|
|
|
|
|
return new TM::Easy::Association ($a->[TM->LID], $self->{__tm}); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
} elsif ($key =~ /^(.*)_s/) { # list of characteristics of this type, PLURAL |
58
|
0
|
|
0
|
|
|
|
my $type = $self->{__tm}->tids ($1) || return undef; |
59
|
|
|
|
|
|
|
return [ |
60
|
0
|
|
|
|
|
|
map { $_->[0] } # only the literals |
|
0
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
map { $_->[TM->PLAYERS]->[1] } # find the values |
62
|
|
|
|
|
|
|
$self->{__tm}->match (TM->FORALL, type => $type, |
63
|
|
|
|
|
|
|
irole => 'thing', iplayer => $self->{__tid} ) |
64
|
|
|
|
|
|
|
]; # look for the items |
65
|
|
|
|
|
|
|
} else { # singular interest |
66
|
0
|
|
0
|
|
|
|
my $type = $self->{__tm}->tids ($key) || return undef; |
67
|
0
|
|
|
|
|
|
my ($v) = |
68
|
0
|
|
|
|
|
|
map { $_->[0] } # only the literals |
69
|
0
|
|
|
|
|
|
map { $_->[TM->PLAYERS]->[1] } # find the values |
70
|
|
|
|
|
|
|
$self->{__tm}->match (TM->FORALL, type => $type, |
71
|
|
|
|
|
|
|
irole => 'thing', iplayer => $self->{__tid} ); # look for the items |
72
|
0
|
|
|
|
|
|
return $v; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
sub EXISTS { |
76
|
0
|
|
|
0
|
|
|
return FETCH @_; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
sub DEFINED { |
79
|
0
|
|
|
0
|
0
|
|
die "not implemented"; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
sub TIEHASH { |
82
|
0
|
|
|
0
|
|
|
my $self = bless {}, shift; |
83
|
0
|
|
|
|
|
|
$self->{__tid} = shift; |
84
|
0
|
|
|
|
|
|
$self->{__tm} = shift; |
85
|
0
|
|
|
|
|
|
return $self; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
1; |