X
xhoster
Is there an elegant way to tell other modules which are ISA some parent
(either directly or indirectly) that they should be ISA something else
instead?
For example, GD::Graph::lines, GD::Graph:oints, and
GD::Graph::linespoints.pm are all subclasses of GD::Graph::axestype.
I want to subclass GD::Graph::axestype and override a method in it, and
have that override exist for the three end-use modules. Currently the way
I do it is to subclass each of the end-use modules individually:
package Xho::linespoints;
use base qw(GD::Graph::linespoints);
## GD::Graph is very buggy if numeric X axis are used
## without x_min_value and x_max_value being set.
## So set them to the pretty choice made by _best_ends
sub setup_x_step_size_v {
my $s=shift;
if ( defined $s->{x_tick_number}) {
$s->{x_min_value}=$s->{x_min} unless defined $s->{x_min_value};
$s->{x_max_value}=$s->{x_max} unless defined $s->{x_max_value};
};
$s->SUPER::setup_x_step_size_v;
};
## and likewise for other end-use modules.
Doing it this way isn't too awful, but it seems like there should be a
better way.
Thanks,
Xho
(either directly or indirectly) that they should be ISA something else
instead?
For example, GD::Graph::lines, GD::Graph:oints, and
GD::Graph::linespoints.pm are all subclasses of GD::Graph::axestype.
I want to subclass GD::Graph::axestype and override a method in it, and
have that override exist for the three end-use modules. Currently the way
I do it is to subclass each of the end-use modules individually:
package Xho::linespoints;
use base qw(GD::Graph::linespoints);
## GD::Graph is very buggy if numeric X axis are used
## without x_min_value and x_max_value being set.
## So set them to the pretty choice made by _best_ends
sub setup_x_step_size_v {
my $s=shift;
if ( defined $s->{x_tick_number}) {
$s->{x_min_value}=$s->{x_min} unless defined $s->{x_min_value};
$s->{x_max_value}=$s->{x_max} unless defined $s->{x_max_value};
};
$s->SUPER::setup_x_step_size_v;
};
## and likewise for other end-use modules.
Doing it this way isn't too awful, but it seems like there should be a
better way.
Thanks,
Xho