HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TAKE_Take.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_Take.h ( TAK Library, C++)
7  *
8  * COMMENTS: Defines a take
9  */
10 
11 #ifndef __TAKE_Take__
12 #define __TAKE_Take__
13 
14 #include "TAKE_API.h"
15 
16 #include "TAKE_DataId.h"
17 
18 #include <UT/UT_Map.h>
19 #include <UT/UT_Array.h>
20 #include <iosfwd>
21 
22 class TAKE_Data;
23 class TAKE_Manager;
24 class TAKE_StringSaver;
25 class UT_IStream;
26 class UT_StringArray;
27 
29 {
30 public:
31  TAKE_Take(TAKE_Take *parent, const char *name);
32  ~TAKE_Take();
33 
34  // Parent/child management
35  void destroyAllKids();
36  void destroyKid(TAKE_Take *kid);
37 
38  // Insert a layer between us and our children
39  void insertChildTake(TAKE_Take *kid);
40  bool isAncestor(const TAKE_Take *take) const;
41 
42  // Add a child layer to us. This layer will inherit all unbound data
43  // from us.
45  {
46  kid->myParent = this;
47  myKids.append(kid);
48  mySortDirty = 1;
49  }
50 
51  void applyTake(int setactive, UT_Array<TAKE_Data *>&data);
52  void applySpecificTake(bool setactive, const TAKE_DataId &id);
53  void markActive();
54  void clearData();
55 
56  int64 getMemoryUsage(bool inclusive) const;
57 
58  // Name of the take
59  void setName(const char *name);
60  const char *getName() const { return myName; }
61 
62  int save(TAKE_StringSaver &strings, std::ostream &os, int binary) const;
63  int load(UT_StringArray &strings, TAKE_Manager *mgr, UT_IStream &is);
64 
65  // Data associated with the take layer
66  TAKE_Data *getData(const TAKE_DataId &id) const;
67  void addData(TAKE_Data *data);
68  void destroyData(const TAKE_DataId &id);
69  void replaceData(TAKE_Data *new_data);
70 
71  // Returns an unsorted list of data
72  void getDataList(UT_Array<TAKE_Data *> &list) const;
73  void getNodeDataList(UT_Array<TAKE_Data *>&list, int opid) const;
74  int getDeadDataCount() const { return myDeadDataCount; }
75 
76 
77  const TAKE_Take *getParent() const { return myParent; }
78  TAKE_Take *getParent() { return myParent; }
79  void setParent(TAKE_Take *p) { myParent = p; }
80  bool reparent(TAKE_Take *newparent);
81 
82  int entries() const { return myKids.entries(); }
84  {
85  if (mySortDirty) sortKids();
86  return myKids(i);
87  }
88  int getChildren(UT_Array<TAKE_Take *>&layers);
89 
90  // semi-private. This needs to be public to be accessed by static
91  // functions, but should be considered private.
92  void deReferenceMasterData(TAKE_Data *data);
93 
94  void cleanDeadData();
95 
96 private:
97  void sortKids();
98 
100 
101  UT_Array<TAKE_Take *> myKids;
102  TAKE_Take *myParent;
103  UT_StringHolder myName;
104 
105  DataMap myData;
106  int myDeadDataCount;
107  bool mySortDirty:1;
108 };
109 
110 #endif
TAKE_Take * getParent()
Definition: TAKE_Take.h:78
void addChildTake(TAKE_Take *kid)
Definition: TAKE_Take.h:44
const GLuint GLenum const void * binary
Definition: glcorearb.h:1923
png_uint_32 i
Definition: png.h:2877
long long int64
Definition: SYS_Types.h:100
int getDeadDataCount() const
Definition: TAKE_Take.h:74
void setParent(TAKE_Take *p)
Definition: TAKE_Take.h:79
GLboolean * data
Definition: glcorearb.h:130
GLuint const GLchar * name
Definition: glcorearb.h:785
GLsizei const GLchar *const * strings
Definition: glcorearb.h:1932
const char * getName() const
Definition: TAKE_Take.h:60
int entries() const
Definition: TAKE_Take.h:82
TAKE_Take * getChild(int i)
Definition: TAKE_Take.h:83
const TAKE_Take * getParent() const
Definition: TAKE_Take.h:77
#define TAKE_API
Definition: TAKE_API.h:10