package ForceField;

use Chemistry::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 $lin =~ /^#/;
		my ($id,$eps,$sig,$mw,$sfact,$nlp,$vol,$com)=split " ",$lin;
		my $type=AtomType->new;
		$type->id($id);
		$type->eps($eps);
		$type->sig($sig);
		$type->sfact($sfact);
		$type->mw($mw);
		$type->nlp($nlp);
		$type->vol($vol);
		$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 types {
	my $self = shift;
	return $self->{types};
};

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