IMP logo
IMP Reference Guide  2.10.0
The Integrative Modeling Platform
generic.h
Go to the documentation of this file.
1 /**
2  * \file IMP/generic.h \brief Various important functionality
3  * for implementing decorators.
4  *
5  * Copyright 2007-2018 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPKERNEL_GENERIC_H
10 #define IMPKERNEL_GENERIC_H
11 
12 #include <IMP/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::internal::get_model(t),
40  IMP::internal::get_index(t), name);
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::internal::get_model(t),
49  IMP::internal::get_index(t), name);
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.
Restraint * create_restraint(Score *s, Container *c, std::string name=std::string())
Constraint * create_constraint(Before *b, After *a, const typename Before::Argument &t, std::string name=std::string())
Definition: generic.h:63
ScoringFunction * create_scoring_function(RestraintType *rs, double weight=1.0, double max=NO_MAX, std::string name=std::string())
Definition: generic.h:23
Implement a constraint on the Model.
Definition: Constraint.h:49
Ints get_index(const ParticlesTemp &particles, const Subset &subset, const Subsets &excluded)
Represents a scoring function on the model.
A restraint is a term in an IMP ScoringFunction.
Definition: Restraint.h:54