IMP  2.1.1
The Integrative Modeling Platform
DistributeSingletonsScoreState.h
Go to the documentation of this file.
1 /**
2  * \file IMP/container/DistributeSingletonsScoreState.h
3  * \brief Apply a SingletonScore to each Singleton in a list.
4  *
5  * WARNING This file was generated from DistributeSingletonsScoreState.h
6  * in /tmp/nightly-build-61576/imp-2.1.1/tools/build/container_templates/container
7  * by tools/maintenance/setup_containers.py.
8  *
9  * Copyright 2007-2013 IMP Inventors. All rights reserved.
10  *
11  */
12 
13 #ifndef IMPCONTAINER_DISTRIBUTE_SINGLETONS_SCORE_STATE_H
14 #define IMPCONTAINER_DISTRIBUTE_SINGLETONS_SCORE_STATE_H
15 
16 #include <IMP/container/container_config.h>
17 
19 #include <IMP/SingletonPredicate.h>
20 #include <IMP/SingletonContainer.h>
21 #include <IMP/base/Vector.h>
22 #include <IMP/singleton_macros.h>
23 #include <IMP/score_state_macros.h>
24 #include <boost/tuple/tuple.hpp>
25 
26 #include <iostream>
27 
28 IMPCONTAINER_BEGIN_NAMESPACE
29 
30 //! Distribute contents of one container into several based on predicates
31 /** This ScoreState takes a list of predicates and values. For
32  each tuple in the input container, it is placed in a given output container
33  if the predicate, when applied, has the passed value.
34 
35  \note The output containers contents are not necessarily disjoint.
36 */
37 class IMPCONTAINEREXPORT DistributeSingletonsScoreState : public ScoreState {
39  typedef boost::tuple<base::Pointer<DynamicListSingletonContainer>,
41  base::Vector<Data> data_;
42  mutable int input_version_;
43  void update_lists_if_necessary() const;
44 
45  public:
46  DistributeSingletonsScoreState(SingletonContainerAdaptor input,
47  std::string name =
48  "DistributeSingletonsScoreState %1%");
49 
50  /** A given tuple will go into the returned container if \c predicate
51  returns \c value when applied to it.*/
53  int value) {
55  (input_, predicate->get_name() + " output"));
56  data_.push_back(Data(c, predicate, value));
57  return c;
58  }
59  virtual void do_before_evaluate() IMP_OVERRIDE;
60  virtual void do_after_evaluate(DerivativeAccumulator *da) IMP_OVERRIDE;
61  virtual kernel::ModelObjectsTemp do_get_inputs() const IMP_OVERRIDE;
62  virtual kernel::ModelObjectsTemp do_get_outputs() const IMP_OVERRIDE;
64 };
65 
66 IMPCONTAINER_END_NAMESPACE
67 
68 #endif /* IMPCONTAINER_DISTRIBUTE_SINGLETONS_SCORE_STATE_H */
Distribute contents of one container into several based on predicates.
Class for adding derivatives from restraints to the model.
IMP::base::Vector< IMP::base::WeakPointer< kernel::ModelObject > > ModelObjectsTemp
Import IMP/kernel/SingletonContainer.h in the namespace.
A smart pointer to a ref-counted Object that is a class memeber.
Definition: base/Pointer.h:147
Import IMP/kernel/singleton_macros.h in the namespace.
#define IMP_NEW(Typename, varname, args)
Declare a ref counted pointer to a new object.
ScoreStates maintian invariants in the Model.
Import IMP/kernel/SingletonPredicate.h in the namespace.
A class for storing lists of IMP items.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Abstract predicate function.
Store a list of ParticlesTemp.
Import IMP/kernel/score_state_macros.h in the namespace.
DynamicListSingletonContainer * add_predicate(SingletonPredicate *predicate, int value)