IMP  2.0.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 
20 
21 /** Create a ScoringFunction on a single restraints. This can be faster than
22  using a RestraintsScoringFunction.*/
23 template <class RestraintType>
24 inline ScoringFunction* create_scoring_function(RestraintType* rs,
25  double weight=1.0,
26  double max=NO_MAX,
27  std::string name
28  = std::string()) {
29  return internal::create_scoring_function(rs, weight, max, name);
30 }
31 
32 /** When programming in C++, you can use generic restraint instead
33  of a SingletonRestraint, PairRestraint, etc. The result is
34  somewhat faster (20% or so).
35 */
36 template <class Score>
37 inline Restraint* create_restraint(Score *s,
38  const typename Score::Argument &t,
39  std::string name= std::string()) {
40  return internal::create_tuple_restraint(s,
41  IMP::kernel::internal::get_model(t),
43  name);
44 }
45 
46 template <class Score>
47 inline Restraint* create_restraint(const Score *s,
48  const typename Score::Argument &t,
49  std::string name= std::string()) {
50  return internal::create_tuple_restraint(const_cast<Score*>(s),
51  IMP::kernel::internal::get_model(t),
53  name);
54 }
55 
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 
70 IMPKERNEL_END_NAMESPACE
71 
72 #endif /* IMPKERNEL_GENERIC_H */