Main Page | Modules | Namespace List | Class Hierarchy | Class List | Namespace Members | Class Members

Bond Class Reference
[Miscellaneous]

Bond class. More...

#include <bond.h>

Inheritance diagram for Bond:

Composite PropertyManager PersistentObject Selectable Object AutoDeletable List of all members.

Constructors and Destructors

 Bond () throw ()
 Default constructor.
 Bond (const Bond &bond, bool deep=true) throw ()
 Copy constructor.
 Bond (const String &name, Atom &first, Atom &second, Order order=BALL_BOND_DEFAULT_ORDER, Type type=BALL_BOND_DEFAULT_TYPE) throw (Exception::TooManyBonds)
 Detailed constructor.
virtual ~Bond () throw ()
 Destructor.
virtual void clear () throw ()
 Disconnect and reset to default state.
virtual void destroy () throw ()
 Explicit destructor.
BondcreateBond (Bond &bond, Atom &first, Atom &second) throw (Exception::TooManyBonds)
 Create a bond.

Public Types

Type definitions
typedef short Order
 Bond type.
typedef short Type
Enumerations
enum  BondOrder {
  ORDER__UNKNOWN = 0, ORDER__SINGLE = 1, ORDER__DOUBLE = 2, ORDER__TRIPLE = 3,
  ORDER__QUADRUPLE = 4, ORDER__AROMATIC = 5, ORDER__ANY = 6, NUMBER_OF_BOND_ORDERS
}
 Predefined constants for the bond order. More...
enum  BondType {
  TYPE__UNKNOWN = 0, TYPE__COVALENT = 1, TYPE__HYDROGEN = 2, TYPE__DISULPHIDE_BRIDGE = 3,
  TYPE__SALT_BRIDGE = 4, TYPE__PEPTIDE = 5, NUMBER_OF_BOND_TYPES
}
 Predefined constants for the bond type. More...
enum  Property { NUMBER_OF_PROPERTIES = 0 }
 Predefined properties. More...

Public Member Functions

Persistence
void persistentWrite (PersistenceManager &pm, const char *name=0) const throw (Exception::GeneralException)
 Write a bond to a persistent stream.
void persistentRead (PersistenceManager &pm) throw (Exception::GeneralException)
 Read a bond from a persistent stream.
void finalize () throw (Exception::GeneralException)
 Finalize the deserialization.
Predicates
bool operator== (const Bond &bond) const throw ()
 Equality operator. Two bonds are equal, if they are identical instances.
bool operator!= (const Bond &bond) const throw ()
 Inequality operator. Two bonds are not equal, if they are different instances.
Assignment methods
Bondoperator= (const Bond &bond) throw ()
 Assignment operator.
void swap (Bond &bond) throw ()
 Swap the contents of two bonds.
Accessors
void setFirstAtom (Atom *atom) throw ()
 Set the first atom.
void setSecondAtom (Atom *atom) throw ()
 Set the second atom.
const AtomgetFirstAtom () const throw ()
 Return a pointer to the first atom.
const AtomgetSecondAtom () const throw ()
 Return a pointer to the second atom.
AtomgetPartner (const Atom &atom) const throw ()
 Return the partner atom of an atom.
void setName (const String &name) throw ()
 Assign the atom name.
const StringgetName () const throw ()
 Return the atom name.
void setOrder (Order bond_order) throw ()
 Assign the bond order.
Order getOrder () const throw ()
 Return the bond order.
void setType (Type bond_type) throw ()
 Set the bond type.
Type getType () const throw ()
 Return the bond type.
float getLength () const throw (NotBound)
 Return the bond length.
const AtomgetBoundAtom (const Atom &atom) const throw ()
 Return the partner of the atom in this bond.
Predicates
bool isBondOf (const Atom &atom) const throw ()
 Determine whether the bond belongs to an atom.
bool isBound () const throw ()
 Determine whether this bond contains any atom.
bool isInterBond () const throw ()
 Determine whether the bond connects two fragments.
bool isInterBondOf (const AtomContainer &atom_container) const throw ()
 Request for the intermolecular bonding of this bond within {atom_container}.
bool isIntraBond () const throw ()
 Request for the intramolecular bonding of this bond.
bool isIntraBondOf (const AtomContainer &atom_container) const throw ()
 Request for the intramolecular bonding of this bond within {atom_container}.
Debugging and diagnostics
virtual bool isValid () const throw ()
 Internal state and consistency self-validation.
