HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PDG_CheckpointManager.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 __PDG_CHECKPOINT_MANAGER_H__
10 #define __PDG_CHECKPOINT_MANAGER_H__
11 
12 #include "PDG_API.h"
14 #include "PDG_WorkItemTypes.h"
15 
16 #include <UT/UT_Array.h>
17 #include <UT/UT_OFStream.h>
18 #include <UT/UT_StringHolder.h>
19 #include <UT/UT_TBBSpinLock.h>
20 
21 class PDG_WorkItem;
22 
23 /**
24  * Helper class for queuing and writing checkpoint files
25  */
27 {
28 public:
30 
31  void setEnabled(bool enabled)
32  { myIsEnabled = enabled; }
34  { myCheckpointRate = rate; }
35  bool setFilePath(
36  const UT_StringHolder& path,
37  UT_WorkBuffer& errors);
38 
39  bool enabled() const
40  { return myIsEnabled; }
41 
42  void writeAddedDependency(
43  const PDG_WorkItem* from,
44  const PDG_WorkItem* to,
45  bool required,
46  bool user_defined,
47  bool immediate);
48  void writeGeneratedItems(
49  const PDG_WorkItemArray& work_items);
50  void writeGeneratedBatches(
51  const PDG_BatchWorkItemSet& batches);
52  void writeExistingItems(
53  const PDG_WorkItemArray& work_items,
54  bool immediate);
55  void writeCookedItem(
56  const PDG_WorkItem* work_item,
57  bool immediate);
58 
59  void flush();
60 
61 private:
62  void flushPendingWrites(bool force);
63  void writeDependencyPair(
64  const PDG_WorkItem* from,
65  const PDG_WorkItem* to,
66  bool required,
67  bool user_defined,
68  bool immediate);
69  void writeWorkItemArray(
70  const PDG_WorkItemArray& work_items);
71 
72 private:
73  enum EntryType
74  {
75  eWorkItem,
77  };
78 
79  struct Entry
80  {
81  const PDG_WorkItem* myWorkItem;
82 
83  const PDG_WorkItem* myDependency;
84  bool myDependencyRequired;
85  bool myDependencyUserDefined;
86 
87  EntryType myType;
88  };
89 
90 private:
91  UT_Array<Entry> myPendingEntries;
92  UT_OFStream myOutputStream;
93  UT_StringHolder myFilePath;
94 
95  PDG_SerializationOptions myUpdateOptions;
96  PDG_SerializationOptions myInitialOptions;
97 
98  exint myCheckpointRate;
99 
100  mutable UT_TBBSpinLock myLock;
101  bool myIsEnabled;
102 };
103 
104 #endif
Custom work item data definition.
#define PDG_API
Definition: PDG_API.h:23
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
int64 exint
Definition: SYS_Types.h:125
GLenum GLenum GLsizei const GLuint GLboolean enabled
Definition: glcorearb.h:2539
Portable replacement for std::ofstream.
Definition: UT_OFStream.h:26
SIM_API const UT_StringHolder force
void setEnabled(bool enabled)
Custom external dependency.
void setCheckpointRate(exint rate)