Apache Geode Native C++ Reference 1.15.0
PdxInstanceFactory.hpp
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_PDXINSTANCEFACTORY_H_
21#define GEODE_PDXINSTANCEFACTORY_H_
22
23#include <map>
24
25#include "CacheableBuiltins.hpp"
26#include "CacheableDate.hpp"
28#include "PdxInstance.hpp"
29#include "internal/geode_globals.hpp"
30
31namespace apache {
32namespace geode {
33namespace client {
34
35class PdxType;
36typedef std::map<std::string, std::shared_ptr<Cacheable>> FieldVsValues;
37class CachePerfStats;
38class PdxTypeRegistry;
39class AuthenticatedView;
40
52class APACHE_GEODE_EXPORT PdxInstanceFactory {
53 public:
54 PdxInstanceFactory() = delete;
55 ~PdxInstanceFactory() noexcept = default;
56
57 public:
65 std::shared_ptr<PdxInstance> create();
66
77 PdxInstanceFactory& writeChar(const std::string& fieldName, char16_t value);
78
89 PdxInstanceFactory& writeChar(const std::string& fieldName, char value);
90
101 PdxInstanceFactory& writeBoolean(const std::string& fieldName, bool value);
102
113 PdxInstanceFactory& writeByte(const std::string& fieldName, int8_t value);
114
125 PdxInstanceFactory& writeShort(const std::string& fieldName, int16_t value);
126
137 PdxInstanceFactory& writeInt(const std::string& fieldName, int32_t value);
138
149 PdxInstanceFactory& writeLong(const std::string& fieldName, int64_t value);
150
161 PdxInstanceFactory& writeFloat(const std::string& fieldName, float value);
162
173 PdxInstanceFactory& writeDouble(const std::string& fieldName, double value);
174
185 PdxInstanceFactory& writeDate(const std::string& fieldName,
186 std::shared_ptr<CacheableDate> value);
187
198 PdxInstanceFactory& writeString(const std::string& fieldName,
199 const std::string& value);
200
201 PdxInstanceFactory& writeString(const std::string& fieldName,
202 std::string&& value);
203
221 PdxInstanceFactory& writeObject(const std::string& fieldName,
222 std::shared_ptr<Cacheable> value);
223
234 PdxInstanceFactory& writeBooleanArray(const std::string& fieldName,
235 const std::vector<bool>& value);
236
247 PdxInstanceFactory& writeCharArray(const std::string& fieldName,
248 const std::vector<char16_t>& value);
249
260 PdxInstanceFactory& writeByteArray(const std::string& fieldName,
261 const std::vector<int8_t>& value);
262
273 PdxInstanceFactory& writeShortArray(const std::string& fieldName,
274 const std::vector<int16_t>& value);
275
286 PdxInstanceFactory& writeIntArray(const std::string& fieldName,
287 const std::vector<int32_t>& value);
288
299 PdxInstanceFactory& writeLongArray(const std::string& fieldName,
300 const std::vector<int64_t>& value);
301
312 PdxInstanceFactory& writeFloatArray(const std::string& fieldName,
313 const std::vector<float>& value);
314
325 PdxInstanceFactory& writeDoubleArray(const std::string& fieldName,
326 const std::vector<double>& value);
327
338 PdxInstanceFactory& writeStringArray(const std::string& fieldName,
339 const std::vector<std::string>& value);
340
356 const std::string& fieldName,
357 std::shared_ptr<CacheableObjectArray> value);
358
372 PdxInstanceFactory& writeArrayOfByteArrays(const std::string& fieldName,
373 int8_t** value,
374 int32_t arrayLength,
375 int32_t* elementLength);
376
400 PdxInstanceFactory& markIdentityField(const std::string& fieldName);
401
402 private:
403 bool m_created;
404 std::shared_ptr<PdxType> m_pdxType;
405 FieldVsValues m_FieldVsValues;
406 CachePerfStats& m_cachePerfStats;
407 PdxTypeRegistry& m_pdxTypeRegistry;
408 const CacheImpl& m_cacheImpl;
409 bool m_enableTimeStatistics;
410 void isFieldAdded(const std::string& fieldName);
411
412 PdxInstanceFactory(const std::string& className, bool expectDomainClass,
413 CachePerfStats& cachePerfStats,
414 PdxTypeRegistry& m_pdxTypeRegistry, const CacheImpl& cache,
415 bool enableTimeStatistics);
416
417 friend CacheImpl;
418 friend AuthenticatedView;
419};
420} // namespace client
421} // namespace geode
422} // namespace apache
423
424#endif // GEODE_PDXINSTANCEFACTORY_H_
Contains generic template definitions for Cacheable types and instantiations for built-in types.
Creates an authenticated cache view to allow credential based access to region services.
Definition: AuthenticatedView.hpp:46
PdxInstanceFactory gives you a way to create PdxInstances.
Definition: PdxInstanceFactory.hpp:52
PdxInstanceFactory & writeBooleanArray(const std::string &fieldName, const std::vector< bool > &value)
Writes the named field with the given value to the serialized form.
PdxInstanceFactory & writeLongArray(const std::string &fieldName, const std::vector< int64_t > &value)
Writes the named field with the given value to the serialized form.
PdxInstanceFactory & writeString(const std::string &fieldName, const std::string &value)
Writes the named field with the given value to the serialized form.
PdxInstanceFactory & writeFloatArray(const std::string &fieldName, const std::vector< float > &value)
Writes the named field with the given value to the serialized form.
PdxInstanceFactory & writeByteArray(const std::string &fieldName, const std::vector< int8_t > &value)
Writes the named field with the given value to the serialized form.
PdxInstanceFactory & writeShort(const std::string &fieldName, int16_t value)
Writes the named field with the given value to the serialized form.
PdxInstanceFactory & writeObject(const std::string &fieldName, std::shared_ptr< Cacheable > value)
Writes the named field with the given value to the serialized form.
PdxInstanceFactory & markIdentityField(const std::string &fieldName)
Indicate that the named field should be included in hashCode and equals (operator==()) checks of this...
PdxInstanceFactory & writeArrayOfByteArrays(const std::string &fieldName, int8_t **value, int32_t arrayLength, int32_t *elementLength)
Writes the named field with the given value to the serialized form.
PdxInstanceFactory & writeChar(const std::string &fieldName, char value)
Writes the named field with the given value to the serialized form.
PdxInstanceFactory & writeInt(const std::string &fieldName, int32_t value)
Writes the named field with the given value to the serialized form.
PdxInstanceFactory & writeCharArray(const std::string &fieldName, const std::vector< char16_t > &value)
Writes the named field with the given value to the serialized form.
std::shared_ptr< PdxInstance > create()
Create a PdxInstance.
PdxInstanceFactory & writeDoubleArray(const std::string &fieldName, const std::vector< double > &value)
Writes the named field with the given value to the serialized form.
PdxInstanceFactory & writeDate(const std::string &fieldName, std::shared_ptr< CacheableDate > value)
Writes the named field with the given value to the serialized form.
PdxInstanceFactory & writeDouble(const std::string &fieldName, double value)
Writes the named field with the given value to the serialized form.
PdxInstanceFactory & writeStringArray(const std::string &fieldName, const std::vector< std::string > &value)
Writes the named field with the given value to the serialized form.
PdxInstanceFactory & writeBoolean(const std::string &fieldName, bool value)
Writes the named field with the given value to the serialized form.
PdxInstanceFactory & writeLong(const std::string &fieldName, int64_t value)
Writes the named field with the given value to the serialized form.
PdxInstanceFactory & writeFloat(const std::string &fieldName, float value)
Writes the named field with the given value to the serialized form.
PdxInstanceFactory & writeByte(const std::string &fieldName, int8_t value)
Writes the named field with the given value to the serialized form.
PdxInstanceFactory & writeObjectArray(const std::string &fieldName, std::shared_ptr< CacheableObjectArray > value)
Writes the named field with the given value to the serialized form.
PdxInstanceFactory & writeShortArray(const std::string &fieldName, const std::vector< int16_t > &value)
Writes the named field with the given value to the serialized form.
PdxInstanceFactory & writeIntArray(const std::string &fieldName, const std::vector< int32_t > &value)
Writes the named field with the given value to the serialized form.
PdxInstanceFactory & writeChar(const std::string &fieldName, char16_t value)
Writes the named field with the given value to the serialized form.

Apache Geode C++ Cache API Documentation