Hazelcast C++ Client
 All Classes Functions Variables Enumerations Enumerator Pages
ClassDefinition.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 //
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 
34 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
35 #pragma warning(push)
36 #pragma warning(disable: 4251) //for dll export
37 #endif
38 
39 namespace hazelcast {
40  namespace client {
41  namespace serialization {
42  namespace pimpl {
43  class DataInput;
44 
45  class DataOutput;
46  }
47 
56  class HAZELCAST_API ClassDefinition {
57  public:
58 
63 
70  ClassDefinition(int factoryId, int classId, int version);
71 
76  void addFieldDef(FieldDefinition& fieldDefinition);
77 
82  bool hasField(char const *fieldName) const;
83 
89  const FieldDefinition& getField(const char *fieldName) const;
90 
96  FieldType getFieldType(const char *fieldName) const;
97 
101  int getFieldCount() const;
102 
106  int getFactoryId() const;
107 
111  int getClassId() const;
112 
116  int getVersion() const;
117 
122  void setVersionIfNotSet(int version);
123 
128  void writeData(pimpl::DataOutput& dataOutput);
129 
134  void readData(pimpl::DataInput& dataInput);
135 
136  private:
137  int factoryId;
138  int classId;
139  int version;
140 
142 
143  ClassDefinition& operator=(const ClassDefinition& rhs);
144 
145  std::vector<FieldDefinition> fieldDefinitions;
146  std::map<std::string, FieldDefinition> fieldDefinitionsMap;
147 
148  std::auto_ptr<std::vector<byte> > binary;
149 
150  };
151  }
152  }
153 }
154 
155 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
156 #pragma warning(pop)
157 #endif
158 
159 
160 #endif /* HAZELCAST_CLASS_DEFINITION */
161 
ClassDefinition defines a class schema for Portable classes.
Definition: ClassDefinition.h:56
FieldDefinition defines name, type, index of a field.
Definition: FieldDefinition.h:47