Author: dylan
Date: 2005-05-21 02:37:34 -0400 (Sat, 21 May 2005)
New Revision: 690

Added:
   trunk/misc/poe-session-plugin/lib/POE/Wheel/Square.pm
   trunk/misc/poe-session-plugin/lib/POE/Wheel/Square/
   trunk/misc/poe-session-plugin/lib/POE/Wheel/Square/Loader.pm
Removed:
   trunk/misc/poe-session-plugin/lib/POE/Wheel/Plugin.pm
   trunk/misc/poe-session-plugin/lib/POE/Wheel/Plugin/
Modified:
   trunk/
   trunk/misc/poe-session-plugin/Build.PL
Log:
 [EMAIL PROTECTED]:  dylan | 2005-05-21 02:34:15 -0400
 more renaming.



Property changes on: trunk
___________________________________________________________________
Name: svk:merge
   - 1f59643a-e6e5-0310-bc24-f7d4c744f460:/haver/local/trunk:11166
1f59643a-e6e5-0310-bc24-f7d4c744f460:/haver/local/trunk-merge-10131:11178
27e50396-46e3-0310-8b22-ae223a1f35ce:/local:212
e9404bb1-7af0-0310-a7ff-e22194cd388b:/haver/local:972
edfcd8bd-4ce7-0310-a97e-bb1efd40edf3:/local:238
   + 1f59643a-e6e5-0310-bc24-f7d4c744f460:/haver/local/trunk:11166
1f59643a-e6e5-0310-bc24-f7d4c744f460:/haver/local/trunk-merge-10131:11178
27e50396-46e3-0310-8b22-ae223a1f35ce:/local:212
e9404bb1-7af0-0310-a7ff-e22194cd388b:/haver/local:973
edfcd8bd-4ce7-0310-a97e-bb1efd40edf3:/local:238

Modified: trunk/misc/poe-session-plugin/Build.PL
===================================================================
--- trunk/misc/poe-session-plugin/Build.PL      2005-05-21 06:37:32 UTC (rev 
689)
+++ trunk/misc/poe-session-plugin/Build.PL      2005-05-21 06:37:34 UTC (rev 
690)
@@ -2,17 +2,18 @@
 require 5.008;
 use Module::Build;
 my $build = Module::Build->new(
-       module_name        => 'POE::Session::Plugin',
-       dist_version_from  => 'lib/POE/Session/Plugin.pm',
+       module_name        => 'POE::Wheel::Square',
+       dist_version_from  => 'lib/POE/Wheel/Square.pm',
        dist_author        => 'Dylan William Hardison <[EMAIL PROTECTED]>',
-       dist_abstract      => 'Base class for modules that extend POE::Session 
at runtime.',
+       dist_abstract      => 'A POE::Wheel that does things for you, and does 
not do drugs',
        license            => 'gpl',
        requires           => {
                'perl'            => '5.8.0',
                POE               => 0.27,
-               
        },
+       build_requires     => {
+               'Test::More'   => 0,
+       }
        create_makefile_pl => 'passthrough',
-       script_files => [glob('bin/*.pl')],
 );
 $build->create_build_script();

