Apache Geode Native C++ Reference 1.15.0
CacheableObjectArray.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_CACHEABLEOBJECTARRAY_H_
21#define GEODE_CACHEABLEOBJECTARRAY_H_
22
23#include <memory>
24#include <vector>
25
26#include "Serializable.hpp"
27#include "internal/DSCode.hpp"
28#include "internal/DataSerializablePrimitive.hpp"
29#include "internal/geode_globals.hpp"
30
34namespace apache {
35namespace geode {
36namespace client {
37
38class DataInput;
39class DataOutput;
40class Serializable;
41
47class APACHE_GEODE_EXPORT CacheableObjectArray
48 : public internal::DataSerializablePrimitive,
49 public std::vector<std::shared_ptr<Cacheable>> {
50 public:
52 inline CacheableObjectArray() : std::vector<std::shared_ptr<Cacheable>>() {}
53
55 inline explicit CacheableObjectArray(int32_t n)
56 : std::vector<std::shared_ptr<Cacheable>>(n) {}
57
58 ~CacheableObjectArray() noexcept override = default;
59
60 CacheableObjectArray& operator=(const CacheableObjectArray& other) = delete;
61 CacheableObjectArray(const CacheableObjectArray& other) = delete;
62
63 void toData(DataOutput& output) const override;
64
65 virtual void fromData(DataInput& input) override;
66
70 inline static std::shared_ptr<Serializable> createDeserializable() {
71 return std::make_shared<CacheableObjectArray>();
72 }
73
74 internal::DSCode getDsCode() const override {
75 return internal::DSCode::CacheableObjectArray;
76 }
77
81 inline static std::shared_ptr<CacheableObjectArray> create() {
82 return std::make_shared<CacheableObjectArray>();
83 }
84
89 inline static std::shared_ptr<CacheableObjectArray> create(int32_t n) {
90 return std::make_shared<CacheableObjectArray>(n);
91 }
92
93 virtual size_t objectSize() const override;
94};
95
96} // namespace client
97} // namespace geode
98} // namespace apache
99
100#endif // GEODE_CACHEABLEOBJECTARRAY_H_
Implements an immutable Vector of Cacheable objects that can serve as a distributable object for cach...
Definition: CacheableObjectArray.hpp:49
static std::shared_ptr< CacheableObjectArray > create(int32_t n)
Factory method for creating an instance of CacheableObjectArray with given size.
Definition: CacheableObjectArray.hpp:89
CacheableObjectArray(int32_t n)
Create a vector with n elements allocated.
Definition: CacheableObjectArray.hpp:55
static std::shared_ptr< CacheableObjectArray > create()
Factory method for creating the default instance of CacheableObjectArray.
Definition: CacheableObjectArray.hpp:81
CacheableObjectArray()
Constructor, used for deserialization.
Definition: CacheableObjectArray.hpp:52
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
This base class is the superclass of all user objects in the cache that can be serialized.
Definition: Serializable.hpp:53

Apache Geode C++ Cache API Documentation