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... | |
Top level tree API representing a tree structure/schema associated with a store.
Data is accessed via TreeCursor.
|
inlineexplicit |
|
inline |
|
inline |
|
inlinenoexcept |
Move constructor "stealing" the C resource from the source.
|
inline |
|
delete |
Can't be copied, single owner of C resources is required (to avoid double-free during destruction)
void obx::Tree::consolidateNodeConflictsAsync | ( | ) |
Explicitly consolidates tree node conflicts (non unique nodes sharing a common path) asynchronously.
void obx::Tree::getAsync | ( | const char * | path, |
bool | withMetadata, | ||
AsyncTreeGetCallback | callback | ||
) |
A get operation for a tree leaf,.
withMetadata | Flag if the callback also wants to receive the metadata (also as raw FlatBuffers). |
callback | Once the operation has completed (successfully or not), the callback is called with AsyncTreeGetResult. |
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.
withMetadata | Flag if the callback also wants to receive the metadata (also as raw FlatBuffers). |
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).
|
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.
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.
data | prepared 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) |
type | value type of the given leafObject: it has to be passed to verify against stored metadata |
outId | Receives the ID of the data leaf object that was put (pointer can be null) |
metadata | optional 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. |
dataPutMode | For the data leaf only (the actual value tree node) |
callback | Once the operation has completed (successfully or not), the callback is called with AsyncTreePutResult. |
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.