ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> perl-poe
perl-poe
object_states 3
by Lanas other posts by this author
Nov 20 2006 5:30AM messages near this date
Re: [Dbix-class] POE::Component::DBD::MySQL | Re: object_states 3
Folks,

  Re.: choosing which method amongst objects having same method names.
The technique described in POE::Session seems to fulfill this goal but
moreover, it enables some kind of an easy double-dispatch of both object
and method since Perl is reflective:

my $obj_a = osObj1-> new();
my $obj_b = osObj2-> new();

POE::Session-> create
  (
   object_states => 
    [
     $obj_a =>  {method1_obja => 'method1',
		method2_obja =>  'method2',
	       },
     $obj_b =>  {method1_objb => 'method1',
		method2_objb =>  'method2',
	       },
    ],

    inline_states => 
    {
     _start =>  \&startIt,
    },
  );

sub startIt
{
  print "Started !\n";
  $_[KERNEL]-> alias_set("os");

  my $methodNumber = 2;
  my $objName = 'a';

  $_[KERNEL]-> post('os', "method$methodNumber\_obj$objName");
}


  Any comments on the subject are welcomed.

Cheers,
Al
Thread:
Lanas
Rocco Caputo

Privacy Policy | Email Opt-out | Feedback | Syndication
© 2004 ActiveState, a division of Sophos All rights reserved