package APE::BarcodeFactory::ConcreteBarcode::ColumnBarcode;

use base 'APE::BarcodeFactory::ConcreteBarcode::Barcode';

use strict;
use warnings;
use Carp;

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};
	    }
	}   
	return $self->SUPER::_init(%args);
    }


    #################################################################
    ## Implemented abstract method from the super class. This method 
    ## creates and returns the actual description - this is what it's
    ## all about.
    #################################################################
    sub createBarcode {
	my $self = shift;
	my $rootTractData = eval { $self->findRootTract; };
	if($@){ croak "ERROR: $@";                       }
	my $flushController = $self->getFlushController;	
	my $newEntityId     = $self->getEntityId;#$flushController->getNewEntityId;
	my $barcodeType     = $self->getBarcodeType;
	my $reservedData    = $self->getReservedData;
	my $name            = $reservedData->[0];#$flushController->getColumnNumber;
	my $columnNumber    = $reservedData->[1];#$flushController->getUsedPlateName;
	return {Prefix  => $barcodeType,
		Barcode => $newEntityId,
		Name    => "Col $columnNumber $name",
		Project => $rootTractData->{tract}[1]};
    }
}

1;
