HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PDG_CommandManager.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_COMMAND_MANAGER_H__
10 #define __PDG_COMMAND_MANAGER_H__
11 
12 #include "PDG_API.h"
13 
14 #include <UT/UT_Array.h>
15 #include <UT/UT_NonCopyable.h>
16 #include <UT/UT_UniquePtr.h>
17 #include <UT/UT_WorkBuffer.h>
18 
19 class PDG_Command;
20 class PDG_CommandChunk;
21 class PDG_GraphContext;
22 
24 {
25 public:
27  virtual ~PDG_CommandManager();
28 
30 
31  PDG_CommandChunk * openChunk(UT_StringHolder description);
32  virtual PDG_CommandChunk * openChunk(bool delayed,
33  UT_StringHolder description);
34  void enableLogging(bool enable);
35  PDG_CommandChunk * currentlyOpenChunk() const;
36 
37  bool commitChunk(UT_WorkBuffer& errors);
38  bool commitChunk()
39  {
40  UT_WorkBuffer errors;
41  return commitChunk(errors);
42  }
43 
44  bool rollbackChunk(UT_WorkBuffer& errors);
45 
46  bool undoIt(UT_WorkBuffer& errors);
47  bool undoIt()
48  {
49  UT_WorkBuffer errors;
50  return undoIt(errors);
51  }
52  bool redoIt(UT_WorkBuffer& errors);
53 
54  bool recordCommand(UT_UniquePtr<PDG_Command> cmd, UT_WorkBuffer& errors);
55  bool recordCommand(UT_UniquePtr<PDG_Command> cmd);
56 
57  void clear();
58  void commandDescriptions(UT_WorkBuffer& buffer) const;
59  void commands(UT_Array<PDG_Command*>& commands) const;
60  void commandChunks(UT_Array<PDG_Command*>& commands) const;
61 
62  int stateCount() const { return myDoneIndex + 1; }
63  int chunkDepth() const { return myCommandChunkStack.size(); }
64 
65 protected:
67 
68 private:
69  PDG_GraphContext* myContext;
71  int myDoneIndex;
72 };
73 
74 #endif /* __PDG_COMMAND_MANAGER_H__ */
#define PDG_API
Definition: PDG_API.h:23
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:39
Definition: core.h:760
#define UT_NON_COPYABLE(CLASS)
Define deleted copy constructor and assignment operator inside a class.
UT_Array< UT_UniquePtr< PDG_CommandChunk > > myCommandChunkStack