8 #ifndef IMPCONTAINER_CONSECUTIVE_PAIR_CONTAINER_H
9 #define IMPCONTAINER_CONSECUTIVE_PAIR_CONTAINER_H
11 #include <IMP/container/container_config.h>
17 #include <boost/unordered_map.hpp>
20 IMPCONTAINER_BEGIN_NAMESPACE
40 if (!get_model()->get_has_attribute(key_, p[0]))
return false;
41 int ia = get_model()->get_attribute(key_, p[0]);
42 if (!get_model()->get_has_attribute(key_, p[1]))
return false;
43 int ib = get_model()->get_attribute(key_, p[1]);
44 return std::abs(ia - ib) == 1;
48 virtual std::size_t do_get_contents_hash()
const IMP_OVERRIDE {
return 0; }
54 for (
unsigned int i = 1; i < ps_.size(); ++i) {
55 f->apply_index(get_model(),
61 std::string name =
"ConsecutivePairContainer%1%");
87 return cpc_->get_contains(pip);
108 static IntKey get_exclusive_key() {
109 static IntKey k(
"exclusive consecutive numbering");
112 static ObjectKey get_exclusive_object_key() {
113 static ObjectKey k(
"exclusive consecutive container");
116 static bool get_contains(
Model *m,
119 ExclusiveConsecutivePairContainer::get_exclusive_object_key();
122 if ( !has_eok_0 || !has_eok_1 )
127 IntKey k = ExclusiveConsecutivePairContainer::get_exclusive_key();
130 return std::abs(ia - ib) == 1;
135 virtual std::size_t do_get_contents_hash()
const IMP_OVERRIDE {
return 0; }
149 for (
unsigned int i = 1; i < ps_.size(); ++i) {
150 f->apply_index(get_model(),
157 "ExclusiveConsecutivePairContainer%1%");
172 : PairPredicate(
"ExclusiveConsecutivePairFilter %1%") {}
177 return ExclusiveConsecutivePairContainer::get_contains(m, pip);
189 IMPCONTAINER_END_NAMESPACE
A shared container for Pairs.
virtual ModelObjectsTemp do_get_inputs(Model *m, const ParticleIndexes &pi) const
Overload this method to specify the inputs.
Macros for various classes.
A container for Singletons.
void apply_generic(F *f) const
apply to each item in container
void apply_generic(F *f) const
apply to each item in container
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
A container which contains all consecutive particle pairs from an input list.
ParticlesTemp get_particles(Model *m, const ParticleIndexes &ps)
Get the particles from a list of indexes.
#define IMP_PAIR_CONTAINER_METHODS(Name)
Class for storing model, its restraints, constraints, and particles.
virtual void do_destroy()
A smart pointer to a ref-counted Object that is a class member.
Store a list of ParticleIndexPairs.
virtual int get_value_index(Model *m, const ParticleIndexPair &pip) const
Compute the predicate and the derivative if needed.
#define IMP_OBJECTS(Name, PluralName)
Define the types for storing lists of object pointers.
Abstract predicate function.
virtual int get_value_index(Model *, const ParticleIndexPair &pip) const
Compute the predicate and the derivative if needed.
virtual ParticleIndexPairs get_indexes() const =0
bool get_has_attribute(TypeKey attribute_key, ParticleIndex particle) const
return true if particle has attribute with the specified key
virtual ModelObjectsTemp do_get_inputs(Model *m, const ParticleIndexes &pi) const
Overload this method to specify the inputs.
Type get_attribute(TypeKey attribute_key, ParticleIndex particle)
get the value of the particle attribute with the specified key
#define IMP_OVERRIDE
Cause a compile error if this method does not override a parent method.
#define IMP_PAIR_PREDICATE_METHODS(Name)
Define extra the functions needed for a PairPredicate.
Compile-time generic restraint and constraint support.