| 1 | package IDS::Algorithm::Template; | ||
| 2 | use base qw(IDS::Algorithm); | ||
| 3 | $IDS::Algorithm::Template::VERSION = "1.0"; | ||
| 4 | |||
| 5 | =head1 NAME | ||
| 6 | |||
| 7 | IDS::Algorithm::Template - A template for an IDS algorithm for use with | ||
| 8 | IDS::Test. | ||
| 9 | |||
| 10 | =head1 SYNOPSIS | ||
| 11 | |||
| 12 | A usage synopsis would go here. Since it is not here, read on. | ||
| 13 | |||
| 14 | =head1 DESCRIPTION | ||
| 15 | |||
| 16 | See IDS::Algorithm.pm docs for any functions not described here. | ||
| 17 | |||
| 18 | =cut | ||
| 19 | |||
| 20 | use strict; | ||
| 21 | use warnings; | ||
| 22 | use Carp qw(cluck carp confess); | ||
| 23 | |||
| 24 | sub param_options { | ||
| 25 | my $self = shift; | ||
| 26 | |||
| 27 | return ( | ||
| 28 | "Template_verbose=i" => \${$self->{"params"}}{"verbose"}, | ||
| 29 | "ids_state=s" => \${$self->{"params"}}{"state_file"}, | ||
| 30 | ); | ||
| 31 | } | ||
| 32 | |||
| 33 | sub default_parameters { | ||
| 34 | my $self = shift; | ||
| 35 | |||
| 36 | %{$self->{"params"}} = ( | ||
| 37 | "verbose" => 1, | ||
| 38 | "state_file" => 0, | ||
| 39 | ); | ||
| 40 | } | ||
| 41 | |||
| 42 | sub initialize { | ||
| 43 | my $self = shift; | ||
| 44 | |||
| 45 | warn *initialize{PACKAGE} . "::initialize not yet written\n"; | ||
| 46 | } | ||
| 47 | |||
| 48 | sub save { | ||
| 49 | my $self = shift; | ||
| 50 | my $fname = $self->find_fname(shift); | ||
| 51 | defined($fname) && $fname or | ||
| 52 | confess *save{PACKAGE} . "::save missing filename"; | ||
| 53 | my $fh = to_fh($fname, ">"); | ||
| 54 | |||
| 55 | confess *save{PACKAGE} . "::save not yet written\n"; | ||
| 56 | } | ||
| 57 | |||
| 58 | sub load { | ||
| 59 | my $self = shift; | ||
| 60 | my $fname = $self->find_fname(shift); | ||
| 61 | $fname or | ||
| 62 | confess *load{PACKAGE} . "::load missing filename"; | ||
| 63 | my $fh = to_fh($fname, "<"); | ||
| 64 | |||
| 65 | confess *load{PACKAGE} . "::load not yet written\n"; | ||
| 66 | } | ||
| 67 | |||
| 68 | sub test { | ||
| 69 | my $self = shift; | ||
| 70 | my $tokensref = shift or | ||
| 71 | confess "bug: missing tokensref to ", *test{PACKAGE} . "::test"; | ||
| 72 | my $string = shift or | ||
| 73 | confess "bug: missing string to ", *test{PACKAGE} . "::test"; | ||
| 74 | my $instance = shift or | ||
| 75 | confess "bug: missing instance to ", *test{PACKAGE} . "::test"; | ||
| 76 | |||
| 77 | confess *test{PACKAGE} . "::test not yet written\n"; | ||
| 78 | } | ||
| 79 | |||
| 80 | sub add { | ||
| 81 | my $self = shift; | ||
| 82 | my $tokensref = shift or | ||
| 83 | confess "bug: missing tokensref to ", *add{PACKAGE} . "::add"; | ||
| 84 | my $string = shift or | ||
| 85 | confess "bug: missing string to ", *add{PACKAGE} . "::add"; | ||
| 86 | my $instance = shift or | ||
| 87 | confess "bug: missing instance to ", *add{PACKAGE} . "::add"; | ||
| 88 | |||
| 89 | confess *add{PACKAGE} . "::add not yet written\n"; | ||
| 90 | } | ||
| 91 | |||
| 92 | =head1 AUTHOR INFORMATION | ||
| 93 | |||
| 94 | Copyright 2005-2007, Kenneth Ingham. All rights reserved. | ||
| 95 | |||
| 96 | This library is free software; you can redistribute it and/or modify | ||
| 97 | it under the same terms as Perl itself. | ||
| 98 | |||
| 99 | Address bug reports and comments to: ids_test at i-pi.com. When sending | ||
| 100 | bug reports, please provide the versions of IDS::Test.pm, IDS::Algorithm.pm, | ||
| 101 | IDS::DataSource.pm, the version of Perl, and the name and version of the | ||
| 102 | operating system you are using. Since Kenneth is a PhD student, the | ||
| 103 | speed of the reponse depends on how the research is proceeding. | ||
| 104 | |||
| 105 | =head1 BUGS | ||
| 106 | |||
| 107 | Please report them. | ||
| 108 | |||
| 109 | =head1 SEE ALSO | ||
| 110 | |||
| 111 | L<IDS::Test>, L<IDS::DataSource>, L<IDS::Algorithm> | ||
| 112 | |||
| 113 | =cut | ||
| 114 | |||
| 115 | 1; |