Index: kernel/include/Vector3D.h =================================================================== --- kernel/include/Vector3D.h (revision 916) +++ kernel/include/Vector3D.h (working copy) @@ -17,6 +17,7 @@ IMP_BEGIN_NAMESPACE +//! A location in 3D typedef VectorD<3> Vector3D; IMP_END_NAMESPACE Index: kernel/include/base_types.h =================================================================== --- kernel/include/base_types.h (revision 916) +++ kernel/include/base_types.h (working copy) @@ -17,13 +17,6 @@ IMP_BEGIN_NAMESPACE -/** \defgroup kernel IMP Kernel - The core IMP types - - \defgroup helper Miscellaneous helpers - Classes and functions which are there to make your life easier. - */ - /** \internal \namespace IMP::internal Implementation details. */ @@ -37,9 +30,11 @@ typedef std::string String; - +//! Standard way to pass a bunch of Float values typedef std::vector Floats; +//! Standard way to pass a bunch of Int values typedef std::vector Ints; +//! Standard way to pass a bunch of String values typedef std::vector Strings; @@ -49,9 +44,13 @@ struct ScoreStateTag {}; struct OptimizerStateTag {}; +//! Index to access a Particle in a container in an object typedef Index ParticleIndex; +//! Index to access a Restraint in a container in an object typedef Index RestraintIndex; +//! Index to access a ScoreState in a container in an object typedef Index ScoreStateIndex; +//! Index to access a OptimizerState in a container in an object typedef Index OptimizerStateIndex; class Particle; @@ -62,10 +61,12 @@ is not as pretty for Python. */ typedef std::vector Particles; +//! The standard way of storing a pair of Particles typedef std::pair ParticlePair; +//! A collection of ParticlePair typedef std::vector ParticlePairs; - +//! A collection of ParticleIndex typedef std::vector ParticleIndexes; class Particle; Index: kernel/include/SingletonScore.h =================================================================== --- kernel/include/SingletonScore.h (revision 916) +++ kernel/include/SingletonScore.h (working copy) @@ -16,12 +16,6 @@ class Particle; -/** \ingroup restraint - \addtogroup singleton Score functions on one particle - Score functions to be applied to a single particle. These can be - used to make more flexible restraints. - */ - //! Abstract score function for a single particle. /** SingletonScores should take a UnaryFunction as their first argument if such is needed. @@ -34,6 +28,9 @@ //! Compute the score for the particle and the derivative if needed. virtual Float evaluate(Particle *a, DerivativeAccumulator *da) const = 0; + //! Print information about the SingletonScore to a stream. + /** Should end in a newline. + */ virtual void show(std::ostream &out=std::cout) const = 0; }; Index: kernel/include/exception.h =================================================================== --- kernel/include/exception.h (revision 916) +++ kernel/include/exception.h (working copy) @@ -143,9 +143,6 @@ #define IMP_IF_CHECK(level)\ if (level <= ::IMP::get_check_level()) -namespace internal -{ - //! This is just here so you can catch errors more easily in the debugger /** Break on exception.cpp:31 to catch assertion failures. \ingroup assert @@ -158,8 +155,6 @@ */ IMPDLLEXPORT void check_fail(const char *msg); -} // namespace internal - #ifndef NDEBUG //! An assertion for IMP. An IMP::ErrorException will be thrown. @@ -178,7 +173,7 @@ oss << message << std::endl \ << " File \"" << __FILE__ << "\", line " << __LINE__ \ << std::endl; \ - IMP::internal::assert_fail(oss.str().c_str()); \ + IMP::assert_fail(oss.str().c_str()); \ } \ } while(false) #else @@ -197,7 +192,7 @@ if (IMP::get_check_level() >= IMP::CHEAP && !(expr)) { \ std::ostringstream oss; \ oss << message << std::endl; \ - IMP::internal::check_fail(oss.str().c_str()); \ + IMP::check_fail(oss.str().c_str()); \ throw ExceptionType(oss.str().c_str()); \ } \ } while (false) @@ -211,7 +206,7 @@ #define IMP_failure(message, ExceptionType) { \ std::ostringstream oss; \ oss << message << std::endl; \ - IMP::internal::check_fail(oss.str().c_str()); \ + IMP::check_fail(oss.str().c_str()); \ throw ExceptionType(oss.str().c_str());} IMP_END_NAMESPACE Index: kernel/include/Model.h =================================================================== --- kernel/include/Model.h (revision 916) +++ kernel/include/Model.h (working copy) @@ -26,15 +26,16 @@ //! Class for storing model, its restraints, and particles. /** The Model maintains a standard IMP container for each of Particle, ScoreState and Restraint object types. - \ingroup kernel */ class IMPDLLEXPORT Model: public Object { - private: +private: friend class Restraint; unsigned int iteration_; public: + //! Model(); + //! ~Model(); IMP_CONTAINER(Particle, particle, ParticleIndex); Index: kernel/include/VersionInfo.h =================================================================== --- kernel/include/VersionInfo.h (revision 916) +++ kernel/include/VersionInfo.h (working copy) @@ -22,7 +22,6 @@ VersionInfo(std::string author, std::string version) : author_(author), version_(version) {} - //! Default constructor VersionInfo() : author_("unknown"), version_("unknown") {} //! \return author of this object. @@ -37,7 +36,7 @@ out << "author: " << author_ << std::endl; } -protected: +private: std::string author_, version_; }; Index: kernel/include/DerivativeAccumulator.h =================================================================== --- kernel/include/DerivativeAccumulator.h (revision 916) +++ kernel/include/DerivativeAccumulator.h (working copy) @@ -19,9 +19,11 @@ class IMPDLLEXPORT DerivativeAccumulator { public: + //! the weight is one by default DerivativeAccumulator(Float weight=1.0) : weight_(weight) {} + //! The weight is multiplied by the new weight DerivativeAccumulator(const DerivativeAccumulator ©, Float weight=1.0) : weight_(copy.weight_ * weight) {} @@ -34,7 +36,7 @@ return value * weight_; } -protected: +private: Float weight_; }; Index: kernel/include/Particle.h =================================================================== --- kernel/include/Particle.h (revision 916) +++ kernel/include/Particle.h (working copy) @@ -22,20 +22,6 @@ IMP_BEGIN_NAMESPACE -namespace internal -{ - -template -void check_particles_active(It b, It e, std::string msg) -{ - for (It c= b; c != e; ++c) { - IMP_check((*c)->get_is_active(), msg, - InactiveParticleException); - } -} - -} // namespace internal - class Model; //! Class to handle individual model particles. @@ -73,8 +59,6 @@ \note In general, Particles should only be used through \ref decorators "Decorators" as these provide a nice and more reliable interface. - - \ingroup kernel */ class IMPDLLEXPORT Particle : public RefCountedObject { Index: kernel/include/UnaryFunction.h =================================================================== --- kernel/include/UnaryFunction.h (revision 916) +++ kernel/include/UnaryFunction.h (working copy) @@ -18,8 +18,6 @@ //! Abstract single variable functor class for score functions. /** These functors take a single feature value, and return a corresponding score (and optionally also the first derivative). - - \ingroup kernel */ class IMPDLLEXPORT UnaryFunction : public RefCountedObject { @@ -41,6 +39,9 @@ */ virtual FloatPair evaluate_with_derivative(Float feature) const = 0; + //! Print information about the UnaryFunction to a stream. + /** Should end in a newline. + */ virtual void show(std::ostream &out=std::cout) const = 0; }; Index: kernel/include/VectorD.h =================================================================== --- kernel/include/VectorD.h (revision 916) +++ kernel/include/VectorD.h (working copy) @@ -22,8 +22,6 @@ IMP_BEGIN_NAMESPACE //! Simple D vector class -/** \ingroup helper - */ template class IMPDLLEXPORT VectorD { Index: kernel/include/Index.h =================================================================== --- kernel/include/Index.h (revision 916) +++ kernel/include/Index.h (working copy) @@ -38,6 +38,7 @@ ValueException); return i_; } + //! void show(std::ostream &out) const { if (!is_default()) { out << "(" << i_ << ")"; @@ -57,7 +58,7 @@ ++i_; } #endif -protected: +private: bool is_default() const { return i_==-1; } Index: kernel/include/IMP_config.h =================================================================== --- kernel/include/IMP_config.h (revision 916) +++ kernel/include/IMP_config.h (working copy) @@ -34,4 +34,14 @@ #define IMP_END_NAMESPACE \ } /* namespace IMP */ +#define IMP_BEGIN_INTERNAL_NAMESPACE \ +IMP_BEGIN_NAMESPACE \ +namespace internal \ +{ + +#define IMP_END_INTERNAL_NAMESPACE \ +} /* namespace internal */ \ +IMP_END_NAMESPACE + + #endif /* IMP_CONFIG_H */ Index: kernel/include/Restraint.h =================================================================== --- kernel/include/Restraint.h (revision 916) +++ kernel/include/Restraint.h (working copy) @@ -27,17 +27,7 @@ typedef std::vector ParticlesList; class Model; -/** \defgroup restraint General purpose restraints - Classes to define and help in defining restraints. The restraints - typically involve a Restraint which defines the set of tuples of Particles - and then various functions which are applied to the tuples. - */ -/** \defgroup exp_restraint Experimental restraints - These are restraints which directly use various types of experimental - data. - */ - //! Abstract class for representing restraints /** Restraints should take their score function or UnaryFunction as the first argument. Restraints which act on large numbers of @@ -60,13 +50,10 @@ without ever having been added to a model as this is an easy mistake to make. To disable this warning for a particular restraint, call set_was_owned(true). - - \ingroup kernel */ class IMPDLLEXPORT Restraint : public RefCountedObject { public: - //! Initialize the Restraint Restraint(); virtual ~Restraint(); Index: kernel/include/DecoratorBase.h =================================================================== --- kernel/include/DecoratorBase.h (revision 916) +++ kernel/include/DecoratorBase.h (working copy) @@ -14,50 +14,6 @@ IMP_BEGIN_NAMESPACE -/** \defgroup decorators Decorators - -Decorators wrap particles -- maintain invariants: e.g. any the particles have all of x,y,z coordinates -- add functionality: e.g. you can get the coordinates as an IMP::Vector3D -- provide uniform names for attributes: so you don't use "x" some places -and "X" other places -- cache keys since those can be expensive to create - -\note In general, you should not access particle attributes except -through decorators - - -The general usage of the decorators is quite simple -- Create a decorator around a particle which does not have the needed -attributes. This adds the attributes. -\verbatim -d= IMP.core.MyDecorator.create(p) -\endverbatim -- Cast a particle which has the required attributes to a decorator, -checking that it has the attributes -\verbatim -d= IMP.core.MyDecorator.cast(p) -\endverbatim -- Wrap a particle which is known to have the required attributes in a -decorator. No checks are necessarily made -\verbatim -d= IMP.core.MyDecorator(p) -\endverbatim -- Access and manipulate attributes or groups of attributes through -methods like -\verbatim -x=d.get_foo() -d.set_foo(1.0) -\endverbatim -- When needed, access the keys used by the decorator through methods like -\verbatim -d.get_foo_key() -\endverbatim - - */ - - - /** A base class for decorators. Implementers of decorators should just inherit from this and then use the IMP_DECORATOR macro */ Index: kernel/include/ParticleRefiner.h =================================================================== --- kernel/include/ParticleRefiner.h (revision 916) +++ kernel/include/ParticleRefiner.h (working copy) @@ -43,6 +43,8 @@ */ virtual void cleanup_refined(Particle *a, Particles &b, DerivativeAccumulator *da=0) const {} + //! Print information about the refiner + /** It should end in a new line. */ virtual void show(std::ostream &out=std::cout) const { out << "ParticleRefiner base" << std::endl; }; Index: kernel/include/TripletScore.h =================================================================== --- kernel/include/TripletScore.h (revision 916) +++ kernel/include/TripletScore.h (working copy) @@ -15,13 +15,6 @@ IMP_BEGIN_NAMESPACE -/** - \ingroup restraint - \addtogroup tripletscore Score functions on three particles - Score functions to by applied to a triplet of particles. These can be - used to make more flexible restraints. - */ - //! Abstract score function for a triplet of particles. /** TripletScores should take a UnaryFunction as their first argument if such is needed. @@ -34,6 +27,9 @@ //! Compute the score for the triplet and the derivative if needed. virtual Float evaluate(Particle *a, Particle *b, Particle *c, DerivativeAccumulator *da) const = 0; + //! Print information about the TripletScore to a stream. + /** Should end in a newline. + */ virtual void show(std::ostream &out=std::cout) const = 0; }; Index: kernel/include/Pointer.h =================================================================== --- kernel/include/Pointer.h (revision 916) +++ kernel/include/Pointer.h (working copy) @@ -58,50 +58,64 @@ typedef bool (This::*unspecified_bool)() const; public: + /** copy constructor */ Pointer(const Pointer &o): o_(NULL) { set_pointer(o.o_); } + /** copy from another */ Pointer& operator=(const Pointer &o){ set_pointer(o.o_); return *this; } + //! initialize to NULL Pointer(): o_(NULL) {} + /** initialize from a pointer */ explicit Pointer(O* o): o_(NULL) { IMP_assert(o, "Can't initialize with NULL pointer"); set_pointer(o); } + /** drop control of the object */ ~Pointer(){ set_pointer(NULL); } + /** it's a pointer */ const O& operator*() const { audit(); return *o_; } + /** it's a pointer */ O& operator*() { audit(); return *o_; } + /** it's a pointer */ const O* operator->() const { audit(); return o_; } + /** it's a pointer */ O* operator->() { audit(); return o_; } + //! get the raw pointer O* get() const { audit(); return o_; } + //! Set it from a possibly NULL pointer. void operator=(O* o) { set_pointer(o); } + IMP_COMPARISONS_1(o_); + //! Return true if the pointer is not NULL bool operator!() const { return !o_; } + //! convert to the raw pointer operator O*() const { return o_; } Index: kernel/include/Optimizer.h =================================================================== --- kernel/include/Optimizer.h (revision 916) +++ kernel/include/Optimizer.h (working copy) @@ -25,10 +25,6 @@ typedef std::vector OptimizerStates; -/** \defgroup optimizer Optimizers - Optimizers of various sorts. - */ - //! Base class for all optimizers. /** The Optimizer maintains a list of OptimizerStates which are updated each time the conformation is changed. @@ -66,6 +62,8 @@ */ void set_model(Model *m) {model_=m;} + //! Print info about the optimizer state + /** It should end in a newline */ virtual void show(std::ostream &out= std::cout) const { out << "Some optimizer" << std::endl; } Index: kernel/include/internal/key_helpers.h =================================================================== --- kernel/include/internal/key_helpers.h (revision 0) +++ kernel/include/internal/key_helpers.h (revision 0) @@ -0,0 +1,45 @@ +/** + * \file key_helpers.h \brief helpers for declaring keys. + * + * Copyright 2007-8 Sali Lab. All rights reserved. + * + */ + +#ifndef IMP_INTERNAL_KEY_HELPERS_H +#define IMP_INTERNAL_KEY_HELPERS_H + +#include "../IMP_config.h" +#include + +IMP_BEGIN_INTERNAL_NAMESPACE +/** \internal The data concerning keys. + */ +struct IMPDLLEXPORT KeyData +{ + typedef std::map Map; + typedef std::vector RMap; + + void show(std::ostream &out= std::cout) const; + KeyData(); + void assert_is_initialized() const; + unsigned int add_key(std::string str) { + unsigned int i= map_.size(); + map_[str]=i; + rmap_.push_back(str); + return i; + } + + const Map &get_map() const {return map_;} + const RMap &get_rmap() const {return rmap_;} + +private: + double heuristic_; + Map map_; + RMap rmap_; +}; + +IMPDLLEXPORT extern std::map key_data; + +IMP_END_INTERNAL_NAMESPACE + +#endif /* IMP_INTERNAL_KEY_HELPERS_H */ \ No newline at end of file Index: kernel/include/internal/SConscript =================================================================== --- kernel/include/internal/SConscript (revision 916) +++ kernel/include/internal/SConscript (working copy) @@ -1,7 +1,7 @@ files = ['AttributeTable.h', 'Vector.h', 'ref_counting.h', 'ObjectContainer.h', 'kernel_version_info.h', 'constants.h', 'units.h', - 'utility.h', 'Unit.h', 'ExponentialNumber.h'] + 'utility.h', 'Unit.h', 'ExponentialNumber.h', 'key_helpers.h'] files = [File(f) for f in files] Return('files') Index: kernel/include/PairScore.h =================================================================== --- kernel/include/PairScore.h (revision 916) +++ kernel/include/PairScore.h (working copy) @@ -15,12 +15,6 @@ IMP_BEGIN_NAMESPACE -/** \ingroup restraint - \addtogroup pairscore Score functions on two particles - Score functions to by applied to a pair of particles. These can be - used to make more flexible restraints. - */ - //! Abstract score function for a pair of particles. /** PairScores should take a UnaryFunction as their first argument if such is needed. @@ -33,6 +27,8 @@ //! Compute the score for the pair and the derivative if needed. virtual Float evaluate(Particle *a, Particle *b, DerivativeAccumulator *da) const = 0; + //! Print information for the PairScore. + /** Should end in a newline. */ virtual void show(std::ostream &out=std::cout) const = 0; }; Index: kernel/include/Key.h =================================================================== --- kernel/include/Key.h (revision 916) +++ kernel/include/Key.h (working copy) @@ -10,6 +10,7 @@ #include "macros.h" #include "exception.h" +#include "internal/key_helpers.h" #include #include @@ -63,42 +64,7 @@ }; \ typedef std::vector Name##s -namespace internal -{ - -/** \internal The data concerning keys. - */ -struct IMPDLLEXPORT KeyData -{ - typedef std::map Map; - typedef std::vector RMap; - - void show(std::ostream &out= std::cout) const; - KeyData(); - void assert_is_initialized() const; - unsigned int add_key(std::string str) { - unsigned int i= map_.size(); - map_[str]=i; - rmap_.push_back(str); - return i; - } - - const Map &get_map() const {return map_;} - const RMap &get_rmap() const {return rmap_;} - -private: - double heuristic_; - Map map_; - RMap rmap_; -}; - -IMPDLLEXPORT extern std::map key_data; - -} // namespace internal - - - //! A base class for Keys /** This class does internal caching of the strings to accelerate the name lookup. It is better to create an Key and reuse it @@ -129,7 +95,7 @@ return get_map().find(sc)->second; } } -protected: +private: bool is_default() const; public: static const std::string get_string(int i) Index: kernel/src/exception.cpp =================================================================== --- kernel/src/exception.cpp (revision 916) +++ kernel/src/exception.cpp (working copy) @@ -51,12 +51,15 @@ { } -namespace internal +namespace { // The error message is already in the exception bool print_exceptions=false; + +} + void assert_fail(const char *msg) { if (print_exceptions) { @@ -72,6 +75,4 @@ } } -} // namespace internal - IMP_END_NAMESPACE