| 1 |
# Copyright (C) 2005 Software Freedom Law Center, Inc. |
|---|
| 2 |
# Author: Bradley M. Kuhn <bkuhn@softwarefreedom.org> |
|---|
| 3 |
# |
|---|
| 4 |
# This software gives you freedom; it is licensed to you under version |
|---|
| 5 |
# 3 of the GNU Affero General Public License. |
|---|
| 6 |
# |
|---|
| 7 |
# This software is distributed WITHOUT ANY WARRANTY, without even the |
|---|
| 8 |
# implied warranties of MERCHANTABILITY and FITNESS FOR A PARTICULAR |
|---|
| 9 |
# PURPOSE. See the GNU Affero General Public License for further |
|---|
| 10 |
# details. |
|---|
| 11 |
# |
|---|
| 12 |
# You should have received a copy of the GNU Affero General Public |
|---|
| 13 |
# License, version 3 along with this software. If not, see |
|---|
| 14 |
# <http://www.gnu.org/licenses/>. |
|---|
| 15 |
use strict; |
|---|
| 16 |
use warnings; |
|---|
| 17 |
|
|---|
| 18 |
package SFLC::TimeTracker::Output; |
|---|
| 19 |
|
|---|
| 20 |
use Carp; |
|---|
| 21 |
|
|---|
| 22 |
sub new { |
|---|
| 23 |
my($class) = shift; |
|---|
| 24 |
my(%input) = @_; |
|---|
| 25 |
|
|---|
| 26 |
if (not exists $input{status}) { |
|---|
| 27 |
croak "invalid for 'status' in $class"; |
|---|
| 28 |
} |
|---|
| 29 |
|
|---|
| 30 |
if (not exists $input{type}) { |
|---|
| 31 |
croak "invalid for 'type' in $class"; |
|---|
| 32 |
} |
|---|
| 33 |
if (not defined $input{object} and not ref $input{object}) { |
|---|
| 34 |
croak "invalid or non existant value for 'object' in $class"; |
|---|
| 35 |
} |
|---|
| 36 |
return bless { object => $input{object}, type => $input{type}, |
|---|
| 37 |
status => $input{status} }, $class; |
|---|
| 38 |
} |
|---|
| 39 |
|
|---|
| 40 |
sub object { |
|---|
| 41 |
my $self = shift; |
|---|
| 42 |
return $self->{object}; |
|---|
| 43 |
} |
|---|
| 44 |
sub type { |
|---|
| 45 |
my $self = shift; |
|---|
| 46 |
return $self->{type}; |
|---|
| 47 |
} |
|---|
| 48 |
sub status { |
|---|
| 49 |
my $self = shift; |
|---|
| 50 |
return $self->{status}; |
|---|
| 51 |
} |
|---|
| 52 |
sub get { |
|---|
| 53 |
my($self, $field) = @_; |
|---|
| 54 |
if ($field =~ /^(?:status|type|object)$/) { |
|---|
| 55 |
return $self->{$field}; |
|---|
| 56 |
} else { |
|---|
| 57 |
croak "invalid field, \"$field\""; |
|---|
| 58 |
} |
|---|
| 59 |
} |
|---|
| 60 |
sub set { |
|---|
| 61 |
my($self, $field, $value) = @_; |
|---|
| 62 |
if ($field =~ /^(?:status|object)$/) { |
|---|
| 63 |
$self->{$field} = $value; |
|---|
| 64 |
} else { |
|---|
| 65 |
croak "invalid field, \"$field\""; |
|---|
| 66 |
} |
|---|
| 67 |
} |
|---|
| 68 |
sub prettyPrintIRC ($$) { |
|---|
| 69 |
my($self, $now) = @_; |
|---|
| 70 |
|
|---|
| 71 |
return "Got status of " . $self->status . " and type of " . $self->type |
|---|
| 72 |
. " on $now, and called prettyPrintIRC in base class. REPORT THIS!"; |
|---|
| 73 |
} |
|---|
| 74 |
# action should return 1 if the action needed to take on this Output item |
|---|
| 75 |
# is complete and therefore we can tell our container that it need not worry |
|---|
| 76 |
# about us anymore after giving output. |
|---|
| 77 |
sub action { |
|---|
| 78 |
return { }; |
|---|
| 79 |
} |
|---|
| 80 |
|
|---|
| 81 |
1; |
|---|
| 82 |
__END__ |
|---|
| 83 |
|
|---|
| 84 |
# |
|---|
| 85 |
# Local variables: |
|---|
| 86 |
# compile-command: "perl -I ../../../Modules -c Output.pm" |
|---|
| 87 |
# End: |
|---|