EntityVisitor Class Reference

EntityVisitor interface. More...

#include <entity_visitor.hh>

Inherited by CRDWriter, CRDWriter, PQRWriter, and PQRWriter.

Public Member Functions

virtual ~EntityVisitor ()
virtual void OnEntry ()
virtual void OnExit ()
virtual bool VisitChain (const ChainHandle &c)
virtual bool VisitResidue (const ResidueHandle &r)
virtual bool VisitAtom (const AtomHandle &a)
virtual bool VisitBond (const BondHandle &b)
virtual bool VisitTorsion (const TorsionHandle &t)

Detailed Description

EntityVisitor interface.

Entity Visitor interface

For hierarchical traversal of the entity-chain-residue-atom hierarchy OpenStructure offers the concept of (simplified) visitors. By passing a subclass of EntityVisitor to the the EntityHandle::Apply(EntityVisitor&) member function, the whole subtree rooted at the object where Apply was invoked is then traversed in a recursive manner.

Visitors may be applied to both Handles and Views, so they are a good way to generalise your algorithms for EntityView and EntitHandle the like.

Algorithms are implemented by subclassing EntityVisitor and overriding one or more of the callbacks.

EntityVisitor provides stub implementations for all of the callbacks. You only have to overload the callbacks you are interested in. Every callback returns a bool to indicate whether the hierarchical traversal should continue. Returning false indicates that recursive traversal should stop and continue with the next sibling.

Example

The following example prints residues and their atoms to stdout

 class Printer : public EntityVisitor { public:
   virtual bool VisitResidue(const ResidueHandle& residue) {
     std::cout << residue.GetKey() << "." << residue.GetNumber() << std::endl;
     return true;
   }
   virtual bool VisitAtom(const AtomHandle& atom) {
     std::cout << " " << atom.GetName() << std::endl;
     return true;
   }
 };
Note:
The order of traversal for chains and atoms is implementation specific and your algorithms should not rely on a particular order. However, residues are visited in ascending order of their residue numbers.

Definition at line 73 of file entity_visitor.hh.


Constructor & Destructor Documentation

virtual ~EntityVisitor (  )  [virtual]

Member Function Documentation

virtual void OnEntry (  )  [virtual]
virtual void OnExit (  )  [virtual]
virtual bool VisitAtom ( const AtomHandle a  )  [virtual]

Atom callback.

Reimplemented in CRDWriter, PQRWriter, CRDWriter, and PQRWriter.

virtual bool VisitBond ( const BondHandle b  )  [virtual]

Bond callback.

Todo:
not implemented for views
virtual bool VisitChain ( const ChainHandle c  )  [virtual]

Chain callback.

virtual bool VisitResidue ( const ResidueHandle r  )  [virtual]

Residue callback.

Reimplemented in CRDWriter, PQRWriter, CRDWriter, and PQRWriter.

virtual bool VisitTorsion ( const TorsionHandle t  )  [virtual]

Torsion callback.

Todo:
Not implemented for views

The documentation for this class was generated from the following file:
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines

Generated on 1 Mar 2018 for OpenStructure by  doxygen 1.6.1