Deleted: trunk/misc/poe-session-plugin/lib/POE/Wheel/Plugin.pm
===================================================================
--- trunk/misc/poe-session-plugin/lib/POE/Wheel/Plugin.pm       2005-05-21 
06:37:32 UTC (rev 689)
+++ trunk/misc/poe-session-plugin/lib/POE/Wheel/Plugin.pm       2005-05-21 
06:37:34 UTC (rev 690)
@@ -1,230 +0,0 @@
-# vim: set ts=4 sw=4 noexpandtab si ai sta tw=100:
-# This module is copyrighted, see end of file for details.
-package POE::Session::Plugin;
-use strict;
-use warnings;
-use Carp;
-use POE::Wheel;
-our $VERSION = '0.06';
-our $Kernel  = $POE::Kernel::poe_kernel;
-
-sub new {
-       my $class = shift;
-       my $self = {
-               # I only prefix these with underscores because I am paranoid of
-               # subclasses clobbering them. :)
-               _provided_states => [],
-               _defined_states  => { },
-               _id              => POE::Wheel::allocate_wheel_id(),
-       };
-       bless $self, $class;
-       $self->provide("load_$self->{_id}", 'on_load');
-       $self->provide("unload_$self->{_id}", 'on_unload');
-       $self->setup(@_);
-       return $self;
-}
-
-sub setup {  }
-
-# POE state called when we load.
-sub on_load {
-       
-}
-
-# POE state called when we unload.
-sub on_unload {
-       
-}
-
-
-# This method is not really public. :)
-sub kernel {
-       my ($self, $kernel) = @_;
-       $Kernel = $kernel;
-}
-
-sub provide {
-       my ($self, $state, $method) = @_;
-       push @{ $self->{_provided_states} }, [ $state, $method ];
-}
-
-sub provided_states {
-       my $self = shift;
-       @{ $self->{_provided_states} };
-}
-
-sub defined_states {
-       my $self = shift;
-       keys %{ $self->{_defined_states} };
-}
-
-
-sub invoke {
-       my $self = shift;
-       my $act  = shift;
-       my $session = $Kernel->get_active_session();
-       my $class   = ref $self;
-       $Kernel->call($session, join('_', $act, $self->ID));
-}
-
-sub ID { shift->{_id} }
-
-# Load all provided states.
-sub load {
-       my $self = shift;
-       map {
-               $self->define(@$_)
-       } $self->provided_states;
-       $self->invoke('load');
-}
-
-# Unload all *defined* states.
-sub unload {
-       my $self = shift;
-       $self->invoke('unload');
-       map {
-               $self->undefine($_)
-       } $self->defined_states;
-}
-
-sub define {
-       my ($self, $state, $method) = @_;
-       $method ||= $state;
-
-       croak "State $state defined; can't redefine"
-               if exists $self->{_defined_states}{$state};
-       $self->{_defined_states}{$state} = $method;
-       $Kernel->state($state, 
-               $self->{package} ? ref $self : $self,
-               $method
-       );
-}
-
-sub undefine {
-       my ($self, $state) = @_;
-
-       croak "State $state not defined; can't undefine"
-               unless exists $self->{_defined_states}{$state};
-       delete $self->{_defined_states}{$state};
-       $Kernel->state($state);
-}
-
-
-sub DESTROY {
-       my $self = shift;
-       POE::Wheel::free_wheel_id($self->ID);
-}
-
-1;
-
-__END__
-=head1 NAME
-
-POE::Session::Plugin - Base class for modules that extend POE::Session at 
runtime.
-
-=head1 SYNOPSIS
-
-       package MyPlugin;
-       use POE;
-       use base 'POE::Session::Plugin';
-
-       sub setup {
-               my $self = shift;
-               $self->provide('foo', 'on_foo');
-       }
-
-       sub on_foo {
-               my ($kernel, $heap, $self) = @_[KERNEL, HEAP, OBJECT];
-               # ...
-       }
-
-=head1 DESCRIPTION
-
-This module allows the loading and unloading of object states into a running 
L<POE::Session>.
-
-Plugins are not unlike a L<POE::Wheel>, except instead of producing events, 
they respond to them.
-
-This behavior is similar to that of L<POE::NFA>, except it is added to 
existing L<POE::Session>
-sessions.
-
-=head1 METHODS
-
-This class implements the following methods:
-
-=head2 new(@args)
-
-This returns a new plugin object.
-Its arguments (@args) are passed to setup()
-
-=head2 setup()
-
-B<Do not call this method>. It is called by new().
-
-Subclasses should overload this method and use it call provide()
-to specify which states they define in the current session.
-
-=head2 define($state [, $method ])
-
-Bind $state in the currently active session to the method $method of $self.
-If $method is omitted, it defaults to the same name as $state.
-
-=head2 undefine($state)
-
-Remove the binding of $state in the current session, if and only if it was 
previously
-defined by our $self.
-
-=head2 provide($state [, $method ])
-
-This is like a delayed define(). It will only occurs when load() is called.
-
-=head2 load(Z<>)
-
-Load all C<provide>'d states.
-
-=head2 unload(Z<>)
-
-This undefines (with undefine()) all states that were defined with define()
-or provided() and subsequently loaded with load().
-
-=head2 on_load
-
-This is method is called as a POE state when the plugin is loaded.
-$_[KERNEL], $_[SESSION], etc, should all be correct.
-
-=head2 on_unload
-
-This is method is called as a POE state when the plugin is unloaded.
-$_[KERNEL], $_[SESSION], etc, should all be correct.
-
-=head1 BUGS
-
-None known. Bug reports are welcome. Please use our bug tracker at
-L<http://gna.org/bugs/?func=additem&group=haver>.
-
-=head1 AUTHOR
-
-Dylan William Hardison, E<lt>[EMAIL PROTECTED]<gt>
-
-=head1 SEE ALSO
-
-L<http://www.haverdev.org/>, L<POE::Session::Plugin::Loader>,
-L<POE>, L<POE::Session>, L<POE::NFA>.
-
-=head1 COPYRIGHT and LICENSE
-
-Copyright (C) 2005 by Dylan William Hardison. All Rights Reserved.
-
-This module is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This module is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this module; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-

