Hazelcast C++ Client
TypedData.h
1 /*
2  * Copyright (c) 2008-2017, Hazelcast, Inc. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #ifndef HAZELCAST_CLIENT_TYPEDDATA_H_
17 #define HAZELCAST_CLIENT_TYPEDDATA_H_
18 
19 #include <memory>
20 
21 #include "hazelcast/util/HazelcastDll.h"
22 #include "hazelcast/client/serialization/pimpl/SerializationService.h"
23 
24 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
25 #pragma warning(push)
26 #pragma warning(disable: 4251) //for dll export
27 #endif
28 
29 namespace hazelcast {
30  namespace client {
31  namespace serialization {
32  namespace pimpl {
33  class Data;
34  }
35  }
40  class HAZELCAST_API TypedData {
41  public:
42  TypedData();
43 
44  TypedData(std::auto_ptr<serialization::pimpl::Data> data,
45  serialization::pimpl::SerializationService &serializationService);
46 
47  TypedData(const TypedData &rhs);
48 
49  TypedData &operator=(const TypedData& rhs);
50 
51  virtual ~TypedData();
52 
57  const serialization::pimpl::ObjectType getType() const;
58 
68  template <typename T>
69  std::auto_ptr<T> get() const {
70  return ss->toObject<T>(data.get());
71  }
72 
77  const serialization::pimpl::Data *getData() const;
78 
79  private:
80  std::auto_ptr<serialization::pimpl::Data> data;
81  serialization::pimpl::SerializationService *ss;
82  };
83 
84  bool HAZELCAST_API operator<(const TypedData &lhs, const TypedData &rhs);
85  }
86 }
87 
88 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
89 #pragma warning(pop)
90 #endif
91 
92 #endif //HAZELCAST_CLIENT_TYPEDDATA_H_
93 
Definition: MapEntryView.h:32
TypedData class is a wrapper class for the serialized binary data.
Definition: TypedData.h:40