GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Chemistry::Obj(3) User Contributed Perl Documentation Chemistry::Obj(3)

Chemistry::Obj - Abstract chemistry object

    package MyObj;
    use base "Chemistry::Obj";
    Chemistry::Obj::accessor('color', 'flavor');

    package main;
    my $obj = MyObj->new(name => 'bob', color => 'red');
    $obj->attr(size => 42);
    $obj->color('blue');
    my $color = $obj->color;
    my $size = $obj->attr('size');

This module implements some generic methods that are used by Chemistry::Mol, Chemistry::Atom, Chemistry::Bond, Chemistry::File, etc.

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. It can also take a hash or hashref with several attributes. Examples:

    $color = $obj->attr('color');
    $obj->attr(color => 'red');
    $obj->attr(color => 'red', flavor => 'cherry');
    $obj->attr({color => 'red', flavor => 'cherry'});
    

$obj->del_attr($attr_name)
Delete an attribute.
$class->new(name => value, name => value...)
Generic object constructor. It will automatically call each "name" method with the parameter "value". For example,

    $bob = Chemistry::Obj->new(name => 'bob', attr => {size => 42});
    

is equivalent to

    $bob = Chemistry::Obj->new;
    $bob->name('bob');
    $bob->attr({size => 42});
    

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)". See overload for details.
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.

<https://github.com/perlmol/Chemistry-Mol>

Chemistry::Atom, Chemistry::Bond, Chemistry::Mol

Ivan Tubert-Brohman <itub@cpan.org>

Copyright (c) 2005 Ivan Tubert-Brohman. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
2021-04-09 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.