00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef IMP_QUAD_CONTAINER_H
00011 #define IMP_QUAD_CONTAINER_H
00012
00013 #include "kernel_config.h"
00014 #include "internal/IndexingIterator.h"
00015 #include "Particle.h"
00016 #include "container_base.h"
00017 #include "utility.h"
00018 #include "VersionInfo.h"
00019 #include "base_types.h"
00020 #include "Pointer.h"
00021 #include "VectorOfRefCounted.h"
00022 #include "VersionInfo.h"
00023 #include "DerivativeAccumulator.h"
00024 #include "internal/OwnerPointer.h"
00025 #include "macros.h"
00026
00027 IMP_BEGIN_NAMESPACE
00028 class QuadModifier;
00029 class QuadScore;
00030
00031
00032
00033
00034
00035
00036
00037
00038 class IMPEXPORT QuadContainer : public Container
00039 {
00040 internal::OwnerPointer<Container> added_, removed_;
00041 struct Accessor {
00042 typedef Accessor This;
00043 typedef ParticleQuad result_type;
00044 typedef unsigned int argument_type;
00045 result_type operator()(argument_type i) const {
00046 return o_->get_particle_quad(i);
00047 }
00048 Accessor(QuadContainer *pc): o_(pc){}
00049 Accessor(): o_(NULL){}
00050 IMP_COMPARISONS_1(o_);
00051 private:
00052
00053 QuadContainer* o_;
00054 };
00055 protected:
00056
00057
00058
00059
00060
00061
00062
00063 void set_added_and_removed_containers(QuadContainer* added,
00064 QuadContainer* removed) {
00065 added_=added;
00066 removed_=removed;
00067 }
00068
00069 public:
00070 #ifndef IMP_DOXYGEN
00071 bool get_is_added_or_removed_container() {
00072 return !added_;
00073 }
00074 #endif
00075
00076 QuadContainer(std::string name="QuadContainer %1%");
00077
00078
00079
00080
00081 virtual bool get_contains_particle_quad(const ParticleQuad& v) const =0;
00082
00083
00084
00085 virtual unsigned int get_number_of_particle_quads() const =0;
00086
00087 ParticleQuadsTemp get_particle_quads() const {
00088 return ParticleQuadsTemp(particle_quads_begin(),
00089 particle_quads_end());
00090 }
00091 virtual ParticleQuad get_particle_quad(unsigned int i) const=0;
00092
00093 #ifdef IMP_DOXYGEN
00094
00095 class ParticleQuadIterator;
00096 #else
00097 typedef internal::IndexingIterator<Accessor> ParticleQuadIterator;
00098 #endif
00099
00100 ParticleQuadIterator particle_quads_begin() const {
00101
00102 return
00103 ParticleQuadIterator(Accessor(const_cast<QuadContainer*>(this)),
00104 0);
00105 }
00106
00107 ParticleQuadIterator particle_quads_end() const {
00108 return
00109 ParticleQuadIterator(Accessor(const_cast<QuadContainer*>(this)),
00110 get_number_of_particle_quads());
00111 }
00112
00113
00114 virtual void apply(const QuadModifier *sm)=0;
00115
00116
00117 virtual void apply(const QuadModifier *sm, DerivativeAccumulator &da)=0;
00118
00119
00120 virtual double evaluate(const QuadScore *s,
00121 DerivativeAccumulator *da) const=0;
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131 QuadContainer* get_removed_quads_container() const {
00132 IMP_USAGE_CHECK(added_, "The containers returned by "
00133 << " get_added_quads_container() do not "
00134 << " track their own added and removed contents.");
00135 QuadContainer *ret= dynamic_cast<QuadContainer*>(removed_.get());
00136 IMP_INTERNAL_CHECK(ret, "Cannot cast object " << removed_->get_name()
00137 << " to a QuadContainer.");
00138 return ret;
00139 }
00140 QuadContainer* get_added_quads_container() const {
00141 IMP_USAGE_CHECK(added_, "The containers returned by "
00142 << " get_added_quads_container() do not "
00143 << " track their own added and removed contents.");
00144 QuadContainer *ret= dynamic_cast<QuadContainer*>(added_.get());
00145 IMP_INTERNAL_CHECK(ret, "Cannot cast object " << added_->get_name()
00146 << " to a QuadContainer.");
00147 return ret;
00148 }
00149
00150
00151
00152 virtual double evaluate_change(const QuadScore *o,
00153 DerivativeAccumulator *da) const = 0;
00154
00155
00156
00157
00158
00159 virtual double evaluate_prechange(const QuadScore *o,
00160 DerivativeAccumulator *da) const = 0;
00161
00162
00163 #ifndef IMP_DOXYGEN
00164 ParticleQuad get(unsigned int i) const {return get_particle_quad(i);}
00165 bool get_contains(const ParticleQuad& v) const {
00166 return get_contains_particle_quad(v);
00167 }
00168 unsigned int get_number() const {return get_number_of_particle_quads();}
00169 #endif
00170
00171 IMP_REF_COUNTED_NONTRIVIAL_DESTRUCTOR(QuadContainer);
00172 };
00173
00174 IMP_OUTPUT_OPERATOR(QuadContainer);
00175
00176
00177 IMP_OBJECTS(QuadContainer);
00178
00179
00180
00181
00182
00183 IMP_END_NAMESPACE
00184
00185 #endif