ObjectBox C and C++ API  4.0.3
obx::Tree Class Reference

Top level tree API representing a tree structure/schema associated with a store. More...

#include <objectbox.hpp>

Public Member Functions

 Tree (Store &store)
 
 Tree (Store &store, TreeOptions &options)
 
 Tree (Store &store, TreeOptions &&options)
 
 Tree (Tree &&source) noexcept
 Move constructor "stealing" the C resource from the source. More...
 
 ~Tree ()
 
 Tree (const Tree &)=delete
 Can't be copied, single owner of C resources is required (to avoid double-free during destruction) More...
 
std::string getLeafName (const std::string &path) const
 Returns the leaf name of the given path (the string component after the last path delimiter). More...
 
void getAsync (const char *path, bool withMetadata, AsyncTreeGetCallback callback)
 A get operation for a tree leaf,. More...
 
void getAsyncRawCallback (const char *path, bool withMetadata, obx_tree_async_get_callback *callback, void *callback_user_data=nullptr)
 Like getAsync(), but the callback uses a C function ptr and user data instead of a std::function wrapper. More...
 
void putAsync (const char *path, void *data, size_t size, OBXPropertyType type, void *metadata=nullptr, size_t metadata_size=0, OBXPutMode dataPutMode=OBXPutMode_PUT, AsyncTreePutCallback callback={})
 A "low-level" put operation for a tree leaf using given raw FlatBuffer bytes. Any non-existing branches and meta nodes are put on the fly if an optional meta-leaf FlatBuffers is given. A typical usage pattern is to first try without the meta-leaf, and if it does not work, create the meta-leaf and call again with the meta leaf. This approach takes into account that meta-leaves typically exist, and thus no resources are wasted for meta-leaf creation if it's not required. An advantage of using "raw" operations is that custom properties can be passed in the FlatBuffers. More...
 
void putAsyncRawCallback (const char *path, void *data, size_t size, OBXPropertyType type, void *metadata=nullptr, size_t metadata_size=0, OBXPutMode dataPutMode=OBXPutMode_PUT, obx_tree_async_put_callback *callback=nullptr, void *callback_user_data=nullptr)
 Like putAsync(), but the callback uses a C function ptr and user data instead of a std::function wrapper. More...
 
void consolidateNodeConflictsAsync ()
 Explicitly consolidates tree node conflicts (non unique nodes sharing a common path) asynchronously. More...
 
size_t nodeConflictCount ()
 Gets the number of currently tracked node conflicts (non-unique nodes at the same path). This count gets resent when conflicts get consolidated. Only tracked if OBXTreeOptionFlags_DetectNonUniqueNodes (or OBXTreeOptionFlags_AutoConsolidateNonUniqueNodes) is set. More...
 

Detailed Description

Top level tree API representing a tree structure/schema associated with a store.

Data is accessed via TreeCursor.

Constructor & Destructor Documentation

◆ Tree() [1/5]

obx::Tree::Tree ( Store store)
inlineexplicit

◆ Tree() [2/5]

obx::Tree::Tree ( Store store,
TreeOptions options 
)
inline

◆ Tree() [3/5]

obx::Tree::Tree ( Store store,
TreeOptions &&  options 
)
inline

◆ Tree() [4/5]

obx::Tree::Tree ( Tree &&  source)
inlinenoexcept

Move constructor "stealing" the C resource from the source.

◆ ~Tree()

obx::Tree::~Tree ( )
inline

◆ Tree() [5/5]

obx::Tree::Tree ( const Tree )
delete

Can't be copied, single owner of C resources is required (to avoid double-free during destruction)

Member Function Documentation

◆ consolidateNodeConflictsAsync()

void obx::Tree::consolidateNodeConflictsAsync ( )

Explicitly consolidates tree node conflicts (non unique nodes sharing a common path) asynchronously.

◆ getAsync()

void obx::Tree::getAsync ( const char *  path,
bool  withMetadata,
AsyncTreeGetCallback  callback 
)

A get operation for a tree leaf,.

Parameters
withMetadataFlag if the callback also wants to receive the metadata (also as raw FlatBuffers).
callbackOnce the operation has completed (successfully or not), the callback is called with AsyncTreeGetResult.

◆ getAsyncRawCallback()

void obx::Tree::getAsyncRawCallback ( const char *  path,
bool  withMetadata,
obx_tree_async_get_callback callback,
void *  callback_user_data = nullptr 
)

Like getAsync(), but the callback uses a C function ptr and user data instead of a std::function wrapper.

Parameters
withMetadataFlag if the callback also wants to receive the metadata (also as raw FlatBuffers).

◆ getLeafName()

std::string obx::Tree::getLeafName ( const std::string &  path) const

Returns the leaf name of the given path (the string component after the last path delimiter).

◆ nodeConflictCount()

size_t obx::Tree::nodeConflictCount ( )
inline

Gets the number of currently tracked node conflicts (non-unique nodes at the same path). This count gets resent when conflicts get consolidated. Only tracked if OBXTreeOptionFlags_DetectNonUniqueNodes (or OBXTreeOptionFlags_AutoConsolidateNonUniqueNodes) is set.

◆ putAsync()

void obx::Tree::putAsync ( const char *  path,
void *  data,
size_t  size,
OBXPropertyType  type,
void *  metadata = nullptr,
size_t  metadata_size = 0,
OBXPutMode  dataPutMode = OBXPutMode_PUT,
AsyncTreePutCallback  callback = {} 
)

A "low-level" put operation for a tree leaf using given raw FlatBuffer bytes. Any non-existing branches and meta nodes are put on the fly if an optional meta-leaf FlatBuffers is given. A typical usage pattern is to first try without the meta-leaf, and if it does not work, create the meta-leaf and call again with the meta leaf. This approach takes into account that meta-leaves typically exist, and thus no resources are wasted for meta-leaf creation if it's not required. An advantage of using "raw" operations is that custom properties can be passed in the FlatBuffers.

Parameters
dataprepared FlatBuffers bytes for the data leaf (non-const as the data buffer will be mutated); note: slots for IDs must be already be prepared (zero values)
typevalue type of the given leafObject: it has to be passed to verify against stored metadata
outIdReceives the ID of the data leaf object that was put (pointer can be null)
metadataoptional FlatBuffers for the meta leaf; at minimum, "name" and "type" must be set. Note: slots for IDs must be already be prepared (zero values). Passing null indicates that the branches and meta nodes must already exist; otherwise the operation will fail and OBX_NOT_FOUND will be returned.
dataPutModeFor the data leaf only (the actual value tree node)
callbackOnce the operation has completed (successfully or not), the callback is called with AsyncTreePutResult.

◆ putAsyncRawCallback()

void obx::Tree::putAsyncRawCallback ( const char *  path,
void *  data,
size_t  size,
OBXPropertyType  type,
void *  metadata = nullptr,
size_t  metadata_size = 0,
OBXPutMode  dataPutMode = OBXPutMode_PUT,
obx_tree_async_put_callback callback = nullptr,
void *  callback_user_data = nullptr 
)

Like putAsync(), but the callback uses a C function ptr and user data instead of a std::function wrapper.