HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
OP_DataBlock.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: OP_DataBlock.h (OP Library, C++)
7  *
8  * COMMENTS: Simple class for holding a chunk of arbitrary binary data
9  * owned by a node.
10  */
11 
12 #ifndef __OP_DATABLOCK_H_INCLUDED__
13 #define __OP_DATABLOCK_H_INCLUDED__
14 
15 #include "OP_API.h"
16 #include <UT/UT_IntrusivePtr.h>
17 #include <UT/UT_StringHolder.h>
18 #include <iosfwd>
19 
20 class UT_IStream;
21 
23 {
24 public:
26  virtual ~OP_DataBlockInterpreter();
27 
28  virtual const void *createNativeData(const char *data,
29  exint length) const = 0;
30  virtual exint memoryUsedByNativeData(
31  const void *nativedata) const = 0;
32  virtual void deleteNativeData(const void *nativedata) const = 0;
33  virtual void saveNativeData(const void *nativedata,
34  std::ostream &os) const = 0;
35 
36 private:
37  UT_StringHolder myType;
38 };
39 
40 class OP_API OP_DataBlock : public UT_IntrusiveRefCounter<OP_DataBlock>
41 {
42 public:
44  ~OP_DataBlock();
45 
46  const UT_StringHolder &type() const
47  { return myType; }
48  const char *data() const
49  { return myData; }
50  exint length() const
51  { return myLength; }
52  exint getMemoryUsage() const;
53 
54  const void *nativeData();
55  void adoptData(const char *data, exint length);
56  void adoptNativeData(const void *nativedata);
57  bool saveData(std::ostream &os) const;
58  bool loadData(UT_IStream &is);
59 
60 private:
61  void deleteData();
62  void deleteNativeData();
63 
64  const UT_StringHolder myType;
65  const char *myData;
66  exint myLength;
67  const void *myNativeData;
68  bool myNativeDataIsValid;
69 };
70 
71 #endif // __OP_DATABLOCK_H_INCLUDED__
A reference counter base class for use with UT_IntrusivePtr.
int64 exint
Definition: SYS_Types.h:115
exint length() const
Definition: OP_DataBlock.h:50
const char * data() const
Definition: OP_DataBlock.h:48
GLboolean * data
Definition: glcorearb.h:130
const UT_StringHolder & type() const
Definition: OP_DataBlock.h:46
#define OP_API
Definition: OP_API.h:10
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:107
GLuint GLsizei GLsizei * length
Definition: glcorearb.h:794