memgraph/include/storage/model/properties/properties.hpp

52 lines
1.2 KiB
C++
Raw Normal View History

#pragma once
#include <map>
#include "storage/model/properties/property.hpp"
#include "storage/model/properties/property_family.hpp"
#include "utils/option.hpp"
using prop_key_t = PropertyFamily::PropertyType::PropertyFamilyKey;
template <class T>
using type_key_t = PropertyFamily::PropertyType::PropertyTypeKey<T>;
class Properties
{
public:
using sptr = std::shared_ptr<Properties>;
auto begin() const { return props.begin(); }
2016-08-08 04:19:04 +08:00
auto cbegin() const { return props.cbegin(); }
auto end() const { return props.end(); }
2016-08-08 04:19:04 +08:00
auto cend() const { return props.cend(); }
size_t size() const { return props.size(); }
const Property &at(prop_key_t &key) const;
2016-08-08 04:19:04 +08:00
template <class T>
auto at(type_key_t<T> &key) const;
template <class T, class... Args>
void set(type_key_t<T> &key, Args &&... args);
void set(prop_key_t &key, Property::sptr value);
void clear(prop_key_t &key);
template <class Handler>
void accept(Handler &handler) const
{
for (auto &kv : props)
handler.handle(kv.first, *kv.second);
handler.finish();
}
private:
using props_t = std::map<prop_key_t, Property::sptr>;
props_t props;
};