IMP  2.1.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-2013 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/TupleRestraint.h"
15 #include "internal/TupleConstraint.h"
16 
17 IMPKERNEL_BEGIN_NAMESPACE
18 
19 /** Create a ScoringFunction on a single restraints. This can be faster than
20  using a RestraintsScoringFunction.*/
21 template <class RestraintType>
22 inline ScoringFunction *create_scoring_function(RestraintType *rs,
23  double weight = 1.0,
24  double max = NO_MAX,
25  std::string name =
26  std::string()) {
27  return internal::create_scoring_function(rs, weight, max, name);
28 }
29 
30 /** When programming in C++, you can use generic restraint instead
31  of a SingletonRestraint, PairRestraint, etc. The result is
32  somewhat faster (20% or so).
33 */
34 template <class Score>
35 inline Restraint *create_restraint(Score *s, const typename Score::Argument &t,
36  std::string name = std::string()) {
37  return internal::create_tuple_restraint(
38  s, IMP::kernel::internal::get_model(t),
40 }
41 
42 template <class Score>
43 inline Restraint *create_restraint(const Score *s,
44  const typename Score::Argument &t,
45  std::string name = std::string()) {
46  return internal::create_tuple_restraint(
47  const_cast<Score *>(s), IMP::kernel::internal::get_model(t),
49 }
50 
51 /** When programming in C++, you can use generic constraint instead
52  of a SingletonConstraint, PairConstraint, etc. The result is
53  somewhat faster (20% or so).
54 */
55 template <class Before, class After>
56 inline Constraint *create_constraint(Before *b, After *a,
57  const typename Before::Argument &t,
58  std::string name = std::string()) {
59  return internal::create_tuple_constraint(b, a, t, name);
60 }
61 
62 IMPKERNEL_END_NAMESPACE
63 
64 #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)
ScoringFunction * create_scoring_function(RestraintType *rs, double weight=1.0, double max=NO_MAX, std::string name=std::string())
A restraint is a term in an IMP ScoringFunction.
Implement a constraint on the Model.
Constraint * create_constraint(Before *b, After *a, Container *c, std::string name=std::string())
kernel::Restraint * create_restraint(Score *s, Container *c, std::string name=std::string())