1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
|
####################################################################################################################################
# Base IO Module
####################################################################################################################################
package pgBackRestTest::Common::Io::Base;
use strict;
use warnings FATAL => qw(all);
use Carp qw(confess);
use English '-no_match_vars';
use Exporter qw(import);
our @EXPORT = qw();
use Scalar::Util qw(blessed);
use pgBackRestDoc::Common::Log;
####################################################################################################################################
# Package name constant
####################################################################################################################################
use constant COMMON_IO_BASE => __PACKAGE__;
push @EXPORT, qw(COMMON_IO_BASE);
####################################################################################################################################
# Default buffer max
####################################################################################################################################
use constant COMMON_IO_BUFFER_MAX => 4194304;
push @EXPORT, qw(COMMON_IO_BUFFER_MAX);
####################################################################################################################################
# new
####################################################################################################################################
sub new
{
my $class = shift;
# Create the class hash
my $self = {};
bless $self, $class;
# Assign function parameters, defaults, and log debug info
(
my $strOperation,
$self->{strId},
) =
logDebugParam
(
__PACKAGE__ . '->new', \@_,
{name => 'strId', trace => true},
);
# Return from function and log return values if any
return logDebugReturn
(
$strOperation,
{name => 'self', value => $self}
);
}
####################################################################################################################################
# error - throw errors
####################################################################################################################################
sub error
{
my $self = shift;
my $iCode = shift;
my $strMessage = shift;
my $strDetail = shift;
logErrorResult($iCode, $strMessage, $strDetail);
}
####################################################################################################################################
# result - retrieve a result from io or a filter
####################################################################################################################################
sub result
{
my $self = shift;
my $strModule = shift;
if (!defined($strModule))
{
return $self->{rhResult};
}
return $self->{rhResult}{$strModule};
}
####################################################################################################################################
# resultAll - get all results
####################################################################################################################################
sub resultAll
{
shift->{rhResult};
}
####################################################################################################################################
# resultSet - set a result from io or a filter
####################################################################################################################################
sub resultSet
{
my $self = shift;
my $strModule = shift;
my $xResult = shift;
$self->{rhResult}{$strModule} = $xResult;
}
####################################################################################################################################
# Getters
####################################################################################################################################
sub className {blessed(shift)}
sub id {shift->{strId}}
1;
|