HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PDGE_DependencyOwner.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * COMMENTS:
7  */
8 
9 #ifndef __PDGE_DEPENDENCY_OWNER_H__
10 #define __PDGE_DEPENDENCY_OWNER_H__
11 
12 #include "PDGE_API.h"
13 #include "PDGE_Dependency.h"
14 
15 #include <UT/UT_Array.h>
16 #include <UT/UT_Assert.h>
17 #include <UT/UT_NonCopyable.h>
18 #include <UT/UT_StringHolder.h>
19 
20 class PDGE_Evaluator;
21 class PDGE_Resolutions;
22 
23 /**
24  * Base class for objects that own dependencies
25  */
27 {
28 public:
31 
32 public:
33  /// Constructs a new dependency owner, which must have a string name
35  virtual ~PDGE_DependencyOwner() {}
36 
38 
39  /// Returns the memory usage of this owner instance
40  virtual int64 getMemoryUsage(bool inclusive) const
41  {
42  int64 mem = inclusive ? sizeof(*this) : 0;
43  mem += myPropagateSet.getMemoryUsage(false);
44  return mem;
45  }
46 
47  /// Resets the owner
48  virtual void resetOwner()
49  { myPropagateSet.clear(); }
50 
51  /// Debug name for this dependency owner object, used when various debug
52  /// utilities are enabled
53  virtual UT_StringHolder debugName() const = 0;
54 
55  /// Debug name for the dependency group this owner is in, used for DOT
56  /// graph output when enabled.
57  virtual UT_StringHolder debugGroup() const
58  { return debugName(); }
59 
60  /// Converts an owner array to an array of the specified type
61  template <typename T>
62  static inline void cast(UT_Array<T>& out, const Array& in)
63  {
64  out.setCapacity(in.size());
65  for (auto&& input : in)
66  out.append((T)(input));
67  }
68 
69  /// Converts an array of the specified type to an owner array
70  template <typename T>
71  static inline void cast(Array& out, const UT_Array<T>& in)
72  {
73  out.setCapacity(in.size());
74  for (auto&& input : in)
75  out.append(input);
76  }
77 
78 protected:
79  friend class PDGE_Dependency;
80  friend class PDGE_PropagateGroup;
81 
82  /// Called when a dependency owned by this object is resolved
84  const PDGE_Evaluator&,
86  {
87  UT_ASSERT(false);
89  }
90 
91  /// Called when a dependency owned by this object is unresolved
92  /// during an evaluation. This method is not called for normal
93  /// reset calls between evaluations, or when a dependency object
94  /// is destroyed. It also cannot be used to add new dependencies or
95  /// trigger evaluation of existing ones, however it can return back
96  /// additional dependencies that should be unresolved.
99  {
100  return 0;
101  }
102 
103  /// Called when a dependency owned by this object receives a partial
104  /// resolve notification.
106  const PDGE_Evaluator&,
108  const Array&)
109  {
110  UT_ASSERT(false);
112  }
113 
114  /// Returns the propagate set for this owner
115  inline const PDGE_Dependency::Set&
117  { return myPropagateSet; }
118 
119  /// Adds an entry to the propagate set
120  inline void addPropagate(PDGE_Dependency* dependency)
121  { myPropagateSet.insert(dependency); }
122 
123 private:
124  /// Propagate set, used by PDGE_PropgateGroup
125  PDGE_Dependency::Set myPropagateSet;
126 };
127 
128 #endif
virtual PDGE_Dependency::State evalPartial(PDGE_Resolutions &, const PDGE_Evaluator &, PDGE_Dependency *, const Array &)
static void cast(Array &out, const UT_Array< T > &in)
Converts an array of the specified type to an owner array.
void setCapacity(exint new_capacity)
exint size() const
Definition: UT_Array.h:646
void addPropagate(PDGE_Dependency *dependency)
Adds an entry to the propagate set.
The dependency was successfully resolved.
#define UT_NON_COPYABLE(CLASS)
Define deleted copy constructor and assignment operator inside a class.
long long int64
Definition: SYS_Types.h:116
PDGE_DependencyOwner()
Constructs a new dependency owner, which must have a string name.
exint append()
Definition: UT_Array.h:142
static void cast(UT_Array< T > &out, const Array &in)
Converts an owner array to an array of the specified type.
#define PDGE_API
Definition: PDGE_API.h:23
virtual PDGE_Dependency::State evalResolve(PDGE_Resolutions &, const PDGE_Evaluator &, PDGE_Dependency *)
Called when a dependency owned by this object is resolved.
virtual UT_StringHolder debugGroup() const
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:156
virtual int evalUnresolve(PDGE_Dependency::Array &, PDGE_Dependency *)
virtual void resetOwner()
Resets the owner.
const PDGE_Dependency::Set & propagateSet()
Returns the propagate set for this owner.