IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
The Integrative Modeling Platform
PairPredicate.h
Go to the documentation of this file.
1// Autogenerated by tools/build/make_containers.py
2// from tools/build/container_templates/kernel/ClassnamePredicate.h
3// Do not edit - any changes will be lost!
4
5/**
6 * \file IMP/PairPredicate.h
7 * \brief Define PairPredicate.
8 *
9 * Copyright 2007-2022 IMP Inventors. All rights reserved.
10 */
11
12#ifndef IMPKERNEL_PAIR_PREDICATE_H
13#define IMPKERNEL_PAIR_PREDICATE_H
14
15#include <IMP/kernel_config.h>
16#include "base_types.h"
18#include "internal/container_helpers.h"
20
21IMPKERNEL_BEGIN_NAMESPACE
22
23//! Abstract predicate function
24/** A predicate is a function which returns one of a discrete set of
25 values (eg -1, 0, 1 depending on whether a value is negative, zero
26 or positive). PairPredicates will evaluate the predicate for the passed
27 particles.
28
29 Implementers should check out IMP_PAIR_PREDICATE().
30*/
31class IMPKERNELEXPORT PairPredicate : public ParticleInputs,
32 public Object {
33 public:
34 typedef ParticlePair Argument;
35 typedef ParticleIndexPair IndexArgument;
36 PairPredicate(std::string name = "PairPredicate %1%");
37
38#if !defined(IMP_DOXYGEN) && !defined(SWIG)
39 //! remove any particles in ps for which this predicate evaluates to v
40 virtual void remove_if_equal(Model *m, ParticleIndexPairs &ps,
41 int v) const;
42 //! remove any particles in ps for which this predicate does not evaluate to v
43 virtual void remove_if_not_equal(Model *m, ParticleIndexPairs &ps,
44 int v) const;
45#endif
46
47 //! Compute the predicate and the derivative if needed.
48 virtual int get_value_index(Model *m, const ParticleIndexPair& vt) const = 0;
49
50 //! Setup for a batch of calls to get_value_index_in_batch()
51 //! (could be used for improving performance - e.g. preload various
52 //! tables from model)
54
55 //! Same as get_value_index, but possibly with optimizations
56 //! for a batch of calls. Call setup_for_get_value_index_in_batch()
57 //! right before calling a batch of those.
58 virtual int get_value_index_in_batch(Model* m, const ParticleIndexPair& vt) const{
59 return get_value_index(m, vt);
60 }
61
62 //! Enable them to be use as functors
63 /** But beware of slicing.
64 */
65 int operator()(Model *m, const ParticleIndexPair& vt) const {
66 return get_value_index(m, vt);
67 }
68
69 virtual Ints get_value_index(Model *m,
70 const ParticleIndexPairs &o) const {
71 Ints ret(o.size());
72 for (unsigned int i = 0; i < o.size(); ++i) {
73 ret[i] += get_value_index(m, o[i]);
74 }
75 return ret;
76 }
77
78 IMP_REF_COUNTED_DESTRUCTOR(PairPredicate);
79};
80
81IMPKERNEL_END_NAMESPACE
82
83#endif /* IMPKERNEL_PAIR_PREDICATE_H */
Class for adding derivatives from restraints to the model.
Basic types used by IMP.
Class for storing model, its restraints, constraints, and particles.
Definition Model.h:111
Object(std::string name)
Construct an object with the given name.
int operator()(Model *m, const ParticleIndexPair &vt) const
Enable them to be use as functors.
virtual int get_value_index(Model *m, const ParticleIndexPair &vt) const =0
Compute the predicate and the derivative if needed.
virtual int get_value_index_in_batch(Model *m, const ParticleIndexPair &vt) const
virtual void setup_for_get_value_index_in_batch(Model *) const
Base class for objects that take particle arguments and read from them.
Classes used in the construction of ModelObjects.
IMP::Vector< ParticleIndexPair, std::allocator< ParticleIndexPair > > ParticleIndexPairs
Definition base_types.h:208
IMP::Vector< Int > Ints
Standard way to pass a bunch of Int values.
Definition types.h:48
Array< 2, ParticleIndex > ParticleIndexPair
An ordered pair of particles, each identified by its ParticleIndex.
Definition base_types.h:202
Array< 2, WeakPointer< Particle >, Particle * > ParticlePair
Definition base_types.h:180
#define IMP_REF_COUNTED_DESTRUCTOR(Name)
Set up destructor for a ref counted object.