HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TAKE_Data.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  * NAME: TAKE_Data.h ( TAK Library, C++)
7  *
8  * COMMENTS: Take data. Each entity which can be changed on a per-take
9  * basis has take data associated with it. When the current take
10  * is changed, we lock down the take information for the entity.
11  *
12  * The priority is used in application of the data when setting a
13  * take. For example, a parameter which is a multi-type guy
14  * should occur before the parameters it defines.
15  * At the current time, there should only be two priorities, 10
16  * and 100.
17  */
18 
19 #ifndef __TAKE_Data__
20 #define __TAKE_Data__
21 
22 #include "TAKE_API.h"
23 #include "TAKE_DataId.h"
24 #include <iosfwd>
25 
26 class UT_String;
27 class UT_WorkBuffer;
28 
29 #define TAKE_HIGH_PRIORITY 10 // Data is applied before other data
30 #define TAKE_NORMAL_PRIORITY 100
31 #define TAKE_LOW_PRIORITY 1000 // Data is applied last
32 
34 {
35 public:
36  TAKE_Data(const TAKE_DataId &id, int priority) :
37  myId(id), myRefCount(0), myPriority(priority) { }
38  virtual ~TAKE_Data();
39 
40  // Create a copy of the data
41  virtual TAKE_Data *duplicate() const = 0;
42 
43  // Query whether the take data can be duplicated for the specified
44  // node.
45  virtual bool canDuplicateForNode(int op_id) const = 0;
46  // Create a copy of the data for the specified node.
47  virtual TAKE_Data *duplicateForNode(int op_id) const = 0;
48 
49  // Store data from the current take
50  virtual void storeCurrent() = 0;
51  // Apply the data to make this current
52  virtual void applyData() = 0;
53 
54  virtual void getOpIdString(UT_String &str) = 0;
55 
56  // Mark the current take data as being active
57  virtual void markActive() = 0;
58  virtual void markInactive() = 0;
59 
60  // Generate a command which will go from the master take to the active take
61  virtual void generateIncludeCommand(UT_WorkBuffer &) = 0;
62  virtual void generateCommand(UT_WorkBuffer &) = 0;
63 
64  // Description of what this take data is
65  virtual void getDescription(UT_WorkBuffer &, int brief=0) = 0;
66 
67  // Amount of memory used (don't forget sizeof(*this))
68  virtual int64 getMemoryUsage() const = 0;
69 
70  // Query whether or not this data should be saved for the master take.
71  // This is used to avoid saving the data in the master take for locked
72  // assets, allowing it to be recomputed during the load.
73  virtual bool canSaveInMasterTake() const = 0;
74 
75  virtual int save(std::ostream &os, int binary) const = 0;
76  virtual bool load(UT_IStream &is) = 0;
77 
78  const TAKE_DataId &getId() const { return myId; }
79 
80  void bumpRefCount(int dir) { myRefCount += dir; }
81  int getRefCount() const { return myRefCount; }
82 
83  void setPriority(int p) { myPriority = p; }
84  int getPriority() const { return myPriority; }
85 
86 protected:
87  // Only allow subclasses to copy us
88  TAKE_Data(const TAKE_Data &) = default;
89  TAKE_Data &operator=(const TAKE_Data &) = default;
90 
91 private:
92  TAKE_DataId myId;
93  int myRefCount;
94  int myPriority;
95 };
96 
97 #endif
PXL_API const char * getDescription(const ColorSpace *space)
Return the description of the color space.
const GLuint GLenum const void * binary
Definition: glcorearb.h:1924
int getRefCount() const
Definition: TAKE_Data.h:81
TAKE_Data(const TAKE_DataId &id, int priority)
Definition: TAKE_Data.h:36
void setPriority(int p)
Definition: TAKE_Data.h:83
const TAKE_DataId & getId() const
Definition: TAKE_Data.h:78
int getPriority() const
Definition: TAKE_Data.h:84
long long int64
Definition: SYS_Types.h:116
void bumpRefCount(int dir)
Definition: TAKE_Data.h:80
#define TAKE_API
Definition: TAKE_API.h:10