Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move event storage out of TB2::History and into a new TB2::History::E…
…ventStorage object. Then we can add an EventStorage that throws out events. This was the last use of TB2::Stack and TB2::StackBuilder, so they're removed. For #198
- Loading branch information
Showing
7 changed files
with
159 additions
and
347 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
package TB2::History::EventStorage; | ||
|
||
use TB2::Mouse; | ||
|
||
=head1 NAME | ||
TB2::History::EventStorage - Store all events | ||
=head1 SYNOPSIS | ||
my $storage = TB2::History::EventStorage->new; | ||
$storage->event_push($event); | ||
my $events = $storage->events; | ||
my $results = $storage->results; | ||
=head1 DESCRIPTION | ||
This object stores L<TB2::Event>s. | ||
=head2 Constructors | ||
=head3 new | ||
my $storage = TB2::History::EventStorage->new; | ||
Create a new storage object. | ||
=head2 Methods | ||
=head3 events | ||
my $events = $storage->events; | ||
Returns all L<TB2::Event>s pushed in so far. | ||
Do I<NOT> alter this array directly. Use L<events_push>. | ||
=head3 results | ||
my $results = $storage->results; | ||
Returns just the L<TB2::Result>s pushed in so far. | ||
Do I<NOT> alter this array directly. Use L<events_push>. | ||
=cut | ||
|
||
has events => | ||
is => 'ro', | ||
isa => 'ArrayRef[TB2::Event]', | ||
default => sub { [] } | ||
; | ||
|
||
has results => | ||
is => 'ro', | ||
isa => 'ArrayRef[TB2::Result]', | ||
default => sub { [] } | ||
; | ||
|
||
|
||
=head3 events_push | ||
$storage->events_push(@events); | ||
Add any number of @events to C<< $storage->events >>. | ||
=cut | ||
|
||
sub events_push { | ||
my $self = shift; | ||
|
||
push @{$self->events}, @_; | ||
push @{$self->results}, grep $_->isa("TB2::Result::Base"), @_; | ||
|
||
return; | ||
} | ||
|
||
|
||
=head1 SEE ALSO | ||
L<TB2::History::NoEventStorage> is like EventStorage but it silently | ||
throws away all events. Saves space. | ||
=cut | ||
|
||
|
||
1; |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.