I have the following class hierarchy:
CPAN::Forum
Object-InsideOut - OIO and default value
| Posted on Fri Dec 8 15:07:36 2006 by gaetan |
| OIO and default value |
|
Hello all,
I have the following class hierarchy:
package Connection;
use Object::InsideOut;
my @bidule
:Arg(name => "bidule", default => 0)
:Set(name => "set_bidule", restricted => 1)
:Field
;
sub print_information
{
my $obj = shift;
print "Bidule: $bidule[$$obj]";
}
package Connection::Simulate;
use Object::InsideOut('Connection');
and the following program
package main;
my $sim = Connection::Simulate->new();
$sim->print_information();
1;
I would like 'bidule' to be set to 1 for objects 'Connection::Simulate' (I already sent a request to have the possibility to set default value without having to use the :Arg attribute. See http://www.cpanforum.com/posts/3633, but the proposed solution does not fit my current pb) I tried to solve my pb without finding a solution. For example, I declared a Preinit function in the Connection::Simulate, but the value '1' is not set correctly (this solution is in anyway incorrect: suppose we have the Connection, Connection::Simulate and Connection::Simulate::Blabla classes with default values set to 0 (for Connection), 1 (for Connection::Simulate), 2 (for Connection::Simulate::Blabla))
package Connection::Simulate;
use Object::InsideOut('Connection');
sub _preinit :Preinit
{
my $obj = shift;
$obj->set_bidule(1);
}
How can I solve my problem (without having to call the set_bidule method outside from the tree hierarchy ;-)) ? Thanks Gaetan |
| Direct Responses: 3725 | Write a response |
(2)
]