Included libraries | Package variables | General documentation | Methods |
WebCvs | Raw content |
_display_stats | No description | Code |
_initialize | No description | Code |
bar | No description | Code |
change_color | No description | Code |
data | No description | Code |
destroy | No description | Code |
set_bar | No description | Code |
set_color | No description | Code |
set_data | No description | Code |
_display_stats | description | prev | next | Top |
my ($self, $OUT ) = @_; $self->SUPER::_display_stats($OUT); printf( $OUT "%-15s: %d\n", 'DATA',$self->data()); printf( $OUT "%-15s: %s\n", 'COLOR',$self->color()); (defined $self->{'Bar'}) ? $self->{'Bar'}->display(-WHERE=>$OUT, -HEADER=>1) : ( printf( $OUT "%-15s: %s\n", 'BAR','undefined')); print $OUT "\n"; } ######################################}
1;
_initialize | description | prev | next | Top |
my($self, %param) = @_; $DEBUG && do{ printf ">>>> Initializing %s (%s) %s\n",$ID,ref($self),$param{-NAME}||'anon'; <STDIN>; }; #----------------------}
# DATA MEMBERS:
# foodat
# color
# bar
#----------------------
$self->SUPER::_initialize( %param ); my ($foo, $color) = $self->_rearrange([qw(FOO COLOR)], %param); $self->set_data( $foo); $self->set_color( $color); $self->set_bar( %param) if defined $param{-BAR}; # $self->index();
$DEBUG and printf "---> Initialized %s (%s) %s\n",$ID, ref($self), $self->name; } ###################################
bar | description | prev | next | Top |
my $self = shift; $self->{'Bar'}}
change_color | description | prev | next | Top |
my ($self,$c) = @_; if( grep /$c/i, @COLORS) { $self->set_color($c); } else { $self->throw("Invalid or unspecified color = $c", "Color not changed ($self->{'Color'}).\nAcceptable colors: @COLORS"); } } ###################################}
data | description | prev | next | Top |
my $self = shift; $self->{'Foodat'}}
destroy | description | prev | next | Top |
my $self = shift; if(ref($self->{'Bar'})) { $self->{'Bar'}->destroy; undef $self->{'Bar'}; } $self->SUPER::destroy(); } ###################################}
set_bar | description | prev | next | Top |
my ($self, %param) = @_; my $bar = undef; $DEBUG and print "Foo::set_bar()\n"; $param{-PARENT} = $self; my $bar_name = 'BAR_'.$self->{'Foodat'}; $param{-NAME} = $bar_name; eval { $bar = new Bar(%param); }; if($@) { ## If Bar throws an exception, assimilate the exception as a warning}
## and add a note to it.
$self->warn(-MSG =>$@, -NOTE =>"${\$self->name()} can't build Bar object\" $bar_name\": Invalid object."); } else { $self->{'Bar'} = $bar; } } ###################################
set_color | description | prev | next | Top |
my ($self, $c) = @_; $DEBUG and print "$ID: setting color()"; $c || do{ $self->warn("Color not defined.", "All $ID objects must have a color.". "\tSetting to $DEFAULT_COLOR"); $c = $DEFAULT_COLOR; }; $self->{'Color'} = "\L$c\E"; } ###################################}
set_data | description | prev | next | Top |
my ($self, $d) = @_; if(not defined ($d) or $d =~ /\D/) { $self->throw("Undefined or invalid foo data: $d", "All $ID objects must be initialized with numeric data."); } $self->{'Foodat'} = $d; } ###################################}