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 
72  BinaryObject(impl::interop::InteropMemory& mem, int32_t start,
73  impl::binary::BinaryIdResolver* idRslvr, impl::binary::BinaryTypeManager* metaMgr) :
74  impl(mem, start, idRslvr, metaMgr)
75  {
76  // No-op.
77  }
79 
85  BinaryObject(const BinaryObject& other) :
86  impl(other.impl)
87  {
88  // No-op.
89  }
90 
98  {
99  impl = other.impl;
100 
101  return *this;
102  }
103 
111  template<typename T>
112  T Deserialize() const
113  {
114  return impl.Deserialize<T>();
115  }
116 
125  template<typename T>
126  T GetField(const char* name) const
127  {
128  return impl.GetField<T>(name);
129  }
130 
138  bool HasField(const char* name) const
139  {
140  return impl.HasField(name);
141  }
142 
143  private:
145  impl::binary::BinaryObjectImpl impl;
146  };
147 
148  /* Specialization */
149  template<>
150  inline BinaryObject BinaryObject::GetField(const char* name) const
151  {
152  return BinaryObject(impl.GetField<impl::binary::BinaryObjectImpl>(name));
153  }
154  }
155 }
156 
157 #endif //_IGNITE_BINARY_BINARY_OBJECT
BinaryObject(const BinaryObject &other)
Copy constructor.
Definition: binary_object.h:85
bool HasField(const char *name) const
Check if the binary object has the specified field.
Definition: binary_object.h:138
BinaryObject & operator=(const BinaryObject &other)
Assignment operator.
Definition: binary_object.h:97
T Deserialize() const
Deserialize object.
Definition: binary_object.h:112
Binary object.
Definition: binary_object.h:48
T GetField(const char *name) const
Get field.
Definition: binary_object.h:126
Apache Ignite API.
Definition: cache.h:48