IMP  2.4.0
The Integrative Modeling Platform
kernel/generic.h
Go to the documentation of this file.
1 /**
2  * \file IMP/kernel/generic.h \brief Various important functionality
3  * for implementing decorators.
4  *
5  * Copyright 2007-2015 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPKERNEL_GENERIC_H
10 #define IMPKERNEL_GENERIC_H
11 
12 #include <IMP/kernel/kernel_config.h>
13 #include "internal/scoring_functions.h"
14 #include "internal/ContainerRestraint.h"
15 #include "internal/TupleRestraint.h"
16 #include "internal/TupleConstraint.h"
17 
18 IMPKERNEL_BEGIN_NAMESPACE
19 
20 /** Create a ScoringFunction on a single restraints. This can be faster than
21  using a RestraintsScoringFunction.*/
22 template <class RestraintType>
23 inline ScoringFunction *create_scoring_function(RestraintType *rs,
24  double weight = 1.0,
25  double max = NO_MAX,
26  std::string name =
27  std::string()) {
28  return internal::create_scoring_function(rs, weight, max, name);
29 }
30 
31 /** When programming in C++, you can use generic restraint instead
32  of a SingletonRestraint, PairRestraint, etc. The result is
33  somewhat faster (20% or so).
34 */
35 template <class Score>
36 inline Restraint *create_restraint(Score *s, const typename Score::Argument &t,
37  std::string name = std::string()) {
38  return internal::create_tuple_restraint(
39  s, IMP::kernel::internal::get_model(t),
41 }
42 
43 template <class Score>
44 inline Restraint *create_restraint(const Score *s,
45  const typename Score::Argument &t,
46  std::string name = std::string()) {
47  return internal::create_tuple_restraint(
48  const_cast<Score *>(s), IMP::kernel::internal::get_model(t),
50 }
51 
52 template <class Score, class Container>
53 inline Restraint *create_restraint(const Score *s, Container *t,
54  std::string name = std::string()) {
55  return internal::create_container_restraint(const_cast<Score *>(s), t, name);
56 }
57 
58 /** When programming in C++, you can use generic constraint instead
59  of a SingletonConstraint, PairConstraint, etc. The result is
60  somewhat faster (20% or so).
61 */
62 template <class Before, class After>
63 inline Constraint *create_constraint(Before *b, After *a,
64  const typename Before::Argument &t,
65  std::string name = std::string()) {
66  return internal::create_tuple_constraint(b, a, t, name);
67 }
68 
69 IMPKERNEL_END_NAMESPACE
70 
71 #endif /* IMPKERNEL_GENERIC_H */
const double NO_MAX
Use this value when you want to turn off maximum for restraint evaluation.
Ints get_index(const kernel::ParticlesTemp &particles, const Subset &subset, const Subsets &excluded)
Represents a scoring function on the model.
ScoringFunction * create_scoring_function(RestraintType *rs, double weight=1.0, double max=NO_MAX, std::string name=std::string())
IMP::kernel::Container Container
A restraint is a term in an IMP ScoringFunction.
Constraint * create_constraint(Before *b, After *a, const typename Before::Argument &t, std::string name=std::string())
Implement a constraint on the Model.
IMP::kernel::Restraint Restraint