package MpmasPerennialObject;
use strict;
use warnings;
use Exporter;
use Storable qw(dclone);
use Data::Dumper;
use MpmasQLModelElementAbstract;
use CtUtilities qw(is_in_list is_in_string_list);

our @ISA = qw(MpmasQLModelElementAbstract);

##class variables

sub defaultclass {
	"perennial"
}
sub list_of_default_fields { 
	my @array = qw( );
	return \@array;
}
sub list_of_attribute_fields{
	my @array = qw(othermilp othermilp_subelements name dyninfo lifetime acqcost terrain managementswitch perennial_yield perennial_harvest_cost perennial_preharvest_cost obj thiscomp switchgroup oid unit);
	return \@array;
}
sub list_of_attribute_stubs {
	my @array = qw();
	return \@array;
}
#instance methods
sub obj {
	my $self = shift;
	return $self->{obj};
}
sub acqcost {
	my $self = shift;
	return $self->{acqcost};
}
sub lifetime {
	my $self = shift;
	return $self->{lifetime};
}
sub dynfield {
	my $self = shift;
	my $field = shift;
	return $self->attr($field)  if (is_in_string_list($field, $self->list_of_attribute_fields));
        return $self->{others}->{$field};
}
sub oid {
	my $self = shift;
	return 	$self->{oid};
}
sub set_oid {
      my $self = shift;
      my $oid = shift;
      $self->{oid} = $oid;
}
sub export_affected_constraints {
	my $self = shift;
	return keys (%{$self->{others}});
}
sub set_switchgroup {
      my $self = shift;
      my $switchgroup = shift;
      $self->{switchgroup} = $switchgroup;
}
sub switchgroup {
      my $self = shift;
      return $self->{switchgroup};
}
sub switchlist {
     my $self = shift;
     return keys %{$self->{managementswitch}};
}
sub activity_of_switch_from {
    my $self = shift;
    my $switchto = shift;
    return $self->{managementswitch}->{$switchto};
    
}
sub managementswitch {
      my $self = shift;
      return $self->{managementswitch};
}
1;
