HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PDGE_Resolutions.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_RESOLUTIONS_H__
10 #define __PDGE_RESOLUTIONS_H__
11 
12 #include "PDGE_API.h"
13 
14 #include "PDGE_Dependency.h"
15 #include "PDGE_DependencyOwner.h"
16 
17 #include <UT/UT_Array.h>
18 #include <UT/UT_ArrayMap.h>
19 #include <UT/UT_NonCopyable.h>
20 #include <UT/UT_ParallelUtil.h>
21 
22 class PDGE_Evaluator;
23 
24 /*
25  * An array of dependency resolutions, including both partial and full
26  * resolutions.
27  */
29 {
30 public:
31  PDGE_Resolutions(bool defer_heavy = true)
32  : myIsSerial(false)
33  , myIsDeferHeavy(defer_heavy) {}
34 
36  {
37  myResolutions =
38  std::move(array.myResolutions);
39  myPartials =
40  std::move(array.myPartials);
41  myIsSerial =
42  array.myIsSerial;
43  myIsDeferHeavy =
44  array.myIsDeferHeavy;
45  }
47  {
48  if (this == &other)
49  return *this;
50  myResolutions =
51  std::move(other.myResolutions);
52  myPartials =
53  std::move(other.myPartials);
54  myIsSerial = other.myIsSerial;
55  myIsDeferHeavy = other.myIsDeferHeavy;
56  return *this;
57  }
58 
59  /// Returns the memory usage of this object
60  int64 getMemoryUsage(bool inclusive) const;
61 
62  /// Clears all exisiting resolutions from the array, including both partial
63  /// and full resolves.
64  inline void clearAll()
65  {
66  myResolutions.clear();
67  myPartials.clear();
68  myIsSerial = false;
69  }
70 
71  /// Clears only partial resolutions from the array.
72  inline void clearPartials()
73  {
74  myPartials.clear();
75  myIsSerial = false;
76  }
77 
78  /// Concats the contents of the specificed resolutions with the ones in
79  /// this array. No deduplication is performed.
80  inline void concat(const PDGE_Resolutions& resolutions)
81  {
82  myResolutions.concat(
83  resolutions.myResolutions);
84  myPartials.concat(
85  resolutions.myPartials);
86  }
87 
88  /// Returns the number of full resolutions in the array
89  inline exint numResolves() const
90  { return myResolutions.size(); }
91 
92  /// Returns the number of partial resolutions in the array
93  inline exint numPartials() const
94  { return myPartials.size(); }
95 
96  /// Returns true if partial evaluation should be performed in serial
97  /// instead of in parallel
98  inline bool isSerial() const
99  { return myIsSerial; }
100 
101 
102  /// Adds a new dependency to the list of full resolutions
103  inline void addResolve(PDGE_Dependency* dependency)
104  { myResolutions.append(dependency); }
105 
106  /// Adds a new dependency to the list of partial resolutions, along with
107  /// the owner argument associated with the partial resolution.
108  bool addPartial(
109  PDGE_Dependency* dependency,
110  const PDGE_DependencyOwner::Array& owners,
111  bool ascending=true,
112  bool serial=false);
113 
114  /// Same as above, but with a single owner argument for convenience
115  bool addPartial(
116  PDGE_Dependency* dependency,
117  PDGE_DependencyOwner* owner,
118  bool ascending=true,
119  bool serial=false);
120 
121  /// Save as above, but with an arbitrarily typed array
122  template <typename T>
124  PDGE_Dependency* dependency,
125  const UT_Array<T>& owners,
126  bool ascending=true,
127  bool serial=false)
128  {
130  PDGE_DependencyOwner::cast<T>(
131  output, owners);
132 
133  return addPartial(dependency,
134  output,
135  ascending,
136  serial);
137  }
138 
139  /// Evaluates all full resolutions in the array. This function should be
140  /// called from a UTparallelFor.
141  void evaluateResolves(
143  PDGE_Evaluator& evaluator,
144  PDGE_Resolutions& resolutions,
145  PDGE_Resolutions& deferred) const;
146 
147  /// Evaluates all partial resolutions and stores new resolutions into the
148  /// supplied array. This function should be called from a UTparalleReduce.
149  void evaluatePartials(
151  PDGE_Evaluator& evaluator,
152  PDGE_Resolutions& resolutions) const;
153 
154 private:
155  PDGE_Dependency::Array myResolutions;
156  PDGE_Dependency::Partial myPartials;
157  bool myIsSerial;
158  bool myIsDeferHeavy;
159 };
160 
161 #endif
GLenum GLint * range
Definition: glcorearb.h:1925
void clearPartials()
Clears only partial resolutions from the array.
int64 exint
Definition: SYS_Types.h:125
bool isSerial() const
bool addPartial(PDGE_Dependency *dependency, const UT_Array< T > &owners, bool ascending=true, bool serial=false)
Save as above, but with an arbitrarily typed array.
exint numPartials() const
Returns the number of partial resolutions in the array.
void concat(const PDGE_Resolutions &resolutions)
long long int64
Definition: SYS_Types.h:116
void addResolve(PDGE_Dependency *dependency)
Adds a new dependency to the list of full resolutions.
exint numResolves() const
Returns the number of full resolutions in the array.
PDGE_Resolutions(bool defer_heavy=true)
PDGE_Resolutions & operator=(PDGE_Resolutions &&other)
#define PDGE_API
Definition: PDGE_API.h:23
PDGE_Resolutions(PDGE_Resolutions &&array)
Declare prior to use.