IMP  2.0.0
The Integrative Modeling Platform
quad_predicates.h
Go to the documentation of this file.
1 /**
2  * \file IMP/core/quad_predicates.h
3  * \brief Define some predicates.
4  *
5  * WARNING This file was generated from quad_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_QUAD_PREDICATES_H
13 #define IMPCORE_QUAD_PREDICATES_H
14 
15 #include <IMP/core/core_config.h>
16 #include <IMP/QuadPredicate.h>
17 #include <IMP/quad_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 ConstantQuadPredicate: public QuadPredicate {
26  int v_;
27 public:
29  std::string name="ConstQuadPredicate%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 UnorderedTypeQuadPredicate: public QuadPredicate {
44 public:
45  UnorderedTypeQuadPredicate(std::string name
46  ="UnorderedTypeQuadPredicate%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 quad of
57  ParticleTypes (see Typed).
58 */
59 class IMPCOREEXPORT OrderedTypeQuadPredicate: public QuadPredicate {
60 public:
61  OrderedTypeQuadPredicate(std::string name
62  ="OrderedTypeQuadPredicate%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 AllSameQuadPredicate: public QuadPredicate {
78 public:
79  AllSameQuadPredicate(std::string name
80  ="AllSameQuadPredicate%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 CoinFlipQuadPredicate: public QuadPredicate {
91  double p_;
92  mutable boost::uniform_real<double> rng_;
93 public:
94  CoinFlipQuadPredicate(double p, std::string name
95  ="CoinFlipQuadPredicate%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_QUAD_PREDICATES_H */