VMware Tanzu GemFire Native C++ Reference  10.1.5
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 
29 namespace apache {
30 namespace geode {
31 namespace client {
32 
33 class DataOutput;
34 class DataInput;
35 class Cache;
36 class PdxSerializable;
37 class Serializable;
38 
44 using TypeFactoryMethod = std::function<std::shared_ptr<Serializable>()>;
45 
46 using TypeFactoryMethodPdx = std::function<std::shared_ptr<PdxSerializable>()>;
47 
53 class 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 
90 typedef Serializable Cacheable;
91 
92 } // namespace client
93 } // namespace geode
94 } // namespace apache
95 
96 #endif // GEODE_SERIALIZABLE_H_
apache::geode::client::Serializable
This base class is the superclass of all user objects in the cache that can be serialized.
Definition: Serializable.hpp:53
apache::geode::client::Serializable::toString
virtual std::string toString() const
Display this object as 'string', which depends on the implementation in the subclasses.
apache::geode::client::Serializable::create
static std::shared_ptr< Serializable > create(_T value)
Factory method that creates the Serializable object that matches the type of value.
apache::geode::client::Serializable::objectSize
virtual size_t objectSize() const
return the size in bytes of the instance being serialized.

Apache Geode C++ Cache API Documentation