| Apache Ignite C++

binary_object.h
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
23 #ifndef _IGNITE_BINARY_BINARY_OBJECT
24 #define _IGNITE_BINARY_BINARY_OBJECT
25
26 #include <stdint.h>
27
28 #include <ignite/impl/binary/binary_object_impl.h>
29
30 namespace ignite
31 {
32 namespace impl
33 {
34 namespace binary
35 {
36 class BinaryWriterImpl;
37 }
38 }
39
40 namespace binary
41 {
48 class IGNITE_IMPORT_EXPORT BinaryObject
49 {
50 friend class ignite::impl::binary::BinaryWriterImpl;
51 public:
53
58 BinaryObject(const impl::binary::BinaryObjectImpl& impl) :
59 impl(impl)
60 {
61 // No-op.
62 }
63
73 BinaryObject(impl::interop::InteropMemory& mem, int32_t start,
74 impl::binary::BinaryIdResolver* idRslvr, impl::binary::BinaryTypeManager* metaMgr) :
75 impl(mem, start, idRslvr, metaMgr)
76 {
77 // No-op.
78 }
80
86 BinaryObject(const BinaryObject& other) :
87 impl(other.impl)
88 {
89 // No-op.
90 }
91
98 BinaryObject& operator=(const BinaryObject& other)
99 {
100 impl = other.impl;
101
102 return *this;
103 }
104
112 template<typename T>
113 T Deserialize() const
114 {
115 return impl.Deserialize<T>();
116 }
117
126 template<typename T>
127 T GetField(const char* name) const
128 {
129 return impl.GetField<T>(name);
130 }
131
139 bool HasField(const char* name) const
140 {
141 return impl.HasField(name);
142 }
143
144 private:
146 impl::binary::BinaryObjectImpl impl;
147 };
148
149 /* Specialization */
150 template<>
151 inline BinaryObject BinaryObject::GetField(const char* name) const
152 {
153 return BinaryObject(impl.GetField<impl::binary::BinaryObjectImpl>(name));
154 }
155 }
156 }
157
158 #endif //_IGNITE_BINARY_BINARY_OBJECT
ignite::binary::BinaryObject::BinaryObject
BinaryObject(const BinaryObject &other)
Copy constructor.
Definition: binary_object.h:86
ignite::binary::BinaryObject::HasField
bool HasField(const char *name) const
Check if the binary object has the specified field.
Definition: binary_object.h:139
ignite::binary::BinaryObject::operator=
BinaryObject & operator=(const BinaryObject &other)
Assignment operator.
Definition: binary_object.h:98
ignite::binary::BinaryObject::Deserialize
T Deserialize() const
Deserialize object.
Definition: binary_object.h:113
ignite::binary::BinaryObject
Binary object.
Definition: binary_object.h:48
ignite::binary::BinaryObject::GetField
T GetField(const char *name) const
Get field.
Definition: binary_object.h:127
ignite
Apache Ignite API.
Definition: cache.h:48