MeshLib Java Docs
Loading...
Searching...
No Matches
meshlib.CppObject Class Referenceabstract
Inheritance diagram for meshlib.CppObject:

Public Member Functions

final java.lang.foreign.MemorySegment rawPointer ()
final boolean isOwned ()
final void close ()
final java.lang.foreign.MemorySegment release ()

Protected Member Functions

 CppObject (java.lang.foreign.MemorySegment ptr, java.util.function.Consumer< java.lang.foreign.MemorySegment > destroy, java.lang.Object owner)

Detailed Description

The base class of the wrappers of the opaque C++ classes.

An instance either owns its C++ object (then the object is destroyed when the wrapper is garbage-collected or closed), or is a reference to an object owned by something else. References returned by methods keep their owner alive.

Constructor & Destructor Documentation

◆ CppObject()

meshlib.CppObject.CppObject ( java.lang.foreign.MemorySegment ptr,
java.util.function.Consumer< java.lang.foreign.MemorySegment > destroy,
java.lang.Object owner )
protected

Wraps a pointer from the C bindings. If destroy is not null, the object is owned and destroy is called on it when the wrapper dies. owner is kept alive as long as this wrapper is.

Member Function Documentation

◆ close()

final void meshlib.CppObject.close ( )

Destroys the C++ object now, if owned. The wrapper can't be used after this. Calling it again does nothing.

◆ isOwned()

final boolean meshlib.CppObject.isOwned ( )

Does this wrapper own its C++ object?

◆ rawPointer()

final java.lang.foreign.MemorySegment meshlib.CppObject.rawPointer ( )

The address of the native object. For opaque classes it's a zero-length segment, for exposed structs it covers the struct.

Implements meshlib.Native.

◆ release()

final java.lang.foreign.MemorySegment meshlib.CppObject.release ( )

Gives up the ownership of the C++ object and returns its pointer. The caller is responsible for destroying it. The wrapper can't be used after this.


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