Metall  v0.28
A persistent memory allocator for data-centric analytics

This is an example of how to use all API related to object attributes.

// Copyright 2020 Lawrence Livermore National Security, LLC and other Metall
// Project Developers. See the top-level COPYRIGHT file for details.
// SPDX-License-Identifier: (Apache-2.0 OR MIT)
#include <iostream>
#include <string>
using T = int;
// Just a one way to extract the type of the attributed object directory
// iterator
int main() {
metall::manager manager(metall::create_only, "/tmp/dir");
T* obj = manager.construct<T>("obj")();
[[maybe_unused]] bool flag;
[[maybe_unused]] std::size_t n;
[[maybe_unused]] std::string str;
[[maybe_unused]] iterator_t itr;
// Accessing object attributes via metall::manager object
n = manager.get_instance_length<T>(obj);
manager.get_instance_description<T>(obj, &str);
manager.set_instance_description<T>(obj, "foo");
itr = manager.named_begin();
itr = manager.named_end();
itr = manager.unique_begin();
itr = manager.unique_end();
itr = manager.anonymous_begin();
itr = manager.anonymous_end();
// Attributed Object Directory Accessor
// Named object
flag = asn.good();
n = asn.num_objects();
n = asn.count("obj");
itr = asn.find("name");
itr = asn.begin();
itr = asn.end();
flag = asn.set_description("obj", "foo");
flag = asn.set_description(itr, "foo");
// Unique object
flag = asu.good();
n = asu.num_objects();
n = asu.count(typeid(T).name());
n = asu.count<T>(metall::unique_instance);
itr = asu.find(typeid(T).name());
itr = asu.find<T>(metall::unique_instance);
itr = asu.begin();
itr = asu.end();
asu.set_description(typeid(T).name(), "foo");
asu.set_description<T>(metall::unique_instance, "foo");
asu.set_description(itr, "foo");
// Anonymous object
flag = asa.good();
n = asa.num_objects();
itr = asa.begin();
itr = asa.end();
asa.set_description(itr, "foo");
// Attributed Object Directory Iterator
n = itr->length();
flag = itr->is_type<T>();
return 0;
A generalized Metall manager class.
Definition: basic_manager.hpp:40
static anonymous_object_attribute_accessor_type access_anonymous_object_attribute(const path_type &path) noexcept
Returns an instance that provides access to the attribute of anonymous object.
Definition: basic_manager.hpp:1308
static named_object_attribute_accessor_type access_named_object_attribute(const path_type &path) noexcept
Returns an instance that provides access to the attribute of named objects.
Definition: basic_manager.hpp:1273
typename manager_kernel_type::const_named_iterator const_named_iterator
Const iterator for named objects.
Definition: basic_manager.hpp:121
static unique_object_attribute_accessor_type access_unique_object_attribute(const path_type &path) noexcept
Returns an instance that provides access to the attribute of unique object.
Definition: basic_manager.hpp:1290
int main()
Definition: jgraph.cpp:24
basic_string< char > string
A string container that uses char as its character type and Metall as its default allocator.
Definition: string.hpp:23
basic_manager<> manager
Default Metall manager class which is an alias of basic_manager with the default template parameters.
Definition: metall.hpp:34