| 1 | package LCC::Documents::queue; | ||
| 2 | |||
| 3 | # Make sure we do everything by the book | ||
| 4 | # Set modules to inherit from | ||
| 5 | # Set version information | ||
| 6 | |||
| 7 | use strict; | ||
| 8 | @LCC::Documents::queue::ISA = qw(LCC::Documents); | ||
| 9 | $LCC::Documents::queue::VERSION = '0.01'; | ||
| 10 | |||
| 11 | # Return true value for use | ||
| 12 | |||
| 13 | 1; | ||
| 14 | |||
| 15 | #------------------------------------------------------------------------ | ||
| 16 | |||
| 17 | # The following methods are class methods | ||
| 18 | |||
| 19 | #------------------------------------------------------------------------ | ||
| 20 | |||
| 21 | # IN: 1 class of object | ||
| 22 | # 2 instantiated LCC object | ||
| 23 | # 3 threads::shared::queue object | ||
| 24 | # 4 method => value pairs to be executed | ||
| 25 | # OUT: 1 instantiated LCC::Documents::xxx object | ||
| 26 | |||
| 27 | sub _new { | ||
| 28 | |||
| 29 | # Obtain the class | ||
| 30 | # Obtain the LCC object | ||
| 31 | # Obtain the source (a ref to a database handle, table name list) | ||
| 32 | |||
| 33 | my $class = shift; | ||
| 34 | my $LCC = shift; | ||
| 35 | my $source = shift; | ||
| 36 | |||
| 37 | # Add error if the source is not a queue object | ||
| 38 | |||
| 39 | $LCC->_add_error( "$source is not a queue object" ) | ||
| 40 | unless ref($source) eq 'threads::shared::queue'; | ||
| 41 | |||
| 42 | # Create the object in the right way | ||
| 43 | # Save the source specification | ||
| 44 | # Return the object | ||
| 45 | |||
| 46 | my $self = $class->SUPER::_new( $LCC,@_ ); | ||
| 47 | $self->{'source'} = $source; | ||
| 48 | return $self; | ||
| 49 | } #_new | ||
| 50 | |||
| 51 | #------------------------------------------------------------------------ | ||
| 52 | |||
| 53 | # The following methods change the object | ||
| 54 | |||
| 55 | #------------------------------------------------------------------------ | ||
| 56 | |||
| 57 | # IN: 1 instantiated object | ||
| 58 | # OUT: 1 id of the next document | ||
| 59 | # 2 mtime of the next document | ||
| 60 | # 3 (optional) length of the next document | ||
| 61 | # 4 (optional) md5 of the next document | ||
| 62 | # 5 (optional) mimetype of the next document | ||
| 63 | # 6 (optional) subtype of the next document | ||
| 64 | |||
| 65 | sub next_document { @{shift->{'source'}->dequeue} } #next_document | ||
| 66 | |||
| 67 | #------------------------------------------------------------------------ | ||
| 68 | |||
| 69 | # The following subroutines deal with standard Perl features | ||
| 70 | |||
| 71 | #------------------------------------------------------------------------ | ||
| 72 | |||
| 73 | __END__ |