NAME
Chemistry::Obj - Abstract chemistry object
SYNOPSIS
use base "Chemistry::Obj";
Chemistry::Obj::accessor('myattr1', 'myattr2');
DESCRIPTION
This module implements some generic methods that are used by Chemistry::Mol, Chemistry::Atom, Chemistry::Bond, etc.
Common Attributes
There are some common attributes that may be found in molecules, bonds, and atoms, such as id, name, and type. They are all accessed through the methods of the same name. For example, to get the id, call $obj->id; to set the id, call $obj->id('new_id').
- id
-
Objects should have a unique ID. The user has the responsibility for uniqueness if he assigns ids; otherwise a unique ID is assigned sequentially.
- name
-
An arbitrary name for an object. The name doesn't need to be unique.
- type
-
The interpretation of this attribute is not specified here, but it's typically used for bond orders and atom types.
- attr
-
A space where the user can store any kind of information about the object. The accessor method for attr expects the attribute name as the first parameter, and (optionally) the new value as the second parameter.
OTHER METHODS
OPERATOR OVERLOADING
Chemistry::Obj overloads a couple of operators for convenience.
- ""
-
The stringification operator. Stringify an object as its id. For example, If an object $obj has the id 'a1', print "$obj" will print 'a1' instead of something like 'Chemistry::Obj=HASH(0x810bbdc)'. If you really want to get the latter, you can call overload::StrVal($obj).
- cmp
-
Compare objects by ID. This automatically overloads eq, ne, lt, le, gt, and ge as well. For example, $obj1 eq $obj2 returns true if both objects have the same id, even if they are different objects with different memory addresses. In contrast, $obj1 == $obj2 will return true only if $obj1 and $obj2 point to the same object, with the same memory address.
VERSION
0.25
SEE ALSO
Chemistry::Atom, Chemistry::Bond, Chemistry::Mol
The PerlMol website http://www.perlmol.org/
AUTHOR
Ivan Tubert <itub@cpan.org>
COPYRIGHT
Copyright (c) 2004 Ivan Tubert. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.