00001
00002
00003
00004
00005
00006
00007 #ifndef IMP_REFINER_H
00008 #define IMP_REFINER_H
00009
00010 #include "kernel_config.h"
00011 #include "base_types.h"
00012 #include "Particle.h"
00013 #include "VersionInfo.h"
00014 #include "RefCounted.h"
00015 #include "internal/IndexingIterator.h"
00016
00017 IMP_BEGIN_NAMESPACE
00018
00019 class Particle;
00020 class DerivativeAccumulator;
00021
00022
00023
00024
00025
00026
00027
00028 class IMPEXPORT Refiner : public Object
00029 {
00030 struct Accessor;
00031 public:
00032 Refiner(std::string name="Refiner %1%");
00033
00034
00035
00036 virtual bool get_can_refine(Particle *a) const {return false;}
00037
00038
00039
00040
00041 virtual const ParticlesTemp get_refined(Particle *a) const=0;
00042
00043
00044
00045 virtual Particle* get_refined(Particle *a, unsigned int i) const =0;
00046
00047
00048
00049 virtual unsigned int get_number_of_refined(Particle *a) const =0;
00050
00051
00052
00053
00054
00055
00056
00057 typedef internal::IndexingIterator<Accessor> RefinedIterator;
00058 RefinedIterator refined_begin(Particle *a) const;
00059 RefinedIterator refined_end(Particle *a) const;
00060
00061
00062
00063
00064 virtual void show(std::ostream &out=std::cout) const {
00065 out << "Refiner base" << std::endl;
00066 };
00067
00068
00069 virtual IMP::VersionInfo get_version_info() const =0;
00070
00071
00072 virtual ParticlesTemp get_input_particles(Particle *) const=0;
00073
00074
00075 virtual ContainersTemp get_input_containers(Particle *) const=0;
00076
00077 IMP_REF_COUNTED_DESTRUCTOR(Refiner);
00078 };
00079
00080 typedef VectorOfRefCounted<Refiner*> Refiners;
00081
00082 IMP_OUTPUT_OPERATOR(Refiner);
00083
00084 #ifndef SWIG
00085 struct Refiner::Accessor {
00086
00087 Particle* p_;
00088 const Refiner* r_;
00089 Accessor(Particle *p, const Refiner *r): p_(p), r_(r) {}
00090 Accessor(){}
00091 typedef Particle *result_type;
00092 Particle *operator()(unsigned int i) const {
00093 return r_->get_refined(p_, i);
00094 }
00095 bool operator==(const Accessor &o) const {
00096 return p_==o.p_ && r_==o.r_;
00097 }
00098 };
00099 #endif
00100
00101 inline Refiner::RefinedIterator Refiner::refined_begin(Particle *a) const {
00102 return RefinedIterator(Accessor(a, this), 0);
00103 }
00104 inline Refiner::RefinedIterator Refiner::refined_end(Particle *a) const {
00105 return RefinedIterator(Accessor(a, this), get_number_of_refined(a));
00106 }
00107
00108 IMP_END_NAMESPACE
00109
00110 #endif