IMP  2.0.1
The Integrative Modeling Platform
container/generic.h
Go to the documentation of this file.
1 /**
2  * \file IMP/container/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 IMPCONTAINER_GENERIC_H
10 #define IMPCONTAINER_GENERIC_H
11 
12 #include <IMP/container/container_config.h>
13 #include <IMP/internal/ContainerRestraint.h>
14 #include <IMP/internal/ContainerConstraint.h>
15 #include "InContainerPairFilter.h"
16 
17 IMPCONTAINER_BEGIN_NAMESPACE
18 
19 
20 /** Create a restraint from a score and a container. The resulting restraint
21  is, in general, more efficient than creating an, eg, PairsRestraint.
22 */
23 template <class Score, class Container>
24 inline Restraint *create_restraint(Score *s, Container*c,
25  std::string name=std::string()) {
26  return IMP::internal::create_container_restraint(s, c, name);
27 }
28 
29 
30 
31 /** Helper to create a ContainerConstraint.
32  */
33 template <class Container, class Before, class After>
34 inline Constraint *create_constraint(Before *b, After *a, Container *c,
35  std::string name=std::string()) {
36  return IMP::internal::create_container_constraint(c, b, a, name);
37 }
38 
39 
40 /** Create a filter that returns whether the pair, or its flip is
41  contained in the passed container.
42 
43  \note This is different than the InContainerPairFilter.*/
44 template <class Container>
45 inline PairPredicate*
46 create_in_container_filter(Container *c, std::string name=std::string()) {
47  return new InContainerPairFilter(c, name);
48 }
49 
50 
51 
52 
53 IMPCONTAINER_END_NAMESPACE
54 
55 
56 #endif /* IMPCONTAINER_GENERIC_H */