Pivotal GemFire Native C++ Reference  10.1.3
Properties.hpp
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #pragma once
19 
20 #ifndef GEODE_PROPERTIES_H_
21 #define GEODE_PROPERTIES_H_
22 
27 #include <memory>
28 #include <string>
29 #include <unordered_map>
30 
31 #include "CacheableKey.hpp"
32 #include "internal/DataSerializablePrimitive.hpp"
33 #include "internal/chrono/duration.hpp"
34 #include "internal/geode_globals.hpp"
35 
36 namespace apache {
37 namespace geode {
38 namespace client {
39 
40 using apache::geode::internal::chrono::duration::to_string;
41 
42 class DataInput;
43 class DataOutput;
44 class CacheableString;
45 
51 class APACHE_GEODE_EXPORT Properties
52  : public internal::DataSerializablePrimitive {
53  public:
54  class Visitor {
55  public:
56  virtual void visit(const std::shared_ptr<CacheableKey>& key,
57  const std::shared_ptr<Cacheable>& value) = 0;
58  virtual ~Visitor() {}
59  };
60 
61  Properties() = default;
62  ~Properties() noexcept override = default;
63  Properties(const Properties&) = delete;
64  Properties& operator=(const Properties&) = delete;
65 
71  std::shared_ptr<CacheableString> find(const std::string& key);
72 
79  std::shared_ptr<Cacheable> find(const std::shared_ptr<CacheableKey>& key);
80 
86  void insert(std::string key, std::string value);
87 
93  void insert(std::string key, const int value);
94 
100  void insert(const std::shared_ptr<CacheableKey>& key,
101  const std::shared_ptr<Cacheable>& value);
102 
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));
107  }
108 
114  void remove(const std::string& key);
115 
121  void remove(const std::shared_ptr<CacheableKey>& key);
122 
127  void foreach (Visitor& visitor) const;
128 
130  size_t getSize() const;
131 
135  void addAll(const std::shared_ptr<Properties>& other);
136 
138  static std::shared_ptr<Properties> create();
139 
143  void load(const std::string& fileName);
144 
146  static std::shared_ptr<Serializable> createDeserializable();
147 
148  void toData(DataOutput& output) const override;
149 
150  void fromData(DataInput& input) override;
151 
152  internal::DSCode getDsCode() const override;
153 
154  private:
155  HashMapOfCacheable m_map;
156 };
157 
158 } // namespace client
159 } // namespace geode
160 } // namespace apache
161 
162 #endif // GEODE_PROPERTIES_H_
apache::geode::client::Properties
Definition: Properties.hpp:51
CacheableKey.hpp
apache::geode::client::DataOutput
Provide operations for writing primitive data values, byte arrays, strings, Serializable objects to a...
Definition: DataOutput.hpp:48
apache::geode::client::DataInput
Provide operations for reading primitive data values, byte arrays, strings, Serializable objects from...
Definition: DataInput.hpp:59

Apache Geode C++ Cache API Documentation