The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

MyCPAN::Indexer::Coordinator - Provide a way for the various components to communicate

SYNOPSIS

my $componentA   = MyCPAN::Indexer::ComponentA->new;
my $componentB   = MyCPAN::Indexer::ComponentB->new;

my $coordinator = MyCPAN::Indexer::Coordinator->new;

# each component gets a reference
$componentA->set_coordinator( $coordinator );
$componentB->set_coordinator( $coordinator );

# the coordinator knows about all of the components
$coordinator->set_component( 'A', $componentA );
$coordinator->set_component( 'B', $componentB );

$componentA->set_note( 'cat', 'Buster' );

my $cat = $componentB->get_note( 'cat' );

# Any component can find any other component
$componentB->get_coordinator->get_component( 'A' )->method_in_A;

DESCRIPTION

The coordinator keeps track of the components in MyCPAN::Indexer. It acts as a central point where all comunication can flow so everything can talk to everything with only 2N connections.

It automatically sets up a notes object to act as a scratchpad. Every component can read from and write to the notes object.

Methods

new

Create a new Coordinator object.

get_component( NAME )

Retrieve the component named NAME.

set_component( NAME, REFERENCE )

Set the component with name NAME to REFERENCE. So far there are no restrictions on reference, but it should be a subclass of MyCPAN::Indexer::Component or at least something that acts like that class.

Dispatch to notes

As a convenience, these methods dispatch to the notes object:

get_note
set_note
get_config
set_config
increment_note
decrement_note
push_onto_note
unshift_onto_note
get_note_list_element
set_note_unless_defined

Organic methods

These methods are defined in this class and work to interact with some of the things the coordinator is tracking.

get_config
set_config( CONFIG )

Get or set the configuration objects.

get_info
set_info( INFO_OBJ )

Get or set the info object. This is the thing that records the data collected during the index.

TO DO

SOURCE AVAILABILITY

This code is in Github:

git://github.com/briandfoy/mycpan-indexer.git

AUTHOR

brian d foy, <bdfoy@cpan.org>

COPYRIGHT AND LICENSE

Copyright © 2008-2018, brian d foy <bdfoy@cpan.org>. All rights reserved.

You may redistribute this under the terms of the Artistic License 2.0.