The AdaptObject class is the parent class of all the ADAPT JS API classes. The class is used for memory management and contains a Destroy method that frees the allocated C++ memory.

The class also stores and manages the reference to the lifetime object it’s attached to.

Note: All the objects created by an instance of the builder are attached to the same lifetime object.

Hierarchy

Table of contents

Constructors

Accessors

Methods

Constructors

constructor

new AdaptObject(lifetime?)

Parameters

Name Type
lifetime? AdaptObjectLifetime

Defined in

common/dist/memory_management/adapt_object_lifetime.d.ts:10

Accessors

lifetime

get lifetime(): undefined | AdaptObjectLifetime

Returns

undefined | AdaptObjectLifetime

Defined in

common/dist/memory_management/adapt_object_lifetime.d.ts:50

set lifetime(lt): void

Parameters

Name Type
lt undefined | AdaptObjectLifetime

Returns

void

Defined in

common/dist/memory_management/adapt_object_lifetime.d.ts:51

Methods

Attach

Attach(lt?): AdaptObject

Attach object to the given lifetime.

In case when lifetime was already defined before, it detaches object from the previous lifetime and attaches to the new one.

Example

AdaptEnvironment.InitializeAsync().then(() => {
     const lifetime = new AdaptObjectLifetime();
     const lifetime1 = new AdaptObjectLifetime();
     const value = new AdaptValue(lifetime, 5);
     value.Attach(lifetime1);
     lifetime.Finalize(); // value is not destroyed by this call
     lifetime1.Finalize(); // value is destroyed
})

Parameters

Name Type Description
lt? AdaptObjectLifetime Lifetime to attach object to

Returns

AdaptObject

Defined in

common/dist/memory_management/adapt_object_lifetime.d.ts:72


Clone

Abstract Clone(lifetime?): AdaptObject

Parameters

Name Type
lifetime? AdaptObjectLifetime

Returns

AdaptObject

Defined in

common/dist/memory_management/adapt_object_lifetime.d.ts:37


Destroy

Destroy(): void

Destroy the C++ object. After calling this method, the object reference is no longer valid and, thus, can’t be used.

Example

AdaptEnvironment.InitializeAsync().then(() => {
     const lifetime = new AdaptObjectLifetime();
     const value = new AdaptValue(lifetime, 5);
     const anotherValue = value;
     const valueCloned = value.Clone(undefined);
     value.Destroy();
     // both `value` and `anotherValue` can't be used because they are pointing to the same C++ object that has been deleted.
     // however, `valueCloned` is valid because it points to another (cloned) C++ object.
     valueCloned.Destroy();
     lifetime.Finalize();
})

Returns

void

Defined in

common/dist/memory_management/adapt_object_lifetime.d.ts:29


Detach

Detach(): AdaptObject

Detach the value from the lifetime

Example

AdaptEnvironment.InitializeAsync().then(() => {
     const lifetime = new AdaptObjectLifetime();
     const value = new AdaptValue(lifetime, 5);
     value.Detach(); // value must be destroyed manually now
     lifetime.Finalize(); // value is not destroyed by this call
     value.Destroy();
})

Returns

AdaptObject

Defined in

common/dist/memory_management/adapt_object_lifetime.d.ts:88