HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GA_BlobData.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: GA_BlobData.h ( GA Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __GA_BlobData__
12 #define __GA_BlobData__
13 
14 #include "GA_API.h"
15 #include <SYS/SYS_Types.h>
16 #include <UT/UT_IntrusivePtr.h>
17 
18 #include <stddef.h>
19 
20 class GA_LoadMap;
21 class GA_SaveMap;
22 class UT_JSONParser;
23 class UT_JSONWriter;
24 class UT_MemoryCounter;
25 class UT_WorkBuffer;
26 
27 
28 /// Class representing an opaque blob of data stored in an attribute
29 /// @see GA_BlobRef, GA_BlobContainer, GA_ATIBlob
31  : public UT_IntrusiveRefCounter<GA_BlobData>
32 {
33 public:
34  GA_BlobData();
35  virtual ~GA_BlobData();
36 
37  /// @{
38  /// The new & delete operators are overloaded to help with memory tracking.
39  // Allocat new object
40  static void *operator new(size_t size);
41  // In-place construction
42  static void *operator new(size_t size, void *p);
43  // Deletion of allocated object
44  static void operator delete(void *p, size_t size);
45  // Get memory statistics
46  static void getAllocationStats(int64 &used, int64 &peak);
47  /// @}
48 
49  /// Create a hash
50  virtual uint hash() const = 0;
51 
52  /// Return true if this blob is equal to the other blob
53  virtual bool isEqual(const GA_BlobData &blob) const = 0;
54 
55  /// Save blob data to a JSON stream. By default, this saves a Null.
56  virtual bool jsonSave(UT_JSONWriter &w, const GA_SaveMap *s) const;
57  /// Load blob data from a JSON stream. By default, this skips the next
58  /// block of data.
59  virtual bool jsonLoad(UT_JSONParser &p, const GA_LoadMap *m);
60 
61  /// Call jsonSave on the work buffer to create a simple representation of
62  /// the blob data.
63  void repr(UT_WorkBuffer &wbuf) const;
64 
65  /// Report approximate memory usage
66  virtual int64 getMemoryUsage(bool inclusive) const = 0;
67 
68  /// Count memory usage using a UT_MemoryCounter in order to count
69  /// shared memory correctly.
70  /// If inclusive is true, the size of this object is counted,
71  /// else only memory owned by this object is counted.
72  /// If this is pointed to by the calling object, inclusive should be true.
73  /// If this is contained in the calling object, inclusive should be false.
74  /// (Its memory was already counted in the size of the calling object.)
75  virtual void countMemory(UT_MemoryCounter &counter, bool inclusive) const = 0;
76 
77 protected:
78  /// This is needed by subclasses int order to implement countMemory
79  exint getRefCount() const { return use_count(); }
80 };
81 
83 
84 #endif
Used to pass options and map offset values during saving.
Definition: GA_SaveMap.h:48
SYS_FORCE_INLINE uint32 use_count() const
Return current counter.
exint getRefCount() const
This is needed by subclasses int order to implement countMemory.
Definition: GA_BlobData.h:79
JSON reader class which handles parsing of JSON or bJSON files.
Definition: UT_JSONParser.h:72
#define GA_API
Definition: GA_API.h:12
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:32
A reference counter base class for use with UT_IntrusivePtr.
GLsizeiptr size
Definition: glcorearb.h:663
long long int64
Definition: SYS_Types.h:100
int64 exint
Definition: SYS_Types.h:109
Options during loading.
Definition: GA_LoadMap.h:42
unsigned int uint
Definition: SYS_Types.h:33
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:856