IMP  2.1.0
The Integrative Modeling Platform
kernel/RestraintSet.h
Go to the documentation of this file.
1 /**
2  * \file IMP/kernel/RestraintSet.h
3  * \brief Used to hold a set of related restraints.
4  *
5  * Copyright 2007-2013 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPKERNEL_RESTRAINT_SET_H
10 #define IMPKERNEL_RESTRAINT_SET_H
11 
12 #include <IMP/kernel/kernel_config.h>
13 #include "declare_RestraintSet.h"
14 
15 IMPKERNEL_BEGIN_NAMESPACE
16 
17 #if !defined(IMP_DOXYGEN) && !defined(SWIG)
18 namespace {
19 template <class It>
20 void get_restraints_internal(It b, It e, RestraintsTemp &ret) {
21  for (It c = b; c != e; ++c) {
22  Restraint *cur = *c;
23  RestraintSet *rs = dynamic_cast<RestraintSet *>(cur);
24  if (rs) {
25  get_restraints_internal(rs->restraints_begin(), rs->restraints_end(),
26  ret);
27  } else {
28  ret.push_back(cur);
29  }
30  }
31 }
32 }
33 #endif
34 
35 template <class It>
36 inline RestraintsTemp get_restraints(It b, It e) {
37  RestraintsTemp ret;
38  get_restraints_internal(b, e, ret);
39  std::sort(ret.begin(), ret.end());
40  ret.erase(std::unique(ret.begin(), ret.end()), ret.end());
41  return ret;
42 }
43 
44 IMPKERNEL_END_NAMESPACE
45 
46 #endif /* IMPKERNEL_RESTRAINT_SET_H */
Used to hold a set of related restraints.
IMP::base::Vector< IMP::base::WeakPointer< Restraint > > RestraintsTemp
kernel::RestraintsTemp get_restraints(const Subset &s, const ParticleStatesTable *pst, const DependencyGraph &dg, kernel::RestraintSet *rs)
IMP::kernel::Restraint Restraint
IMP::kernel::RestraintSet RestraintSet