IMP  2.3.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-29065/imp-2.3.1/tools/build/container_templates/container
7  * by tools/build/make_containers.py.
8  *
9  * Copyright 2007-2014 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 <boost/tuple/tuple.hpp>
24 
25 #include <iostream>
26 
27 IMPCONTAINER_BEGIN_NAMESPACE
28 
29 //! Distribute contents of one container into several based on predicates
30 /** This ScoreState takes a list of predicates and values. For
31  each tuple in the input container, it is placed in a given output container
32  if the predicate, when applied, has the passed value.
33 
34  \note The output containers contents are not necessarily disjoint.
35 */
36 class IMPCONTAINEREXPORT DistributeSingletonsScoreState : public ScoreState {
38  typedef boost::tuple<base::Pointer<DynamicListSingletonContainer>,
40  base::Vector<Data> data_;
41  mutable std::size_t input_version_;
42  void update_lists_if_necessary() const;
43 
44  public:
45  DistributeSingletonsScoreState(SingletonContainerAdaptor input,
46  std::string name =
47  "DistributeSingletonsScoreState %1%");
48 
49  /** A given tuple will go into the returned container if \c predicate
50  returns \c value when applied to it.*/
52  int value) {
54  (input_, predicate->get_name() + " output"));
55  data_.push_back(Data(c, predicate, value));
56  return c;
57  }
58  virtual void do_before_evaluate() IMP_OVERRIDE;
59  virtual void do_after_evaluate(DerivativeAccumulator *da) IMP_OVERRIDE;
60  virtual kernel::ModelObjectsTemp do_get_inputs() const IMP_OVERRIDE;
61  virtual kernel::ModelObjectsTemp do_get_outputs() const IMP_OVERRIDE;
63 };
64 
65 IMPCONTAINER_END_NAMESPACE
66 
67 #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 member.
Definition: Pointer.h:147
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Definition: object_macros.h:25
Import IMP/kernel/singleton_macros.h in the namespace.
ScoreStates maintain invariants in the Model.
#define IMP_NEW(Typename, varname, args)
Declare a ref counted pointer to a new object.
Definition: object_macros.h:72
Import IMP/kernel/SingletonPredicate.h in the namespace.
A class for storing lists of IMP items.
Abstract predicate function.
Store a list of kernel::ParticlesTemp.
DynamicListSingletonContainer * add_predicate(SingletonPredicate *predicate, int value)
#define IMP_OVERRIDE
Cause a compile error if this method does not override a parent method.