IMP logo
IMP Reference Guide  2.18.0
The Integrative Modeling Platform
ModelObject.h
Go to the documentation of this file.
1 /**
2  * \file IMP/ModelObject.h
3  * \brief Base class for objects in a Model that depend on other objects.
4  *
5  * Copyright 2007-2022 IMP Inventors. All rights reserved.
6  */
7 
8 #ifndef IMPKERNEL_MODEL_OBJECT_H
9 #define IMPKERNEL_MODEL_OBJECT_H
10 
11 #include <IMP/kernel_config.h>
12 #include "base_types.h"
13 #include <IMP/ref_counted_macros.h>
14 #include <IMP/utility_macros.h>
15 
16 IMPKERNEL_BEGIN_NAMESPACE
17 
18 class Model;
19 
20 //! Base class for objects in a Model that depend on other objects.
21 /** These objects are associated with a particular Model
22  and have a callback that is called whenever the dependencies
23  in the model change. This allows them to update internal state
24  when that occurs.
25  */
26 class IMPKERNELEXPORT ModelObject : public Object {
27  friend class Model;
28  WeakPointer<Model> model_;
29 
30  // for cleanup
31  void set_model(Model *m);
32 
33  public:
34 #if !defined(IMP_DOXYGEN) && !defined(SWIG)
35  void validate_inputs() const;
36  void validate_outputs() const;
37 #endif
38 
39  ModelObject(Model *m, std::string name);
40  ~ModelObject();
41 
42  Model *get_model() const { return model_; }
43  /** get_has_dependencies() must be true. */
44  ModelObjectsTemp get_inputs() const;
45  /** get_has_dependencies() must be true. */
46  ModelObjectsTemp get_outputs() const;
47  //! Get the interacting sets induced by this ModelObject.
48  /** That is, the particles in each ModelObjectsTemp in the list have some
49  sort of computed relation with one another and none with
50  disjoint other sets in the list. */
51  ModelObjectsTemps get_interactions() const;
52 
53  //! Return whether this object has dependencies computed
54  bool get_has_dependencies() const;
55 
56  //! Either invalidate the dependencies or ensure they are correct.
57  void set_has_dependencies(bool tf);
58 
59  //! Compute the required score states.
60  void set_has_required_score_states(bool tf);
61 
62  //! Return whether score states are computed.
63  bool get_has_required_score_states() const;
64 
65  //! Get the score states that are ancestors of this in the dependency graph.
66  const ScoreStatesTemp &get_required_score_states() const;
67 
68  protected:
69  // virtual void do_destroy() override {set_has_dependencies(false);}
70  /** Called when set_has_required_score_states() is called.*/
72  /** Get any Particle, Container or other ModelObjects read by
73  this during evaluation. If you read everything in a container,
74  you can just return that container. */
75  virtual ModelObjectsTemp do_get_inputs() const = 0;
76  /** Get any Particle, Container or other ModelObjects changed by
77  this during evaluation. This is only useful for ScoreStates,
78  at the moment.*/
79  virtual ModelObjectsTemp do_get_outputs() const = 0;
80  /** Override if this if not all inputs interact with all outputs. This is
81  rarely something you want to do.*/
82  virtual ModelObjectsTemps do_get_interactions() const;
83 };
84 
85 IMPKERNEL_END_NAMESPACE
86 
87 #endif /* IMPKERNEL_MODEL_OBJECT_H */
Macros to help with reference counting.
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:42
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:73
Base class for objects in a Model that depend on other objects.
Definition: ModelObject.h:26
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:71