Stay organized with collections
Save and categorize content based on your preferences.
ndk::impl::ScopedAResource
#include <binder_auto_utils.h>
This baseclass owns a single object, used to make various classes RAII.
Summary
Public functions
|
get()
|
T
This returns the underlying object to be modified but does not affect ownership.
|
get() const
|
const T
This returns the const underlying object but does not affect ownership.
|
getR()
|
T *
This allows the value in this class to be set from beneath it.
|
operator=(const ScopedAResource &)=delete
|
|
operator=(ScopedAResource && other) noexcept
|
|
release()
|
T
Release the underlying resource.
|
set(T t)
|
void
Takes ownership of t.
|
Public functions
ScopedAResource
ScopedAResource(
T t
)
get
T get()
This returns the underlying object to be modified but does not affect ownership.
get
const T get() const
This returns the const underlying object but does not affect ownership.
getR
T * getR()
This allows the value in this class to be set from beneath it.
If you call this method and then change the value of T*, you must take ownership of the value you are replacing and add ownership to the object that is put in here.
Recommended use is like this: ScopedAResource a; // will be nullptr SomeInitFunction(a.getR()); // value is initialized with refcount
Other usecases are discouraged.
release
T release()
Release the underlying resource.
~ScopedAResource
~ScopedAResource()
This deletes the underlying object if it exists.
See set.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2024-04-17 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-04-17 UTC."],[],[],null,["# ndk::impl::ScopedAResource Class Reference\n\nndk::impl::ScopedAResource\n==========================\n\n\n`#include \u003cbinder_auto_utils.h\u003e`\n\nThis baseclass owns a single object, used to make various classes RAII.\n\nSummary\n-------\n\n| ### Constructors and Destructors ||\n|---|---|\n| [ScopedAResource](#classndk_1_1impl_1_1_scoped_a_resource_1a8e9a24c6cc5c67be6bce7952c4f61781)`(T t)` Takes ownership of t. ||\n| [ScopedAResource](#classndk_1_1impl_1_1_scoped_a_resource_1acf3698c65e7cdb85e5562870bfacccc4)`(const `[ScopedAResource](/ndk/reference/classndk/1-1impl-1-1-scoped-a-resource#classndk_1_1impl_1_1_scoped_a_resource)` &)` ||\n| [ScopedAResource](#classndk_1_1impl_1_1_scoped_a_resource_1ad96f0d4baec67890421e763ad00d6100)`(`[ScopedAResource](/ndk/reference/classndk/1-1impl-1-1-scoped-a-resource#classndk_1_1impl_1_1_scoped_a_resource)` && other)` ||\n| [~ScopedAResource](#classndk_1_1impl_1_1_scoped_a_resource_1a3ef0acb2cfb7719a349c70f9902410ac)`()` This deletes the underlying object if it exists. ||\n\n| ### Public functions ||\n|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------|\n| [get](#classndk_1_1impl_1_1_scoped_a_resource_1a16b348f82e9c5607a60bd3c390de11a9)`()` | `T` This returns the underlying object to be modified but does not affect ownership. |\n| [get](#classndk_1_1impl_1_1_scoped_a_resource_1a7aac6588d84a866dc9b30c0d8ebce6f2)`() const ` | `const T` This returns the const underlying object but does not affect ownership. |\n| [getR](#classndk_1_1impl_1_1_scoped_a_resource_1a0f9bcddfa1f4babe476feddf78d85871)`()` | `T *` This allows the value in this class to be set from beneath it. |\n| [operator=](#classndk_1_1impl_1_1_scoped_a_resource_1a380885f868216184e8cbeec0653f8b58)`(const `[ScopedAResource](/ndk/reference/classndk/1-1impl-1-1-scoped-a-resource#classndk_1_1impl_1_1_scoped_a_resource)` &)=delete` | [ScopedAResource](/ndk/reference/classndk/1-1impl-1-1-scoped-a-resource#classndk_1_1impl_1_1_scoped_a_resource)` &` |\n| [operator=](#classndk_1_1impl_1_1_scoped_a_resource_1a361d999f328d901e0d3500d0dba6cf4d)`(`[ScopedAResource](/ndk/reference/classndk/1-1impl-1-1-scoped-a-resource#classndk_1_1impl_1_1_scoped_a_resource)` && other) noexcept` | [ScopedAResource](/ndk/reference/classndk/1-1impl-1-1-scoped-a-resource#classndk_1_1impl_1_1_scoped_a_resource)` &` |\n| [release](#classndk_1_1impl_1_1_scoped_a_resource_1a7b843cbd28682058b2212bd5b93e2ed2)`()` | `T` Release the underlying resource. |\n| [set](#classndk_1_1impl_1_1_scoped_a_resource_1a805bd77886baf4580ae136e141a23424)`(T t)` | `void` Takes ownership of t. |\n\nPublic functions\n----------------\n\n### ScopedAResource\n\n```text\n ScopedAResource(\n T t\n)\n``` \nTakes ownership of t. \n\n### ScopedAResource\n\n```gdscript\n ScopedAResource(\n const ScopedAResource &\n)=delete\n``` \n\n### ScopedAResource\n\n```text\n ScopedAResource(\n ScopedAResource && other\n) noexcept\n``` \n\n### get\n\n```text\nT get()\n``` \nThis returns the underlying object to be modified but does not affect ownership. \n\n### get\n\n```gdscript\nconst T get() const \n``` \nThis returns the const underlying object but does not affect ownership. \n\n### getR\n\n```scdoc\nT * getR()\n``` \nThis allows the value in this class to be set from beneath it.\n\nIf you call this method and then change the value of T\\*, you must take ownership of the value you are replacing and add ownership to the object that is put in here.\n\nRecommended use is like this: ScopedAResource a; // will be nullptr SomeInitFunction(a.getR()); // value is initialized with refcount\n\nOther usecases are discouraged. \n\n### operator=\n\n```gdscript\nScopedAResource & operator=(\n const ScopedAResource &\n)=delete\n``` \n\n### operator=\n\n```text\nScopedAResource & operator=(\n ScopedAResource && other\n) noexcept\n``` \n\n### release\n\n```text\nT release()\n``` \nRelease the underlying resource. \n\n### set\n\n```text\nvoid set(\n T t\n)\n``` \nTakes ownership of t. \n\n### \\~ScopedAResource\n\n```text\n ~ScopedAResource()\n``` \nThis deletes the underlying object if it exists.\n\nSee set."]]