virtual void dump (std::ostream &s=std::cout, Size depth=0) const throw ()
 Internal state dump.

Protected Attributes

Atributes
Atomfirst_
Atomsecond_
String name_
Order bond_order_
Type bond_type_

Friends

class Atom

Detailed Description

Bond class.

An instance of Bond represents a bond between two atoms. There can be only one bond between two atoms (double, triple, etc. bonds are represented using just one bond and an appropriate value for the bond order attribute, see setBondOrder ).

The "first" and "second" atom are assigned in a unique way: the first atom is always the atom with the lower Handle thant the second atom.
The "state" of a bond is defined by its attributes:

Bond equality is defined as bond identity. A linear ordering of bonds is defined as the linear order of the Object::Handle s.


Member Typedef Documentation

typedef short Bond::Order
 

Bond type.


Member Enumeration Documentation

enum Bond::BondOrder
 

Predefined constants for the bond order.

Enumeration values:
ORDER__UNKNOWN  Default value.
ORDER__SINGLE  Single bond.
ORDER__DOUBLE  Double bond.
ORDER__TRIPLE  Triple Bond.
ORDER__QUADRUPLE  Quadruple bond.
ORDER__AROMATIC  Aromatic bonds.
ORDER__ANY  Any bond orders (useful for predicates).
NUMBER_OF_BOND_ORDERS  The number of bond orders.

enum Bond::BondType
 

Predefined constants for the bond type.

Those are just defined for convenience but they are not used right now.

enum Bond::Property
 

Predefined properties.

Enumeration of all properties that are used by Bond.


Constructor & Destructor Documentation

Bond::Bond  )  throw ()
 

Default constructor.

The state of this bond is:

Bond::Bond const Bond bond,
bool  deep = true
throw ()
 

Copy constructor.

Calls Bond::createBond . The state of this bond is initialized to the state of bond.

Note: Deep copying of bonds makes no sense, the parameter deep is therefore ignored. The use of this method is not recommended because it may result in inconcistencies of the whole the kernel data structure. This if for internal use only!
Parameters:
bond the bond to be copied
deep ignored
See also:
createBond

Bond::Bond const String name,
Atom first,
Atom second,
Order  order = BALL_BOND_DEFAULT_ORDER,
Type  type = BALL_BOND_DEFAULT_TYPE
throw (Exception::TooManyBonds)
 

Detailed constructor.

Calls createBond to create a new bond between the two atoms

Parameters:
name name of the constructed bond
first first atom of the constructed bond
second second atom of the constructed bond
order order of the constructed bond
type type of the constructed bond
Exceptions:
TooManyBonds if one of the atom already possesses Atom::MAX_NUMBER_OF_BONDS bonds.

virtual Bond::~Bond  )  throw () [virtual]
 

Destructor.

If the bond is connecting two atoms, they are disconnected.


Member Function Documentation

virtual void Bond::clear  )  throw () [virtual]
 

Disconnect and reset to default state.

Reset the bond attributes to their default values. The state of this bond is:

  • bond has no connectivity with first atom (=0)
  • bond has no connectivity with second atom (=0)
  • bond name is the empty string (="")
  • bond order is unknown (= Bond::ORDER__UNKNOWN )
  • bond type is unknown (= Bond::TYPE__UNKNOWN )

Reimplemented from Composite.

Bond* Bond::createBond Bond bond,
Atom first,
Atom second
throw (Exception::TooManyBonds) [static]
 

Create a bond.

Connect the two atoms first and second via a bond.

Parameters:
bond the instantiated bond that connects the first atom first to the second atom second
first the first atom of the bond
second the second atom of the bond
Returns:
Bond* this
Exceptions:
TooManyBonds if one of the atom already possesses Atom::MAX_NUMBER_OF_BONDS bonds.

virtual void Bond::destroy  )  throw () [virtual]
 

Explicit destructor.

Destroy this bond explicitly without releasing its heap memory thus this bond may exist further. Calls Bond::clear . Set the state of this bond to the default values. Note: Destroy is equivalent to Bond::clear .

See also:
Bond::clear

Reimplemented from Composite.

virtual void Bond::dump std::ostream &  s = std::cout,
Size  depth = 0
const throw () [virtual]
 

Internal state dump.

Dump the current internal state of this bond to the output ostream s with dumping depth depth .

Parameters:
s output stream where to output the internal state of this bond
depth the dumping depth

Reimplemented from Composite.

