Agent
view release on metacpan or search on metacpan
$self->{AgentVar} = '$agent';
my $agentclass = $tom->class;
my $str =
"if ('$agentclass' && (\${$agentclass\:\:}{new})) {\n" .
" \$agent = new $agentclass(" . %args . ");\n" .
"} else {\n" .
" \$agent = {}; bless \$agent, $agentclass;\n" .
"}";
$cpt->reval($str);
print "AGENT: ", ${$cpt->varglob('agent')}, "\n";
if ($@) {
warn "Unsafe agent trapped: $@\n" if $Debug;
return;
}
}
# store the agent's class in the agent itself:
${$cpt->varglob($self->{AgentVar})}->{Tom} = $tom;
bless $self, $class; # bless wrapper into Agent!
} else {
unless ($self = $tom->get_object) {
no strict;
# got no object, so create one:
my $agentclass = $tom->class();
if (($agentclass) && (${"$agentclass\:\:"}{new})) {
$self = new $agentclass(%args);
} else {
print STDERR "$agentclass\:\:new() not found!\n" if $Debug;
( run in 0.527 second using v1.01-cache-2.11-cpan-49f99fa48dc )