IMP logo
IMP Reference Guide  2.13.0
The Integrative Modeling Platform
ModelObject.h
Go to the documentation of this file.
1 /**
2  * \file IMP/ModelObject.h \brief Single variable function.
3  *
4  * Copyright 2007-2020 IMP Inventors. All rights reserved.
5  */
6 
7 #ifndef IMPKERNEL_MODEL_OBJECT_H
8 #define IMPKERNEL_MODEL_OBJECT_H
9 
10 #include <IMP/kernel_config.h>
11 #include "base_types.h"
12 #include <IMP/ref_counted_macros.h>
13 #include <IMP/utility_macros.h>
14 
15 IMPKERNEL_BEGIN_NAMESPACE
16 
17 class Model;
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 : public Object {
25  friend class Model;
26  WeakPointer<Model> model_;
27 
28  // for cleanup
29  void set_model(Model *m);
30 
31  public:
32 #if !defined(IMP_DOXYGEN) && !defined(SWIG)
33  void validate_inputs() const;
34  void validate_outputs() const;
35 #endif
36 
37  ModelObject(Model *m, std::string name);
38  ~ModelObject();
39 
40  Model *get_model() const { return model_; }
41  /** get_has_dependencies() must be true. */
42  ModelObjectsTemp get_inputs() const;
43  /** get_has_dependencies() must be true. */
44  ModelObjectsTemp get_outputs() const;
45  //! Get the interacting sets induced by this ModelObject.
46  /** That is, the particles in each ModelObjectsTemp in the list have some
47  sort of computed relation with one another and none with
48  disjoint other sets in the list. */
49  ModelObjectsTemps get_interactions() const;
50 
51  //! Return whether this object has dependencies computed
52  bool get_has_dependencies() const;
53 
54  //! Either invalidate the dependencies or ensure they are correct.
55  void set_has_dependencies(bool tf);
56 
57  //! Compute the required score states.
58  void set_has_required_score_states(bool tf);
59 
60  //! Return whether score states are computed.
61  bool get_has_required_score_states() const;
62 
63  //! Get the score states that are ancestors of this in the dependency graph.
65 
66  protected:
67  // virtual void do_destroy() IMP_OVERRIDE {set_has_dependencies(false);}
68  /** Called when set_has_required_score_states() is called.*/
70  /** Get any Particle, Container or other ModelObjects read by
71  this during evaluation. If you read everything in a container,
72  you can just return that container. */
73  virtual ModelObjectsTemp do_get_inputs() const = 0;
74  /** Get any Particle, Container or other ModelObjects changed by
75  this during evaluation. This is only useful for ScoreStates,
76  at the moment.*/
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 };
82 
83 IMPKERNEL_END_NAMESPACE
84 
85 #endif /* IMPKERNEL_MODEL_OBJECT_H */
Various general useful macros for IMP.
Basic types used by IMP.
Smart pointer to Object-derived classes that does not refcount.
Definition: WeakPointer.h:76
A more IMP-like version of the std::vector.
Definition: Vector.h:39
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:72
ScoreStatesTemp get_required_score_states(ModelObject *p, const ModelObjectsTemp &all, const DependencyGraph &dg, const DependencyGraphVertexIndex &index)
Common base class for heavy weight IMP objects.
Definition: Object.h:106
Various general useful macros for IMP.
virtual void handle_set_has_required_score_states(bool)
Definition: ModelObject.h:69