################################################################## 
## Class Name: DefaultFlushControllerFactory                    ##
##                                                              ##
## Description: This is the default flush controller factory    ##
##              class that is created by the AtomicProcessCont- ##
##              -ainer class if no specialised FCFM object is   ##
##              passed to it. This concrete flush controller    ##
##              factory instantiates and returns a new default  ##
##              concrete flush controller class.                ##
##                                                              ##
## Arguments: None.                                             ##
##                                                              ##
##################################################################
package APE::FlushControllerFactory::DefaultFlushControllerFactory;

use base 'APE::FlushControllerFactory';

$APE::FlushControllerFactory::DefaultFlushControllerFactory::VERSION = '0.1';

use strict;
use warnings;

use APE::FlushControllerFactory::ConcreteFlushController::DefaultFlushController;

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 base class. This method creates
    ## a description object depending on the process id and returns it.
    #################################################################
    sub getInstance {
	my ($self,%args) = @_;
	%args = $self->SUPER::validateInstanceRequest(%args);
	
	my $arrayingEntity = $args{arrayingEntity};
	my $processId      = $arrayingEntity->getParentProcessId; 
	my $prefix         = $arrayingEntity->getOutPrefix;
	warn "*** '$self' returning the default FlushController ".
            "for prefix '$prefix' with ppid '$processId'";
	## Return the default Barcode object.
	return new APE::FlushControllerFactory::ConcreteFlushController::DefaultFlushController
	    (%args);
    }
}

1;
