package APE::BarcodeFactory::DN_BarcodeFactory;

use base 'APE::BarcodeFactory';

use strict;
use warnings;

use APE::BarcodeFactory::ConcreteBarcode::DefaultBarcode;

use constant TRUE  => 1;
use constant FALSE => 0;

{
    my %_attributes = ();


    my %object; 
    

    foreach my $attName (keys(%_attributes)) {
	no strict 'refs';
	*{__PACKAGE__ . "::get\u$attName"} = sub { $object{ $_[0] }->{$attName} }
    }


    #################################################################
    ## Initialise the objects private attributes. The argument is
    ## deleted as it is found, initialised and set.
    #################################################################
    sub _init {	
	my ($self,%args) = @_;
	foreach my $attName (keys(%args)) {
	    if(exists($_attributes{$attName})) { 
		$object{ $self }->{$attName} = delete $args{$attName};
	    }
	}   

	## Set this factories type.
	$args{'barcodeType'} = 'DN';

	return $self->SUPER::_init(%args);
    }

    

    #################################################################
    ## Implemented abstract method from base class. This method creates
    ## a description object depending on the process id and returns it.
    #################################################################
    sub getInstance {
	my $self = shift;

	my $processId = $self->getProcessId;

	## Return the default Barcode object.
	return new APE::BarcodeFactory::ConcreteBarcode::DefaultBarcode
	    (barcodeType     => $self->getBarcodeType,
	     flushController => $self->getFlushController,
	     entityId        => $self->getEntityId,
	     reservedData    => $self->getReservedData,
	     processId       => $processId);
    }
}

1;
