SoMemoryObject Class Reference
[General]

VSG extension Handle memory buffer with reference counter. More...

#include <Inventor/misc/SoMemoryObject.h>

Inheritance diagram for SoMemoryObject:
SoRefCounter

List of all members.

Public Types

enum  CopyPolicy {
  COPY = 0,
  NO_COPY,
  NO_COPY_AND_DELETE,
  NO_COPY_AND_FREE
}

Public Member Functions

 SoMemoryObject ()
 SoMemoryObject (void *buf, size_t byteSize, bool owner=true)
 SoMemoryObject (void *buf, size_t byteSize, SbDataType type, CopyPolicy policy)
 SoMemoryObject (SoBufferObject *bufObj, SbDataType type=SbDataType::UNSIGNED_BYTE, bool owner=true)
virtual ~SoMemoryObject ()
void * get () const
size_t length () const
SbDataType getType () const

Detailed Description

VSG extension Handle memory buffer with reference counter.

This object encapsulates a memory buffer with a reference counter, allowing it to be shared across multiple objects. The buffer will be released when no more references to it exist.

SEE ALSO

SoRefCounter, SoRef,


Member Enumeration Documentation

SoMemoryObject may be manipulating large amounts of memory.

It is therefore convenient to be able to set the memory usage policy.

Enumerator:
COPY 

Open Inventor will make a copy of the data.

NO_COPY 

Passed buffer used, user will delete.

NO_COPY_AND_DELETE 

Passed buffer used, SoMemoryObject will delete.

Use this if memory is allocated with operator "new[]".

NO_COPY_AND_FREE 

Passed buffer used, SoMemoryObject will free.

Use this if memory is allocated with "malloc".


Constructor & Destructor Documentation

SoMemoryObject::SoMemoryObject (  ) 

Default Constructor.

No memory area is handled, but default parameters are set to a type of SbDataType::UNSIGNED_BYTE and a CopyPolicy of NO_COPY_AND_DELETE

SoMemoryObject::SoMemoryObject ( void *  buf,
size_t  byteSize,
bool  owner = true 
)

Constructor.

Takes the object to manage.
Default type will be assigned to UNSIGNED_BYTE. if owner flag is true, Policy will be set to NO_COPY_AND_FREE , then the memory area pointed to by buf should be allocated by malloc/realloc C function in order to be correctly deleted during unref. else policy is NO_COPY (disables automatic release of the managed buffer).

SoMemoryObject::SoMemoryObject ( void *  buf,
size_t  byteSize,
SbDataType  type,
CopyPolicy  policy 
)

Constructor.

Takes the object to manage.

SoMemoryObject::SoMemoryObject ( SoBufferObject bufObj,
SbDataType  type = SbDataType::UNSIGNED_BYTE,
bool  owner = true 
)

Constructor.

Takes the buffer object to manage.
Policy is NO_COPY_AND_DELETE if owner flag is true, else policy is NO_COPY (disables automatic release of the buffer object).

virtual SoMemoryObject::~SoMemoryObject (  )  [virtual]

Destructor.

It will be called when there are no more references to this object. It will destroy the managed buffer as well.


Member Function Documentation

void* SoMemoryObject::get (  )  const

Returns a pointer to the encapsulated buffer.

SbDataType SoMemoryObject::getType (  )  const [inline]

Returns the type of the encapsulated buffer.

size_t SoMemoryObject::length (  )  const

Returns the size in bytes of the encapsulated buffer.


The documentation for this class was generated from the following file:

Open Inventor Toolkit reference manual, generated on 4 Sep 2023
Copyright © Thermo Fisher Scientific All rights reserved.
https://www.openinventor.com/