Added: trunk/misc/poe-session-plugin/lib/POE/Wheel/Square/Loader.pm
===================================================================
--- trunk/misc/poe-session-plugin/lib/POE/Wheel/Square/Loader.pm        
2005-05-21 06:37:32 UTC (rev 689)
+++ trunk/misc/poe-session-plugin/lib/POE/Wheel/Square/Loader.pm        
2005-05-21 06:37:34 UTC (rev 690)
@@ -0,0 +1,145 @@
+# vim: set ts=4 sw=4 noexpandtab si ai sta tw=100:
+# This module is copyrighted, see end of file for details.
+package POE::Session::Plugin::Loader;
+use strict;
+use warnings;
+use Carp;
+
+our $VERSION = '0.04';
+
+sub new {
+       my $class = shift;
+       my $self = {
+               plugins => {},
+       };
+       bless $self, $class;
+}
+
+sub load_plugin {
+       my ($self, $class, @args) = @_;
+
+       if (exists $self->{plugins}{$class}) {
+               croak "Plugin $class already loaded!";
+       }
+       
+       my $object = $class->new(@args);
+       $object->load;
+       $self->{plugins}{$class} = $object;
+}
+
+sub unload_plugin {
+       my ($self, $class) = @_;
+       my $object = delete $self->{plugins}{$class};
+       $object->unload;
+}
+
+sub plugins {
+       my $self = shift;
+       keys %{ $self->{plugins} };
+}
+
+sub unload_all_plugins {
+       my ($self) = @_;
+       map { $self->unload($_) } $self->plugins
+}
+
+sub fetch_plugin {
+       my ($self, $class) = @_;
+       
+       if (exists $self->{plugins}{$class}) {
+               $self->{plugins}{$class};
+       } else {
+               undef;
+       }
+}
+
+
+1;
+__END__
+=head1 NAME
+
+POE::Session::Plugin::Loader - description
+
+=head1 SYNOPSIS
+
+  use POE::Session::Plugin::Loader;
+  use MyPlugin;
+
+  # ... In some POE state ...
+  my $loader = POE::Session::Plugin::Loader;
+  $loader->load_plugin('MyPlugin', 'some', 'args');
+  $_[HEAP]{loader} = $loader;
+
+=head1 DESCRIPTION
+
+This object maintains a list of plugin objects which have states loaded into a 
session.
+
+FIXME: Write a better description.
+
+=head1 METHODS
+
+This class implements the following methods:
+
+=head2 new(Z<>)
+
+This returns a new POE::Session::Plugin::Loader object.
+
+=head2 load_plugin($class, @args)
+
+Creates a new object of class $class, passing @args to its new() class method.
+The newly created object will have its load() method called, which should load 
states into the
+currently active L<POE::Session>.
+
+For details on defining plugins, see L<POE::Session::Plugin>.
+
+=head2 unload_plugin($class)
+
+Call unload() on the object associated with $class,
+and then destroy the said object.
+
+=head2 plugins(Z<>)
+
+Returns a list of the currently loaded class names.
+
+=head2 fetch_plugin($class)
+
+Returns the plugin object of type $class.
+Returns undef if $class was never loaded.
+
+=head2 unload_all_plugins(Z<>)
+
+Unload all currently loaded plugins.
+
+This is called when the plugin loader is DESTROY()'d, so you never really need 
to call it.
+
+=head1 BUGS
+
+None known. Bug reports are welcome. Please use our bug tracker at
+L<http://gna.org/bugs/?func=additem&group=haver>.
+
+=head1 AUTHOR
+
+Dylan William Hardison, E<lt>[EMAIL PROTECTED]<gt>
+
+=head1 SEE ALSO
+
+L<http://www.haverdev.org/>, L<POE>, L<POE::Session>, L<POE::NFA>.
+
+=head1 COPYRIGHT and LICENSE
+
+Copyright (C) 2005 by Dylan William Hardison. All Rights Reserved.
+
+This module is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This module is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this module; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+

