#
#  Attribute.pm
#  --generic attribute container
#

package Mchange::Attribute;

use strict;

use lib '/afs/.cs.wisc.edu/s/mchange-2.2/common/perl5';


sub new {

  my ( $class, $data ) = @_;

  my $ref = { data => $data };
              
  return bless $ref, $class;

}

sub DESTROY {


}


#
#  get
#  --return the named attrib
#

sub get {

  my ( $self, $attrib ) = @_;

  return $self->{data}{$attrib};

}

#
#  set
#  --set the named attrib
#

sub set {

  my ( $self, $attrib, $value ) = @_;

  $self->{data}{$attrib} = $value;
  $self->{change}{$attrib} = $value;
  
}

#
#  copy
#  --return a deep copy of ourself
#

sub copy {

  my ( $self ) = @_;

  my %newdata;

  map { $newdata{$_} = $self->{data}{$_} } keys %{$self->{data}};
  
  return new Mchange::Attribute( \%newdata );
  
}


1;

