libRosetta Users Guide

Source Code

The libRosetta source code follows a set of conventions designed to make it easier to find things and to understand the source. An example of an interface class definition is shown at right and notes on the source code follow.

Naming

  • Class names are generally in CamelCase (mixed case) and data member and functions in lower_case. For compatibility with STL naming, where some types such as value_type are lower case, some libRosetta classes provide both sets of typedef names.
  • Private data members have names ending with '_', such as key_, angle_, or position_. The accessor functions are named without the '_', such as key(), angle(), or position().
  • The interface and other primary directories correspond to the namespace organization.
  • Typedef names are used to provide class-local names for types to insulate the classes and code that uses them from changes to the choice of implementing class.
  • Scalar floating point types have been given typedef names to help document the source and to allow libRosetta to be easily built with different floating point precisions for all or some of the primary types. This also provides some future-proofing: we can easily change some of those scalars to classes if the need arises.

Class Organization

Class definitions include some subset of the following categories in this order:

  • Types
  • Friends
  • Creation: Constructors, destructors, and related creational member functions
  • Assignments
  • Conversion functions
  • Methods: Member functions that do more than simple property getters or setters
  • Properties: Property accessor and assignment member functions (properties can include computed state values as well as data members)
  • Indexers: Indexing/subscripting accessors that do lookup by an index or key
  • Iterators
  • Comparisons
  • I/o functions
  • Protected functions
  • Private functions
  • Data members (private)
  • Static data members (private)

Function implementations in .cc files are in the same order as their declarations in the .hh header.

Interface classes generally have no data members and only pure virtual function declarations (those declared such as  virtual bool foo() const = 0;  where the =0 implies "pure", meaning no implementation is provided in the abstract class). The (simplified) Polymer interface on the right shows what that looks like.

 
Simplified Polymer Interface Source
#ifndef INCLUDED_rosetta_conformation_Polymer_HH
#define INCLUDED_rosetta_conformation_Polymer_HH


// Unit headers
#include <rosetta/conformation/Polymer.fwd.hh>

// Package headers
#include <rosetta/conformation/Molecule.hh>
#include <rosetta/conformation/HydrogenBond.fwd.hh>
#include <rosetta/conformation/HydrogenBonds.hh>
#include <rosetta/conformation/Residue.hh>
#include <rosetta/conformation/keys/PolymerKey.hh>

namespace rosetta {
namespace conformation {


/// @brief Conformation polymer interface class
class Polymer :
   public Molecule
{


private: // Types


   typedef  Molecule  Super;


public: // Types


   typedef  PolymerKey  Key;

   typedef  HydrogenBondOP  HydrogenBondP;

   typedef  HydrogenBonds::ConstIterator  HydrogenBonds_ConstIterator;
   typedef  HydrogenBonds::Iterator  HydrogenBonds_Iterator;


protected: // Creation


   /// @brief Default constructor
   inline
   Polymer()
   {}


   /// @brief Copy constructor
   inline
   Polymer( Polymer const & polymer ) :
      Super( polymer )
   {}


public: // Creation


   /// @brief Create one of these
   virtual
   Polymer *
   create() const = 0;


   /// @brief Clone this
   virtual
   Polymer *
   clone() const = 0;


   /// @brief Destructor
   inline
   virtual
   ~Polymer()
   {}


protected: // Assignment


   /// @brief Copy assignment
   inline
   Polymer &
   operator =( Polymer const & )
   {
      return *this;
   }


public: // Methods


   /// @brief Clear the neighbors
   virtual
   void
   clear_neighbors() = 0;


public: // Properties


   /// @brief Key
   virtual
   Key const &
   key() const = 0;


   /// @brief Number of residues
   virtual
   Size
   n_residue() const = 0;


   /// @brief Hydrogen bond container
   virtual
   HydrogenBonds const &
   H_bonds() const = 0;


   /// @brief Hydrogen bond container
   virtual
   HydrogenBonds &
   H_bonds() = 0;


public: // Indexers


   /// @brief Residue i
   virtual
   Residue const &
   operator []( Size const i ) const = 0;


   /// @brief Residue i
   virtual
   Residue &
   operator []( Size const i ) = 0;


   /// @brief Residue i
   virtual
   Residue const &
   residue( Size const i ) const = 0;


   /// @brief Residue i
   virtual
   Residue &
   residue( Size const i ) = 0;


public: // Iterators


   /// @brief Hydrogen bonds begin const iterator
   virtual
   HydrogenBonds_ConstIterator
   H_bonds_begin() const = 0;


   /// @brief Hydrogen bonds end const iterator
   virtual
   HydrogenBonds_ConstIterator
   H_bonds_end() const = 0;


   /// @brief Hydrogen bonds begin iterator
   virtual
   HydrogenBonds_Iterator
   H_bonds_begin() = 0;


   /// @brief Hydrogen bonds end Iterator
   virtual
   HydrogenBonds_Iterator
   H_bonds_end() = 0;


}; // Polymer


} // namespace conformation
} // namespace rosetta


#endif // INCLUDED_rosetta_conformation_Polymer_HH
Support | ©2007 Rosetta Commons