20#ifndef GEODE_PROPERTIES_H_
21#define GEODE_PROPERTIES_H_
29#include <unordered_map>
32#include "internal/DataSerializablePrimitive.hpp"
33#include "internal/chrono/duration.hpp"
34#include "internal/geode_globals.hpp"
40using apache::geode::internal::chrono::duration::to_string;
52 :
public internal::DataSerializablePrimitive {
56 virtual void visit(
const std::shared_ptr<CacheableKey>& key,
57 const std::shared_ptr<Cacheable>& value) = 0;
58 virtual ~Visitor()
noexcept =
default;
71 std::shared_ptr<CacheableString>
find(
const std::string& key);
79 std::shared_ptr<Cacheable>
find(
const std::shared_ptr<CacheableKey>& key);
86 void insert(std::string key, std::string value);
93 void insert(std::string key,
const int value);
100 void insert(
const std::shared_ptr<CacheableKey>& key,
101 const std::shared_ptr<Cacheable>& value);
103 template <
class _Rep,
class _Period>
104 void insert(std::string key,
105 const std::chrono::duration<_Rep, _Period>& value) {
106 insert(key, to_string(value));
121 void remove(
const std::shared_ptr<CacheableKey>& key);
127 void foreach (Visitor& visitor)
const;
135 void addAll(
const std::shared_ptr<Properties>& other);
138 static std::shared_ptr<Properties>
create();
143 void load(
const std::string& fileName);
148 void toData(
DataOutput& output)
const override;
150 void fromData(
DataInput& input)
override;
152 internal::DSCode getDsCode()
const override;
155 HashMapOfCacheable m_map;
Provide operations for reading primitive data values, byte arrays, strings, Serializable objects from...
Definition: DataInput.hpp:59
Provide operations for writing primitive data values, byte arrays, strings, Serializable objects to a...
Definition: DataOutput.hpp:48
Contains a set of (key, value) pair properties with key being the name of the property; value,...
Definition: Properties.hpp:52
void addAll(const std::shared_ptr< Properties > &other)
Add the contents of other to this instance, replacing any existing values with those from other.
void insert(std::string key, std::string value)
Add or update the string value for key.
void remove(const std::string &key)
Remove the key from the collection.
size_t getSize() const
Return the number of entries in the collection.
void load(const std::string &fileName)
Read property values from a file, overriding what is currently in the properties object.
static std::shared_ptr< Properties > create()
Factory method, returns an empty collection.
static std::shared_ptr< Serializable > createDeserializable()
Return an empty instance for deserialization.
std::shared_ptr< CacheableString > find(const std::string &key)
Return the value for the given key, or nullptr if not found.
void insert(const std::shared_ptr< CacheableKey > &key, const std::shared_ptr< Cacheable > &value)
Add or update Cacheable value for CacheableKey.
std::shared_ptr< Cacheable > find(const std::shared_ptr< CacheableKey > &key)
Return the value for the given CacheableKey, or nullptr if not found.
void remove(const std::shared_ptr< CacheableKey > &key)
Remove the CacheableKey from the collection.
void insert(std::string key, const int value)
Add or update the int value for key.