App-Framework
view release on metacpan or search on metacpan
lib/App/Framework/Extension.pm view on Meta::CPAN
#============================================================================================
# OBJECT HIERARCHY
#============================================================================================
#our @ISA = qw(App::Framework::Core) ;
our @ISA ;
#============================================================================================
# GLOBALS
#============================================================================================
=head2 FIELDS
The following fields should be defined either in the call to 'new()', as part of a 'set()' call, or called by their accessor method
(which is the same name as the field):
=over 4
=back
=cut
my %FIELDS = (
'extension_heap' => {}, # Extension-specific heap
);
#============================================================================================
=head2 CONSTRUCTOR
=over 4
=cut
#============================================================================================
=item B< new([%args]) >
Create a new Extension.
The %args are specified as they would be in the B<set> method.
=cut
sub new
{
my ($obj, %args) = @_ ;
my $class = ref($obj) || $obj ;
#print "App::Framework::Extension->new() class=$class\n" ;
## Inherit from specified list
my $this = App::Framework::Core->inherit($class, %args) ;
$this->_dbg_prt(["Extension - $class ISA=@ISA\n"]) ;
# Create object
# my $this = $class->SUPER::new(%args) ;
#$this->debug(1) ;
#print "App::Framework::Extension->new() - END\n" ;
return($this) ;
}
#============================================================================================
=back
=head2 CLASS METHODS
=over 4
=cut
#============================================================================================
#-----------------------------------------------------------------------------
=item B< init_class([%args]) >
Initialises the object class variables.
=cut
sub init_class
{
my $class = shift ;
my (%args) = @_ ;
# Add extra fields
$class->add_fields(\%FIELDS, \%args) ;
# init class
$class->SUPER::init_class(%args) ;
}
#============================================================================================
=back
=head2 OBJECT METHODS
=over 4
=cut
#============================================================================================
#----------------------------------------------------------------------------
=item B<heap([$level])>
Returns HEAP space for the calling module
=cut
sub heap
{
my $this = shift ;
my ($level) = @_ ;
## Get calling package
$level ||= 0 ;
my $pkg = (caller($level))[0] ;
#print "##!!## heap($pkg)\n" ;
#$this->dump_callstack() ;
# Get total heap space
my $heap = $this->extension_heap() ;
# Return this package's area
$heap->{$pkg} ||= {} ;
$this->_dbg_prt(["#!# this=$this pkg=$pkg Heap [$heap->{$pkg}] Total heap [$heap]=", $heap]) ; ;
return $heap->{$pkg} ;
}
# TODO: Specify fn(s) as method name strings that get called on this
#----------------------------------------------------------------------------
=item B<extend_fn(%spec)>
Hi-jack the specified application function. %spec is a HASH of:
key = function name
value = CODE ref to subroutine
=cut
( run in 0.740 second using v1.01-cache-2.11-cpan-0bb4e1dffa6 )