Skip to content

Instantly share code, notes, and snippets.

@hogihung
Created March 31, 2016 20:17
Show Gist options
  • Save hogihung/09856a175694a85fb9eb79fef1aba439 to your computer and use it in GitHub Desktop.
Save hogihung/09856a175694a85fb9eb79fef1aba439 to your computer and use it in GitHub Desktop.
#-----------------------------------------------------------------------------
# John Hogarty
#
# Description: Data Access Orchestrator class
#
#-----------------------------------------------------------------------------
package OMX::Data::DAO;
use strict;
use warnings FATAL => qw(all);
use OMX::Data::DB::Baytech;
use OMX::Data::File::GFP_Device_Lists;
use OMX::Data::File::GFP_Interfaces;
use OMX::Data::File::LPP_Inventory;
#-----------------------------------------------------------------------------
# construct and return object, set defaults
#-----------------------------------------------------------------------------
sub new
{
my $type = shift();
my $class = ref($type) || $type;
my $self = {};
my %args = @_;
bless ($self, $class);
if(defined($args{debug}))
{
print ref($self), ":new\n" if ($args{debug});
$self->debug($args{debug});
}
return $self;
}
#-----------------------------------------------------------------------------
# baytech_db
#-----------------------------------------------------------------------------
sub baytech_db
{
my $self = shift;
my $baytech_db = new OMX::Data::DB::Baytech(@_);
$self->{baytech_db} = $baytech_db;
print ref($self), ":baytech_db: ", $self->{baytech_db}, "\n" if $self->debug;
return $baytech_db;
}
#-----------------------------------------------------------------------------
# gfp_dev_file
#-----------------------------------------------------------------------------
sub gfp_dev_file
{
my $self = shift;
my $gfp_dev_file = new OMX::Data::File::GFP_Device_Lists(@_);
$self->{gfp_dev_file} = $gfp_dev_file;
print ref($self), ":gfp_dev_file: ", $self->{gfp_dev_file}, "\n" if $self->debug;
return $gfp_dev_file;
}
#-----------------------------------------------------------------------------
# gfp_int_file
#-----------------------------------------------------------------------------
sub gfp_int_file
{
my $self = shift;
my $gfp_int_file = new OMX::Data::File::GFP_Interfaces(@_);
$self->{gfp_int_file} = $gfp_int_file;
print ref($self), ":gfp_int_file: ", $self->{gfp_int_file}, "\n" if $self->debug;
return $gfp_int_file;
}
#-----------------------------------------------------------------------------
# lpp_inv_file
#-----------------------------------------------------------------------------
sub lpp_inv_file
{
my $self = shift;
my $lpp_inv_file = new OMX::Data::File::LPP_Inventory(@_);
$self->{lpp_inv_file} = $lpp_inv_file;
print ref($self), ":lpp_inv_file: ", $self->{lpp_inv_file}, "\n" if $self->debug;
return $lpp_inv_file;
}
#-----------------------------------------------------------------------------
# debug
#-----------------------------------------------------------------------------
sub debug
{
my $self = shift;
if (@_)
{
my $value = shift;
$self->{debug} = $value;
print ref($self), ":debug: ", $self->{debug}, "\n" if ($value > 0);
}
return $self->{debug};
}
#-----------------------------------------------------------------------------
# display for debugging
#-----------------------------------------------------------------------------
sub display
{
my $self = shift;
my @keys = keys %$self;
for my $attribute ( @keys )
{
if( !( defined( $self->{$attribute})))
{
printf "%-20s = %-30s\n", $attribute, "undef", "\n";
}
else
{
printf "%-20s = %-30s\n", $attribute, $self->{$attribute}, "\n";
}
}
print "\n";
}
return 1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment