IMP  2.0.1
The Integrative Modeling Platform
triplet_predicates.h
Go to the documentation of this file.
1 /**
2  * \file IMP/core/triplet_predicates.h
3  * \brief Define some predicates.
4  *
5  * WARNING This file was generated from triplet_predicates.h
6  * in /tmp/nightly-build-36540/imp-2.0.1/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_TRIPLET_PREDICATES_H
13 #define IMPCORE_TRIPLET_PREDICATES_H
14 
15 #include <IMP/core/core_config.h>
16 #include <IMP/TripletPredicate.h>
17 #include <IMP/triplet_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 ConstantTripletPredicate: public TripletPredicate {
26  int v_;
27 public:
29  std::string name="ConstTripletPredicate%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 UnorderedTypeTripletPredicate: public TripletPredicate {
44 public:
45  UnorderedTypeTripletPredicate(std::string name
46  ="UnorderedTypeTripletPredicate%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 triplet of
57  ParticleTypes (see Typed).
58 */
59 class IMPCOREEXPORT OrderedTypeTripletPredicate: public TripletPredicate {
60 public:
61  OrderedTypeTripletPredicate(std::string name
62  ="OrderedTypeTripletPredicate%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 AllSameTripletPredicate: public TripletPredicate {
78 public:
79  AllSameTripletPredicate(std::string name
80  ="AllSameTripletPredicate%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 CoinFlipTripletPredicate: public TripletPredicate {
91  double p_;
92  mutable boost::uniform_real<double> rng_;
93 public:
94  CoinFlipTripletPredicate(double p, std::string name
95  ="CoinFlipTripletPredicate%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_TRIPLET_PREDICATES_H */