IMP  2.0.0
The Integrative Modeling Platform
pair_predicates.h
Go to the documentation of this file.
1 /**
2  * \file IMP/core/pair_predicates.h
3  * \brief Define some predicates.
4  *
5  * WARNING This file was generated from pair_predicates.h
6  * in /tmp/nightly-build-5687/imp-2.0.0/tools/build/container_templates/core
7  * by tools/maintenance/setup_containers.py.
8  *
9  * Copyright 2007-2013 IMP Inventors. All rights reserved.
10  */
11 
12 #ifndef IMPCORE_PAIR_PREDICATES_H
13 #define IMPCORE_PAIR_PREDICATES_H
14 
15 #include <IMP/core/core_config.h>
16 #include <IMP/PairPredicate.h>
17 #include <IMP/pair_macros.h>
18 #include <boost/random.hpp>
19 #include "internal/container_helpers.h"
20 
21 IMPCORE_BEGIN_NAMESPACE
22 
23 /** Always return a constant value.
24  */
25 class IMPCOREEXPORT ConstantPairPredicate: public PairPredicate {
26  int v_;
27 public:
29  std::string name="ConstPairPredicate%1%");
31  IMP_UNUSED(m); IMP_UNUSED(pi);
32  return v_;
33  }, {
34  IMP_UNUSED(m); IMP_UNUSED(pi);
35  return ModelObjectsTemp();
36  });
37 };
38 
39 /** Return a unique predicate value for each unordered set of ParticleTypes
40  (see Typed).
41 */
42 
43 class IMPCOREEXPORT UnorderedTypePairPredicate: public PairPredicate {
44 public:
45  UnorderedTypePairPredicate(std::string name
46  ="UnorderedTypePairPredicate%1%");
48  return internal::get_type_hash(m, pi);
49  }, {
50  ModelObjectsTemp ret;
51  ret+= IMP::get_particles(m, pi);
52  return ret;
53  });
54 };
55 
56 /** Return a unique predicate value for each ordered pair of
57  ParticleTypes (see Typed).
58 */
59 class IMPCOREEXPORT OrderedTypePairPredicate: public PairPredicate {
60 public:
61  OrderedTypePairPredicate(std::string name
62  ="OrderedTypePairPredicate%1%");
64  return internal::get_ordered_type_hash(m, pi);
65  },
66  {
67  ModelObjectsTemp ret;
68  ret+= IMP::get_particles(m, pi);
69  return ret;
70  });
71  int get_value(const core::ParticleTypes& types) {
72  return internal::get_ordered_type_hash(types);
73  }
74 };
75 
76 /** Return true if all members of the tuple are the same. */
77 class IMPCOREEXPORT AllSamePairPredicate: public PairPredicate {
78 public:
79  AllSamePairPredicate(std::string name
80  ="AllSamePairPredicate%1%");
82  return internal::get_all_same(m, pi);
83  },{
84  IMP_UNUSED(m); IMP_UNUSED(pi);
85  return ModelObjectsTemp();
86  });
87 };
88 
89 /** Return true with a fixed probability. */
90 class IMPCOREEXPORT CoinFlipPairPredicate: public PairPredicate {
91  double p_;
92  mutable boost::uniform_real<double> rng_;
93 public:
94  CoinFlipPairPredicate(double p, std::string name
95  ="CoinFlipPairPredicate%1%");
97  IMP_UNUSED(m);
98  IMP_UNUSED(pi);
99  if (rng_(base::random_number_generator)<p_) return 1;
100  else return 0;
101  },{
102  IMP_UNUSED(m); IMP_UNUSED(pi);
103  return ModelObjectsTemp();
104  });
105 };
106 
107 
108 IMPCORE_END_NAMESPACE
109 
110 #endif /* IMPCORE_PAIR_PREDICATES_H */