VMware Tanzu GemFire Native C++ Reference 10.3.0
Serializable.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_SERIALIZABLE_H_
21#define GEODE_SERIALIZABLE_H_
22
23#include <functional>
24#include <memory>
25#include <string>
26
27#include "internal/geode_globals.hpp"
28
29namespace apache {
30namespace geode {
31namespace client {
32
33class DataOutput;
34class DataInput;
35class Cache;
36class PdxSerializable;
37class Serializable;
38
44using TypeFactoryMethod = std::function<std::shared_ptr<Serializable>()>;
45
46using TypeFactoryMethodPdx = std::function<std::shared_ptr<PdxSerializable>()>;
47
53class APACHE_GEODE_EXPORT Serializable {
54 public:
63 virtual size_t objectSize() const;
64
69 virtual std::string toString() const;
70
76 template <class _T>
77 static std::shared_ptr<Serializable> create(_T value);
78
79 template <class _T>
80 inline static std::shared_ptr<Serializable> create(
81 const std::shared_ptr<_T>& value) {
82 return value;
83 }
84
85 virtual ~Serializable() noexcept = default;
86
87 protected:
88};
89
91
92} // namespace client
93} // namespace geode
94} // namespace apache
95
96#endif // GEODE_SERIALIZABLE_H_
This base class is the superclass of all user objects in the cache that can be serialized.
Definition: Serializable.hpp:53
virtual size_t objectSize() const
return the size in bytes of the instance being serialized.
virtual std::string toString() const
Display this object as 'string', which depends on the implementation in the subclasses.
static std::shared_ptr< Serializable > create(_T value)
Factory method that creates the Serializable object that matches the type of value.

Apache Geode C++ Cache API Documentation