VMware Tanzu GemFire Native C++ Reference  10.1.5
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 
34 namespace apache {
35 namespace geode {
36 namespace client {
37 
38 class DataInput;
39 class DataOutput;
40 class Serializable;
41 
47 class 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_
apache::geode::client::CacheableObjectArray::CacheableObjectArray
CacheableObjectArray(int32_t n)
Create a vector with n elements allocated.
Definition: CacheableObjectArray.hpp:55
apache::geode::client::CacheableObjectArray::create
static std::shared_ptr< CacheableObjectArray > create(int32_t n)
Factory method for creating an instance of CacheableObjectArray with given size.
Definition: CacheableObjectArray.hpp:89
apache::geode::client::CacheableObjectArray
Implements an immutable Vector of Cacheable objects that can serve as a distributable object for cach...
Definition: CacheableObjectArray.hpp:49
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::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::client::CacheableObjectArray::CacheableObjectArray
CacheableObjectArray()
Constructor, used for deserialization.
Definition: CacheableObjectArray.hpp:52
apache::geode::client::CacheableObjectArray::create
static std::shared_ptr< CacheableObjectArray > create()
Factory method for creating the default instance of CacheableObjectArray.
Definition: CacheableObjectArray.hpp:81

Apache Geode C++ Cache API Documentation