00001 /* 00002 * PROPRIETARY INFORMATION. This software is proprietary to 00003 * Side Effects Software Inc., and is not to be reproduced, 00004 * transmitted, or disclosed in any way without written permission. 00005 * 00006 * Produced by: 00007 * Mark Elendt 00008 * Side Effects Software Inc 00009 * 477 Richmond Street West 00010 * Toronto, Ontario 00011 * Canada M5V 3E7 00012 * 416-504-9876 00013 * 00014 * NAME: TAKE_Take.h ( TAK Library, C++) 00015 * 00016 * COMMENTS: Defines a take 00017 */ 00018 00019 #ifndef __TAKE_Take__ 00020 #define __TAKE_Take__ 00021 00022 #include "TAKE_API.h" 00023 #include <iostream.h> 00024 #include "TAKE_Hash.h" 00025 #include <UT/UT_HashTable.h> 00026 #include <UT/UT_PtrArray.h> 00027 00028 class TAKE_Data; 00029 class TAKE_Hash; 00030 class TAKE_Manager; 00031 class TAKE_StringSaver; 00032 class UT_StringArray; 00033 00034 class TAKE_API TAKE_Take { 00035 public: 00036 TAKE_Take(TAKE_Take *parent, const char *name); 00037 ~TAKE_Take(); 00038 00039 // Parent/child management 00040 void destroyAllKids(); 00041 void destroyKid(TAKE_Take *kid); 00042 00043 // Insert a layer between us and our children 00044 void insertChildTake(TAKE_Take *kid); 00045 bool isAncestor(const TAKE_Take *take) const; 00046 00047 // Add a child layer to us. This layer will inherit all unbound data 00048 // from us. 00049 void addChildTake(TAKE_Take *kid) 00050 { 00051 kid->myParent = this; 00052 myKids.append(kid); 00053 mySortDirty = 1; 00054 } 00055 00056 void applyTake(int setactive, UT_PtrArray<TAKE_Data *>&data); 00057 void applySpecificTake(int setactive, TAKE_Hash &id); 00058 void markActive(); 00059 void clearData(); 00060 00061 int64 getMemoryUsage() const; 00062 00063 // Name of the take 00064 const char *getName() const { return myName; } 00065 const char *getLabel() const { return myName; } 00066 00067 int save(TAKE_StringSaver &strings, ostream &os, int binary) const; 00068 int load(UT_StringArray &strings, TAKE_Manager *mgr, 00069 UT_IStream &is); 00070 00071 void setName(const char *name); 00072 void setLabel(const char *label); 00073 00074 // Data associated with the take layer 00075 TAKE_Data *getData(const TAKE_Hash &id) const; 00076 void addData(TAKE_Data *data); 00077 void destroyData(const TAKE_Hash &id); 00078 void replaceData(TAKE_Data *new_data); 00079 00080 // Returns an unsorted list of data 00081 void getDataList(UT_PtrArray<TAKE_Data *> &list) const; 00082 void getNodeDataList(UT_PtrArray<TAKE_Data *>&list, int opid) const; 00083 int getDeadDataCount() const { return myDeadDataCount; } 00084 00085 00086 const TAKE_Take *getParent() const { return myParent; } 00087 TAKE_Take *getParent() { return myParent; } 00088 void setParent(TAKE_Take *p) { myParent = p; } 00089 bool reparent(TAKE_Take *newparent); 00090 00091 int entries() const { return myKids.entries(); } 00092 TAKE_Take *getChild(int i) 00093 { 00094 if (mySortDirty) sortKids(); 00095 return myKids(i); 00096 } 00097 int getChildren(UT_PtrArray<TAKE_Take *>&layers); 00098 00099 // semi-private. This needs to be public to be accessed by static 00100 // functions, but should be considered private. 00101 void deReferenceMasterData(TAKE_Data *data); 00102 00103 void cleanDeadData(); 00104 00105 private: 00106 void sortKids(); 00107 00108 UT_PtrArray<TAKE_Take *> myKids; 00109 TAKE_Take *myParent; 00110 const char *myName; 00111 UT_HashTable myData; 00112 int myDeadDataCount; 00113 uint mySortDirty:1; 00114 }; 00115 00116 #endif
1.5.9