package APE::InputControllerFactory::ConcreteInputController::CPEP_InputController;

use base 'APE::InputControllerFactory::ConcreteInputController::DefaultExoApeInputController';

$APE::InputControllerFactory::ConcreteInputController::CPEP_InputController::VERSION = '0.1';


use strict;
use warnings;
use Carp;

use constant LOGIN => 'snp';
use constant TRUE  => 1;
use constant FALSE => 0;

{
    my %_attributes = ( 
			## ** Add your object attributes here **
			## They will automatically be given a get method.
			## e.g. attribute 'personForename' can be accessed
			## using getPersonForname(). There are no automatic 
			## set routines, they must be declared or the attribute 
			## value must be parsed in the constructor 
			## i.e new InputController(personForename=>'Simon');
			);

    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 the description as this is a specialised InputController.
	$args{description} = "An InputController that overrides the getData method from the super class ".
	    "InputController to allow cherry picked data to be set." unless $args{description};
	
	return $self->SUPER::_init(%args);
    }


    #################################################################
    ## This method overrides the process method declared in the super
    ## class STUDY_InputController class. This method accepts an array
    ## ref of data ($data) that represents the data to be set in the
    ## overridden getData method below.
    #################################################################
    sub process {
	my ($self,$requirementObj,$data) = @_;
	if(defined $data) {
	    print STDERR "Setting the cherry picked data\n";
	    $object{ $self }->{cherryPickData} = $data;
	}
	$self->SUPER::process($requirementObj);
    }


    #################################################################
    ## This method overrides the getData method declared in the super
    ## class InputController class. This method allows the Requirement
    ## objects data store to be set with passed data - danger! This
    ## data may be the product of a cherry pick.
    #################################################################
    sub getData {
	my ($self,$requirementObj,$data) = @_;
	print STDERR "Setting the requirement data store to: ".$object{ $self }->{cherryPickData}."\n";
	## Just set the data store for the EP plates.
	$requirementObj->setDataStore($object{ $self }->{cherryPickData});
	return $requirementObj;
    }
}

1;
