Hazelcast C++ Client
ClassDefinition.h
1 /*
2  * Copyright (c) 2008-2018, 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 //
17 // ClassDefinition.h
18 // Server
19 //
20 // Created by sancar koyunlu on 1/10/13.
21 // Copyright (c) 2013 sancar koyunlu. All rights reserved.
22 //
23 
24 #ifndef HAZELCAST_CLASS_DEFINITION
25 #define HAZELCAST_CLASS_DEFINITION
26 
27 
28 #include "hazelcast/client/serialization/FieldDefinition.h"
29 #include <map>
30 #include <vector>
31 #include <memory>
32 #include <boost/shared_ptr.hpp>
33 #include <ostream>
34 
35 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
36 #pragma warning(push)
37 #pragma warning(disable: 4251) //for dll export
38 #endif
39 
40 namespace hazelcast {
41  namespace client {
42  namespace serialization {
43  namespace pimpl {
44  class DataInput;
45 
46  class DataOutput;
47  }
48 
57  class HAZELCAST_API ClassDefinition {
58  public:
59 
64 
71  ClassDefinition(int factoryId, int classId, int version);
72 
77  void addFieldDef(FieldDefinition& fieldDefinition);
78 
83  bool hasField(char const *fieldName) const;
84 
90  const FieldDefinition& getField(const char *fieldName) const;
91 
97  FieldType getFieldType(const char *fieldName) const;
98 
102  int getFieldCount() const;
103 
107  int getFactoryId() const;
108 
112  int getClassId() const;
113 
117  int getVersion() const;
118 
123  void setVersionIfNotSet(int version);
124 
129  void writeData(pimpl::DataOutput& dataOutput);
130 
135  void readData(pimpl::DataInput& dataInput);
136 
137  bool operator==(const ClassDefinition &rhs) const;
138 
139  bool operator!=(const ClassDefinition &rhs) const;
140 
141  friend std::ostream &operator<<(std::ostream &os, const ClassDefinition &definition);
142 
143  private:
144  int factoryId;
145  int classId;
146  int version;
147 
149 
150  ClassDefinition& operator=(const ClassDefinition& rhs);
151 
152  std::map<std::string, FieldDefinition> fieldDefinitionsMap;
153 
154  std::auto_ptr<std::vector<byte> > binary;
155 
156  };
157  }
158  }
159 }
160 
161 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
162 #pragma warning(pop)
163 #endif
164 
165 
166 #endif /* HAZELCAST_CLASS_DEFINITION */
167 
ClassDefinition defines a class schema for Portable classes.
Definition: ClassDefinition.h:57
PN (Positive-Negative) CRDT counter.
Definition: MapEntryView.h:32
FieldDefinition defines name, type, index of a field.
Definition: FieldDefinition.h:48