HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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_Array.h>
19 #include <UT/UT_Map.h>
20 #include <UT/UT_NonCopyable.h>
21 #include <iosfwd>
22 
23 class TAKE_Data;
24 class TAKE_Manager;
25 class TAKE_StringSaver;
26 class UT_IStream;
27 class UT_StringArray;
28 
30 {
31 public:
32  TAKE_Take(TAKE_Take *parent, const char *name);
33  ~TAKE_Take();
34 
36 
37  // Parent/child management
38  void destroyAllKids();
39  void destroyKid(TAKE_Take *kid);
40 
41  // Insert a layer between us and our children
42  void insertChildTake(TAKE_Take *kid);
43  bool isAncestor(const TAKE_Take *take) const;
44 
45  // Add a child layer to us. This layer will inherit all unbound data
46  // from us.
48  {
49  kid->myParent = this;
50  myKids.append(kid);
51  mySortDirty = 1;
52  }
53 
54  void applyTake(int setactive, UT_Array<TAKE_Data *>&data);
55  void applySpecificTake(bool setactive, const TAKE_DataId &id);
56  void markActive();
57  void clearData();
58 
59  int64 getMemoryUsage(bool inclusive) const;
60 
61  // Name of the take
62  void setName(const char *name);
63  const char *getName() const { return myName; }
64 
65  int save(TAKE_StringSaver &strings, std::ostream &os, int binary) const;
66  int load(UT_StringArray &strings, TAKE_Manager *mgr, UT_IStream &is);
67 
68  // Data associated with the take layer
69  TAKE_Data *getData(const TAKE_DataId &id) const;
70  void addData(TAKE_Data *data);
71  void destroyData(const TAKE_DataId &id);
72  void replaceData(TAKE_Data *new_data);
73 
74  // Returns an unsorted list of data
75  void getDataList(UT_Array<TAKE_Data *> &list) const;
76  void getNodeDataList(UT_Array<TAKE_Data *>&list, int opid) const;
77  int getDeadDataCount() const { return myDeadDataCount; }
78 
79 
80  const TAKE_Take *getParent() const { return myParent; }
81  TAKE_Take *getParent() { return myParent; }
82  void setParent(TAKE_Take *p) { myParent = p; }
83  bool reparent(TAKE_Take *newparent);
84 
85  int entries() const { return myKids.entries(); }
87  {
88  if (mySortDirty) sortKids();
89  return myKids(i);
90  }
92 
93  // semi-private. This needs to be public to be accessed by static
94  // functions, but should be considered private.
95  void deReferenceMasterData(TAKE_Data *data);
96 
97  void cleanDeadData();
98 
99 private:
100  void sortKids();
101 
103 
104  UT_Array<TAKE_Take *> myKids;
105  TAKE_Take *myParent;
106  UT_StringHolder myName;
107 
108  DataMap myData;
109  int myDeadDataCount;
110  bool mySortDirty:1;
111 };
112 
113 #endif
TAKE_Take * getParent()
Definition: TAKE_Take.h:81
void addChildTake(TAKE_Take *kid)
Definition: TAKE_Take.h:47
const GLuint GLenum const void * binary
Definition: glcorearb.h:1924
GU_API GA_OffsetArray getChildren(const GU_Detail *gdp, const GA_Offset &node, bool recurse=false)
int getDeadDataCount() const
Definition: TAKE_Take.h:77
#define UT_NON_COPYABLE(CLASS)
Define deleted copy constructor and assignment operator inside a class.
long long int64
Definition: SYS_Types.h:116
void setParent(TAKE_Take *p)
Definition: TAKE_Take.h:82
GLuint const GLchar * name
Definition: glcorearb.h:786
GLsizei const GLchar *const * strings
Definition: glcorearb.h:1933
const char * getName() const
Definition: TAKE_Take.h:63
int entries() const
Definition: TAKE_Take.h:85
TAKE_Take * getChild(int i)
Definition: TAKE_Take.h:86
const TAKE_Take * getParent() const
Definition: TAKE_Take.h:80
Definition: format.h:895
#define TAKE_API
Definition: TAKE_API.h:10