void Bond::finalize  )  throw (Exception::GeneralException) [virtual]
 

Finalize the deserialization.

Bond might have to swap first_ and second_ to ensure the correct order (see Bond ).

Reimplemented from PersistentObject.

const Atom* Bond::getBoundAtom const Atom atom  )  const throw ()
 

Return the partner of the atom in this bond.

Parameters:
atom an atom
Returns:
Atom a constant pointer to the atom, 0 if the atom is not part of the bond

float Bond::getLength  )  const throw (NotBound)
 

Return the bond length.

Exceptions:
NotBound if the bond has not two atoms
Returns:
float - the distance between the two atoms

Atom* Bond::getPartner const Atom atom  )  const throw ()
 

Return the partner atom of an atom.

If the given atom is part of this bond, the other atom of the bond is returned. 0 is returned if atom is not one of the bond's atoms.

Parameters:
atom one of the bond's atoms
Returns:
the atom's bond partner

bool Bond::isBondOf const Atom atom  )  const throw ()
 

Determine whether the bond belongs to an atom.

Calls Atom::hasBond .

Parameters:
atom the atom that is queried to connect this bond to another atom
Returns:
bool - true if bond connects the atom atom with another atom, false otherwise
See also:
Atom::hasBond

bool Bond::isBound  )  const throw ()
 

Determine whether this bond contains any atom.

Returns:
bool - true if bond connects the atom atom with another atom, false otherwise
See also:
Atom::hasBond

bool Bond::isInterBond  )  const throw ()
 

Determine whether the bond connects two fragments.

If both atoms have no roots, the result is false. Calls Composite::getRoot .

Returns:
bool - true if this bond is intermolecular, false otherwise
See also:
Composite::getRoot

bool Bond::isInterBondOf const AtomContainer atom_container  )  const throw ()
 

Request for the intermolecular bonding of this bond within {atom_container}.

Query, if this bond connects a atom within {atom_container} instance with an atom outside. Calls Composite::isDescendantOf .

Parameters:
atom_container the queried parent fragment.
Returns:
bool - true if this bond is intermolecular, false otherwise
See also:
Composite::isDescendantOf

bool Bond::isIntraBond  )  const throw ()
 

Request for the intramolecular bonding of this bond.

Query, if this bond connects its two atoms within a common parent Composite instance. If both atoms have no roots, the result is true. Calls Composite::getRoot .

Returns:
bool - true if this bond is intramolecular, false otherwise
See also:
Composite::getRoot

bool Bond::isIntraBondOf const AtomContainer atom_container  )  const throw ()
 

Request for the intramolecular bonding of this bond within {atom_container}.

Query, if this bond connects its two atoms within the common parent {atom_container} instance. Calls Composite::isDescendantOf .

Parameters:
atom_container the queried parent fragment.
Returns:
bool - true if this bond is intramolecular, false otherwise
See also:
Composite::isDescendantOf

virtual bool Bond::isValid  )  const throw () [virtual]
 

Internal state and consistency self-validation.

Returns:
bool - true if the internal state of this bond is correct (self-validated) and consistent, false otherwise

Reimplemented from Composite.

Bond& Bond::operator= const Bond bond  )  throw ()
 

Assignment operator.

Assign a deep copy (on the level of Composite ).

Note: The use of this method is not recommended because it may result in inconcistencies of the whole system. This is for internal use only.

Parameters:
bond the bond to be copied
Returns:
Bond - this bond
See also:
Bond::set

void Bond::persistentRead PersistenceManager pm  )  throw (Exception::GeneralException) [virtual]
 

Read a bond from a persistent stream.

Parameters:
pm the persistence manager

Reimplemented from Composite.

void Bond::persistentWrite PersistenceManager pm,
const char *  name = 0
const throw (Exception::GeneralException) [virtual]
 

Write a bond to a persistent stream.

Parameters:
pm the persistence manager

Reimplemented from Composite.

void Bond::setFirstAtom Atom atom  )  throw ()
 

Set the first atom.

This method does not ensure the correct order of atoms (see Bond ), so its use is recommended for internal purposes only.

void Bond::setSecondAtom Atom atom  )  throw ()
 

Set the second atom.

This method does not ensure the correct order of atoms (see Bond ), so its use is recommended for internal purposes only.

void Bond::swap Bond bond  )  throw ()
 

Swap the contents of two bonds.

Parameters:
bond the bond this is being swapped with
See also:
Bond::Bond