Added: trunk/misc/poe-session-plugin/lib/POE/Wheel/Square.pm
===================================================================
--- trunk/misc/poe-session-plugin/lib/POE/Wheel/Square.pm       2005-05-21 
06:37:32 UTC (rev 689)
+++ trunk/misc/poe-session-plugin/lib/POE/Wheel/Square.pm       2005-05-21 
06:37:34 UTC (rev 690)
@@ -0,0 +1,230 @@
+# vim: set ts=4 sw=4 noexpandtab si ai sta tw=100:
+# This module is copyrighted, see end of file for details.
+package POE::Session::Plugin;
+use strict;
+use warnings;
+use Carp;
+use POE::Wheel;
+our $VERSION = '0.06';
+our $Kernel  = $POE::Kernel::poe_kernel;
+
+sub new {
+       my $class = shift;
+       my $self = {
+               # I only prefix these with underscores because I am paranoid of
+               # subclasses clobbering them. :)
+               _provided_states => [],
+               _defined_states  => { },
+               _id              => POE::Wheel::allocate_wheel_id(),
+       };
+       bless $self, $class;
+       $self->provide("load_$self->{_id}", 'on_load');
+       $self->provide("unload_$self->{_id}", 'on_unload');
+       $self->setup(@_);
+       return $self;
+}
+
+sub setup {  }
+
+# POE state called when we load.
+sub on_load {
+       
+}
+
+# POE state called when we unload.
+sub on_unload {
+       
+}
+
+
+# This method is not really public. :)
+sub kernel {
+       my ($self, $kernel) = @_;
+       $Kernel = $kernel;
+}
+
+sub provide {
+       my ($self, $state, $method) = @_;
+       push @{ $self->{_provided_states} }, [ $state, $method ];
+}
+
+sub provided_states {
+       my $self = shift;
+       @{ $self->{_provided_states} };
+}
+
+sub defined_states {
+       my $self = shift;
+       keys %{ $self->{_defined_states} };
+}
+
+
+sub invoke {
+       my $self = shift;
+       my $act  = shift;
+       my $session = $Kernel->get_active_session();
+       my $class   = ref $self;
+       $Kernel->call($session, join('_', $act, $self->ID));
+}
+
+sub ID { shift->{_id} }
+
+# Load all provided states.
+sub load {
+       my $self = shift;
+       map {
+               $self->define(@$_)
+       } $self->provided_states;
+       $self->invoke('load');
+}
+
+# Unload all *defined* states.
+sub unload {
+       my $self = shift;
+       $self->invoke('unload');
+       map {
+               $self->undefine($_)
+       } $self->defined_states;
+}
+
+sub define {
+       my ($self, $state, $method) = @_;
+       $method ||= $state;
+
+       croak "State $state defined; can't redefine"
+               if exists $self->{_defined_states}{$state};
+       $self->{_defined_states}{$state} = $method;
+       $Kernel->state($state, 
+               $self->{package} ? ref $self : $self,
+               $method
+       );
+}
+
+sub undefine {
+       my ($self, $state) = @_;
+
+       croak "State $state not defined; can't undefine"
+               unless exists $self->{_defined_states}{$state};
+       delete $self->{_defined_states}{$state};
+       $Kernel->state($state);
+}
+
+
+sub DESTROY {
+       my $self = shift;
+       POE::Wheel::free_wheel_id($self->ID);
+}
+
+1;
+
+__END__
+=head1 NAME
+
+POE::Session::Plugin - Base class for modules that extend POE::Session at 
runtime.
+
+=head1 SYNOPSIS
+
+       package MyPlugin;
+       use POE;
+       use base 'POE::Session::Plugin';
+
+       sub setup {
+               my $self = shift;
+               $self->provide('foo', 'on_foo');
+       }
+
+       sub on_foo {
+               my ($kernel, $heap, $self) = @_[KERNEL, HEAP, OBJECT];
+               # ...
+       }
+
+=head1 DESCRIPTION
+
+This module allows the loading and unloading of object states into a running 
L<POE::Session>.
+
+Plugins are not unlike a L<POE::Wheel>, except instead of producing events, 
they respond to them.
+
+This behavior is similar to that of L<POE::NFA>, except it is added to 
existing L<POE::Session>
+sessions.
+
+=head1 METHODS
+
+This class implements the following methods:
+
+=head2 new(@args)
+
+This returns a new plugin object.
+Its arguments (@args) are passed to setup()
+
+=head2 setup()
+
+B<Do not call this method>. It is called by new().
+
+Subclasses should overload this method and use it call provide()
+to specify which states they define in the current session.
+
+=head2 define($state [, $method ])
+
+Bind $state in the currently active session to the method $method of $self.
+If $method is omitted, it defaults to the same name as $state.
+
+=head2 undefine($state)
+
+Remove the binding of $state in the current session, if and only if it was 
previously
+defined by our $self.
+
+=head2 provide($state [, $method ])
+
+This is like a delayed define(). It will only occurs when load() is called.
+
+=head2 load(Z<>)
+
+Load all C<provide>'d states.
+
+=head2 unload(Z<>)
+
+This undefines (with undefine()) all states that were defined with define()
+or provided() and subsequently loaded with load().
+
+=head2 on_load
+
+This is method is called as a POE state when the plugin is loaded.
+$_[KERNEL], $_[SESSION], etc, should all be correct.
+
+=head2 on_unload
+
+This is method is called as a POE state when the plugin is unloaded.
+$_[KERNEL], $_[SESSION], etc, should all be correct.
+
+=head1 BUGS
+
+None known. Bug reports are welcome. Please use our bug tracker at
+L<http://gna.org/bugs/?func=additem&group=haver>.
+
+=head1 AUTHOR
+
+Dylan William Hardison, E<lt>[EMAIL PROTECTED]<gt>
+
+=head1 SEE ALSO
+
+L<http://www.haverdev.org/>, L<POE::Session::Plugin::Loader>,
+L<POE>, L<POE::Session>, L<POE::NFA>.
+
+=head1 COPYRIGHT and LICENSE
+
+Copyright (C) 2005 by Dylan William Hardison. All Rights Reserved.
+
+This module is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This module is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this module; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+


Reply via email to