| 1 | package Net::SolarWinds::ConstructorHash; | ||
| 2 | |||
| 3 | 5 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 5 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 5 | ▶ | use base qw( Net::SolarWinds::LogMethods); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | =pod | ||
| 8 | |||
| 9 | =head1 NAME | ||
| 10 | |||
| 11 | Net::SolarWinds::ConstructorHash - Default Hash object constructor | ||
| 12 | |||
| 13 | =head1 SYNOPSIS | ||
| 14 | |||
| 15 | package MyClass; | ||
| 16 | |||
| 17 | use base qw(Net::SolarWinds::ConstructorHash); | ||
| 18 | |||
| 19 | 1; | ||
| 20 | |||
| 21 | my $pkg=new MyClass(key=>'value'); | ||
| 22 | |||
| 23 | =head1 DESCRIPTION | ||
| 24 | |||
| 25 | This library provides a common base line construcotor that accepts an arbitrary key=>value pair set. | ||
| 26 | |||
| 27 | |||
| 28 | =head1 Setting default constructor values. | ||
| 29 | |||
| 30 | To create default constructor values, simply use the inherited OO constructor example: | ||
| 31 | |||
| 32 | sub new { | ||
| 33 | my ($class,%args)=@_; | ||
| 34 | |||
| 35 | return $class->SUPER::new( | ||
| 36 | some_argument=>'default_value', | ||
| 37 | %args | ||
| 38 | ); | ||
| 39 | } | ||
| 40 | |||
| 41 | =head1 OO Methods provided | ||
| 42 | |||
| 43 | =over 4 | ||
| 44 | |||
| 45 | =item * Object constructor | ||
| 46 | |||
| 47 | This class provides a basic object constructor that accepts hash key value pairs as its arguments. Keep in mind there are a few reserved hash keys. | ||
| 48 | |||
| 49 | Reserved hash keys: | ||
| 50 | |||
| 51 | _shutdown=>0|1 | ||
| 52 | # wich is used to manage the shutdown state. | ||
| 53 | |||
| 54 | log=>undef|Net::SolarWinds::Log instance | ||
| 55 | # this key represents the log object ( if passed into the constructor as class->new(log=>Net::SolarWinds::Log->new()) ) | ||
| 56 | |||
| 57 | =cut | ||
| 58 | |||
| 59 | 27 | ▶ | sub new { |
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 60 | 27 | my ( $class, %args ) = @_; | |
| 61 | |||
| 62 | 27 | my $self = bless { log => undef, _shutdown => 0, %args }, $class; | |
| 63 | |||
| 64 | 27 | return $self; | |
| 65 | } | ||
| 66 | |||
| 67 | =item * $self->is_shutdown | ||
| 68 | |||
| 69 | This method should be used when running infinate loops to see if the application should stop running its extended loop. | ||
| 70 | |||
| 71 | =cut | ||
| 72 | |||
| 73 | 4 | ▶ | sub is_shutdown { return $_[0]->{_shutdown} } |
|
Subroutine
is_shutdown: called CC=1 SCAR=0.0
Pod
documented
| |||
| 74 | |||
| 75 | =item * $self->set_shutdown | ||
| 76 | |||
| 77 | Sets the object into the shutdown state. | ||
| 78 | |||
| 79 | =cut | ||
| 80 | |||
| 81 | 2 | ▶ | sub set_shutdown { $_[0]->{_shutdown} = 1 } |
|
Subroutine
set_shutdown: called CC=1 SCAR=0.0
Pod
documented
| |||
| 82 | |||
| 83 | =back | ||
| 84 | |||
| 85 | =head1 AUTHOR | ||
| 86 | |||
| 87 | Michael Shipper | ||
| 88 | |||
| 89 | =cut | ||
| 90 | |||
| 91 | 5 | 1; | |