Commit | Line | Data |
dd3b58b0 |
1 | package Text::Tradition::Collation; |
2 | use Moose; |
3 | |
4 | has 'graph' => ( |
5 | is => 'ro', |
784877d9 |
6 | isa => 'Graph::Easy', |
7 | writer => '_init_graph', |
8 | handles => { |
9 | add_node => 'add_reading', |
10 | del_node => 'del_reading', |
11 | add_edge => 'add_path', |
12 | del_edge => 'del_path', |
13 | nodes => 'readings', |
14 | edges => 'paths', |
dd3b58b0 |
15 | ); |
784877d9 |
16 | |
dd3b58b0 |
17 | |
784877d9 |
18 | # TODO do we not have a way to access the parent object? |
dd3b58b0 |
19 | has 'tradition' => ( |
20 | is => 'ro', |
21 | isa => 'Text::Tradition', |
22 | ); |
23 | |
24 | # The collation can be created two ways: |
25 | # 1. Collate a set of witnesses (with CollateX I guess) and process |
26 | # the results as in 2. |
27 | # 2. Read a pre-prepared collation in one of a variety of formats, |
28 | # and make the graph from that. |
29 | |
30 | # The graph itself will (for now) be immutable, and the positions |
31 | # within the graph will also be immutable. We need to calculate those |
32 | # positions upon graph construction. The equivalences between graph |
33 | # nodes will be mutable, entirely determined by the user (or possibly |
34 | # by some semantic pre-processing provided by the user.) So the |
35 | # constructor should just make an empty equivalences object. The |
36 | # constructor will also need to make the witness objects, if we didn't |
37 | # come through option 1. |
38 | |
784877d9 |
39 | # TODO BUILDARGS |
40 | |
41 | # Wrappers around some methods |
42 | |
43 | sub merge_readings { |
44 | my $self = shift; |
45 | my $first_node = shift; |
46 | my $second_node = shift; |
47 | $first_node->merge_from( $second_node ); |
48 | unshift( @_, $first_node, $second_node ); |
49 | return $self->graph->merge_nodes( @_ ); |
50 | } |
51 | |
dd3b58b0 |
52 | no Moose; |
53 | __PACKAGE__->meta->make_immutable; |