# -*- mode: perl -*-
# CVS Status      : $Id: $
# Last Modified by: $Author: griff $

# Store information into a DB about Link Data
#

################ Copyright ################

# This program is Copyright 2004 by Adam J. Griff, Ph.D. (GriffMonster, LLC)
# This program is free software; you can redistribute it and/or
# modify it under the terms of the Perl Artistic License or the
# GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any
# later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# If you do not have a copy of the GNU General Public License write to
# the Free Software Foundation, Inc., 675 Mass Ave, Cambridge,
# MA 02139, USA.

################ Module Preamble ################


# 2004/07/09 V1.0.0
# initial release


=head1 NAME
    
    LinkDB - Database of link information
    
=head1 SYNOPSIS

    use LINKDB;

=head2 GET SOME HELP

    none for now

=cut


package LinkDB;
use 5.006_001;
use warnings;
use strict;
use Carp();
use vars qw($VERSION @ISA);
my $Debugging=0;
my $Census = 0;
    
BEGIN {
  $VERSION        =  1.0.0;
  @ISA = 'UNIVERSAL';
}

sub new {
  my $proto = shift;
  my $class = ref($proto) || $proto;
  if ($Debugging >= 2) {
    print "Creating object of class $class\n";
  }
  my $self = {
    PAGE_NAME => undef,
    PAGE_TYPE => undef,
    PAGE_STATUS => undef,
  };
  $self->{"rs_CENSUS"} = \$Census;
  bless ($self, $class);
  ++ ${$self->{"rs_CENSUS"}};

  return $self;
}


sub DESTROY {
  my $self=shift;
  -- ${$self->{"rs_CENSUS"}};
  if ($Debugging) {
    Carp::carp( "Destroying $self new CENSUS is " . ${$self->{"rs_CENSUS"}} );
    if ($Debugging >= 2) {
      use Data::Dumper;
      print "Here is the object being destroyed\n" . Dumper($self);
    }
  }
}

sub END {
  if ($Debugging) { print "All object have gone away of class LinkDB.\n"; }
}
sub debug {
  my $class=shift;
  if (ref $class) { Carp::confess( "Class method called as object method");}
  unless (@_ == 1) { Carp::confess( "usage: $class->debug(level}");}
  $Debugging = shift;
}

sub population {
  my $self=shift;
  if (ref $self) {
    return ${$self->{"rs_CENSUS"}};
  } else {
    return $Census;
  }
}

sub page_name {
  my $self = shift;
  if (@_) { $self->{PAGE_NAME} = shift }
  return $self->{PAGE_NAME};
}

sub db_type {
  my $self = shift;
  print "I'm a LinkDB object and store in memory only\n";
}

1;
