package ForceField;

@ISA=qw(chemistry);
use AtomType;

sub new {
  my $class=shift;
  $self={name => '', types => {}, numTypes => 0};
  bless $self;
}

sub load {
	my ($class,$txt) = @_;
	$self = ForceField->new;
	for my $lin (split /\n/, $txt) {
		next if /^#/;
		my ($id,$esp,$sig,$mw,$sfact,$com)=split " ",$lin;
		my $type=AtomType->new;
		$type->id=$id;
		$type->esp=$esp;
		$type->sig=$sig;
		$type->sfact=$sfact;
		$self->addatType($type);
	}
	return $self;
};	

sub atType {
  my ($self,$id)=@_;
  return $self->{types}->{$id};
}

sub addatType {
  my ($self,$type)=@_;
  $self->{types}->{$type->{id}}=$type;
  $self->{numTypes} = scalar keys %{$self->{types}};
  return $self;
}

sub rmatType {
  my ($self,$id)=@_;
  undef $self->{types}->{$id};
  $self->{numTypes} = scalar keys %{$self->{types}};
  return $self;
}

sub numTypes {
	my $self =shift;
	return $self->{numTypes};
}
"1";
