IMP  2.0.0
The Integrative Modeling Platform
kernel/ModelObject.h
Go to the documentation of this file.
1 /**
2  * \file IMP/kernel/ModelObject.h \brief Single variable function.
3  *
4  * Copyright 2007-2013 IMP Inventors. All rights reserved.
5  */
6 
7 #ifndef IMPKERNEL_MODEL_OBJECT_H
8 #define IMPKERNEL_MODEL_OBJECT_H
9 
10 #include <IMP/kernel/kernel_config.h>
11 #include "base_types.h"
12 #include "dependency_graph.h"
14 #include <IMP/base/tracking.h>
16 
17 IMPKERNEL_BEGIN_NAMESPACE
18 
19 /** These objects are associated with a particular Model
20  and have a callback that is called whenever the dependencies
21  in the model change. This allows them to update internal state
22  when that occurs.
23  */
24 class IMPKERNELEXPORT ModelObject :
25 #if defined(IMP_DOXYGEN) || defined(SWIG)
26  public base::Object
27 #else
28  public base::TrackedObject<ModelObject, Model>
29 #endif
30 {
32 
33  friend class Model;
34 public:
35  ModelObject(Model *m, std::string name);
36 #ifndef IMP_DOXYGEN
37  ModelObject(std::string name);
38  /** Virtual so that RestraintSet can override it.*/
39  virtual void set_model(Model *m);
40  bool get_is_part_of_model() const {
41  return Tracked::get_is_tracked();
42  }
43 #endif
44  Model *get_model() const {
45  return Tracked::get_tracker();
46  }
47  /** Get any Particle, Container or other ModelObjects read by
48  this during evaluation. If you read everything in a container,
49  you can just return that container. */
50  ModelObjectsTemp get_inputs() const;
51  /** Get any Particle, Container or other ModelObjects changed by
52  this during evaluation. This is only useful for ScoreStates,
53  at the moment.*/
54  ModelObjectsTemp get_outputs() const;
55  /** Get the interacting sets induce by this ModelObject. That is,
56  the particles in each ModelObjectsTemp in the list have some
57  sort of computed relation with one another and none with
58  disjoint other sets in the list.*/
59  ModelObjectsTemps get_interactions() const;
60 protected:
61 #ifndef SWIG
62  // too hard to make swig handle this
63  /** This method is called when the dependencies in the model have changed
64  and model evaluate is called (or Model::ensure_dependencies()).
65  The object can use this to update anything
66  that is needed for efficient computation.*/
67  virtual void do_update_dependencies(){
68  // swig is being braindead and not matching this function successfully
69  }
70 #endif
71  /** The model calls this method when dependencies have changed. It in
72  turn calls do_update_dependencies().*/
73  virtual void update_dependencies();
74  /** Override if this reads other objects during evaluate.*/
75  virtual ModelObjectsTemp do_get_inputs() const =0;
76  /** Override if this writes other objects during evaluate.*/
77  virtual ModelObjectsTemp do_get_outputs() const =0;
78  /** Override if this if not all inputs interact with all outputs. This is
79  rarely something you want to do.*/
80  virtual ModelObjectsTemps do_get_interactions() const;
81 
83 };
84 
85 IMPKERNEL_END_NAMESPACE
86 
87 #endif /* IMPKERNEL_MODEL_OBJECT_H */