| 1 | # ------------------------------------------------------------------------------ |
|---|
| 2 | # Copyright (C) 2006-2021 British Crown (Met Office) & Contributors. |
|---|
| 3 | # |
|---|
| 4 | # This file is part of FCM, tools for managing and building source code. |
|---|
| 5 | # |
|---|
| 6 | # FCM is free software: you can redistribute it and/or modify |
|---|
| 7 | # it under the terms of the GNU General Public License as published by |
|---|
| 8 | # the Free Software Foundation, either version 3 of the License, or |
|---|
| 9 | # (at your option) any later version. |
|---|
| 10 | # |
|---|
| 11 | # FCM is distributed in the hope that it will be useful, |
|---|
| 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 14 | # GNU General Public License for more details. |
|---|
| 15 | # |
|---|
| 16 | # You should have received a copy of the GNU General Public License |
|---|
| 17 | # along with FCM. If not, see <http://www.gnu.org/licenses/>. |
|---|
| 18 | # ------------------------------------------------------------------------------ |
|---|
| 19 | use strict; |
|---|
| 20 | use warnings; |
|---|
| 21 | # ------------------------------------------------------------------------------ |
|---|
| 22 | package FCM::Context::Task; |
|---|
| 23 | use base qw{FCM::Class::HASH}; |
|---|
| 24 | |
|---|
| 25 | use constant { |
|---|
| 26 | ST_FAILED => 'ST_FAILED', |
|---|
| 27 | ST_OK => 'ST_OK', |
|---|
| 28 | ST_WORKING => 'ST_WORKING', |
|---|
| 29 | }; |
|---|
| 30 | |
|---|
| 31 | __PACKAGE__->class({ |
|---|
| 32 | ctx => {}, |
|---|
| 33 | error => {}, |
|---|
| 34 | id => '$', |
|---|
| 35 | elapse => {isa => '$', default => 0}, |
|---|
| 36 | state => {isa => '$', default => ST_WORKING}, |
|---|
| 37 | }); |
|---|
| 38 | # ------------------------------------------------------------------------------ |
|---|
| 39 | 1; |
|---|
| 40 | __END__ |
|---|
| 41 | |
|---|
| 42 | =head1 NAME |
|---|
| 43 | |
|---|
| 44 | FCM::Context::Task |
|---|
| 45 | |
|---|
| 46 | =head1 SYNOPSIS |
|---|
| 47 | |
|---|
| 48 | use FCM::Context::Task; |
|---|
| 49 | my $task = FCM::Context::Task->new(\%attrib); |
|---|
| 50 | |
|---|
| 51 | =head1 DESCRIPTION |
|---|
| 52 | |
|---|
| 53 | An instance of this class represents the generic context for a task for the |
|---|
| 54 | L<FCM::Util->task_runner()|FCM::Util>. This class is a sub-class of |
|---|
| 55 | L<FCM::Class::HASH|FCM::Class::HASH>. |
|---|
| 56 | |
|---|
| 57 | =head1 ATTRIBUTES |
|---|
| 58 | |
|---|
| 59 | =over 4 |
|---|
| 60 | |
|---|
| 61 | =item ctx |
|---|
| 62 | |
|---|
| 63 | The specific context of the task, such as the inputs and the outputs. |
|---|
| 64 | |
|---|
| 65 | =item error |
|---|
| 66 | |
|---|
| 67 | If the task failed, the error/exception will be returned in this attribute. |
|---|
| 68 | |
|---|
| 69 | =item id |
|---|
| 70 | |
|---|
| 71 | The ID of the task. |
|---|
| 72 | |
|---|
| 73 | =item elapse |
|---|
| 74 | |
|---|
| 75 | The amount of time (in seconds) taken to run the task. |
|---|
| 76 | |
|---|
| 77 | =item state |
|---|
| 78 | |
|---|
| 79 | The state of the task. See L</CONSTANTS> for possible variables. |
|---|
| 80 | |
|---|
| 81 | =back |
|---|
| 82 | |
|---|
| 83 | =head1 CONSTANTS |
|---|
| 84 | |
|---|
| 85 | =over 4 |
|---|
| 86 | |
|---|
| 87 | =item FCM::Context::Task->ST_FAILED |
|---|
| 88 | |
|---|
| 89 | A status to indicate that the task has failed. |
|---|
| 90 | |
|---|
| 91 | =item FCM::Context::Task->ST_OK |
|---|
| 92 | |
|---|
| 93 | A status to indicate that the task is completed successfully. |
|---|
| 94 | |
|---|
| 95 | =item FCM::Context::Task->ST_WORKING |
|---|
| 96 | |
|---|
| 97 | A status to indicate that the task is bing worked on. |
|---|
| 98 | |
|---|
| 99 | =back |
|---|
| 100 | |
|---|
| 101 | =head1 COPYRIGHT |
|---|
| 102 | |
|---|
| 103 | Copyright (C) 2006-2021 British Crown (Met Office) & Contributors. |
|---|
| 104 | |
|---|
| 105 | =cut |
|---|