00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef IMP_PAIR_MODIFIER_H
00011 #define IMP_PAIR_MODIFIER_H
00012
00013 #include "kernel_config.h"
00014 #include "internal/container_helpers.h"
00015 #include "DerivativeAccumulator.h"
00016 #include "base_types.h"
00017 #include "VectorOfRefCounted.h"
00018
00019 IMP_BEGIN_NAMESPACE
00020
00021 class Particle;
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 class IMPEXPORT PairModifier : public Object
00036 {
00037 public:
00038 PairModifier(std::string name="PairModifier %1%");
00039
00040
00041 virtual void apply(const ParticlePair& vt,
00042 DerivativeAccumulator &da) const {
00043 IMP_FAILURE("This PairModifier must be called without a"
00044 << " DerivativeAccumulator.");
00045 }
00046
00047
00048 virtual void apply(const ParticlePair& vt) const {
00049 IMP_FAILURE("This PairModifier must be called with a"
00050 << " DerivativeAccumulator.");
00051 }
00052
00053
00054 virtual void apply(const ParticlePairsTemp &o) const {
00055 IMP_FAILURE("This PairModifier must be called with a"
00056 << " DerivativeAccumulator.");
00057 }
00058
00059
00060 virtual void apply(const ParticlePairsTemp &o,
00061 DerivativeAccumulator &da) const {
00062 IMP_FAILURE("This PairModifier must be called without a"
00063 << " DerivativeAccumulator.");
00064 }
00065
00066
00067
00068 virtual ParticlesList
00069 get_interacting_particles(const ParticlePair& vt) const =0;
00070
00071
00072 virtual ParticlesTemp
00073 get_input_particles(const ParticlePair& vt) const =0;
00074
00075 virtual ParticlesTemp
00076 get_output_particles(const ParticlePair& vt) const =0;
00077
00078
00079 virtual ContainersTemp
00080 get_input_containers(const ParticlePair& vt) const =0;
00081
00082
00083 virtual ContainersTemp
00084 get_output_containers(const ParticlePair& vt) const =0;
00085 };
00086
00087 IMP_OUTPUT_OPERATOR(PairModifier);
00088
00089
00090 IMP_OBJECTS(PairModifier);
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109 class PairFunctor {
00110 Pointer<const PairModifier> f_;
00111 DerivativeAccumulator *da_;
00112 public:
00113
00114 PairFunctor(const PairModifier *f): f_(f), da_(NULL){}
00115 PairFunctor(const PairModifier *f,
00116 DerivativeAccumulator *da): f_(f), da_(da){
00117 IMP_USAGE_CHECK(da_,
00118 "The passed derivative accumulator should not be null.");
00119 }
00120 void operator()( ParticlePair p) const {
00121 if (da_) {
00122 f_->apply(p, *da_);
00123 } else {
00124 f_->apply(p);
00125 }
00126 }
00127 };
00128
00129
00130
00131 IMP_END_NAMESPACE
00132
00133 #endif