IMP  2.0.1
The Integrative Modeling Platform
singleton_predicates.h
Go to the documentation of this file.
1 /**
2  * \file IMP/core/singleton_predicates.h
3  * \brief Define some predicates.
4  *
5  * WARNING This file was generated from singleton_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_SINGLETON_PREDICATES_H
13 #define IMPCORE_SINGLETON_PREDICATES_H
14 
15 #include <IMP/core/core_config.h>
16 #include <IMP/SingletonPredicate.h>
17 #include <IMP/singleton_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 ConstantSingletonPredicate: public SingletonPredicate {
26  int v_;
27 public:
29  std::string name="ConstSingletonPredicate%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 
44 public:
45  UnorderedTypeSingletonPredicate(std::string name
46  ="UnorderedTypeSingletonPredicate%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 singleton of
57  ParticleTypes (see Typed).
58 */
60 public:
61  OrderedTypeSingletonPredicate(std::string name
62  ="OrderedTypeSingletonPredicate%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 AllSameSingletonPredicate: public SingletonPredicate {
78 public:
79  AllSameSingletonPredicate(std::string name
80  ="AllSameSingletonPredicate%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 CoinFlipSingletonPredicate: public SingletonPredicate {
91  double p_;
92  mutable boost::uniform_real<double> rng_;
93 public:
94  CoinFlipSingletonPredicate(double p, std::string name
95  ="CoinFlipSingletonPredicate%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_SINGLETON_PREDICATES_H */