Hazelcast C++ Client
 All Classes Functions Variables Enumerations Pages
ClassDefinitionBuilder.h
1 /*
2  * Copyright (c) 2008-2015, 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 // Created by sancar koyunlu on 21/07/14.
18 //
19 
20 
21 #ifndef HAZELCAST_ClassDefinitionBuilder
22 #define HAZELCAST_ClassDefinitionBuilder
23 
24 #include "hazelcast/util/HazelcastDll.h"
25 #include "hazelcast/client/serialization/ClassDefinition.h"
26 #include <vector>
27 #include <set>
28 
29 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
30 #pragma warning(push)
31 #pragma warning(disable: 4251) //for dll export
32 #endif
33 
34 namespace hazelcast {
35  namespace client {
36  namespace serialization {
37 
45  class HAZELCAST_API ClassDefinitionBuilder {
46  public:
47  ClassDefinitionBuilder(int factoryId, int classId, int version);
48 
49  ClassDefinitionBuilder(int factoryId, int classId);
50 
51  ClassDefinitionBuilder& addIntField(const std::string& fieldName);
52 
53  ClassDefinitionBuilder& addLongField(const std::string& fieldName);
54 
55  ClassDefinitionBuilder& addUTFField(const std::string& fieldName);
56 
57  ClassDefinitionBuilder& addBooleanField(const std::string& fieldName);
58 
59  ClassDefinitionBuilder& addByteField(const std::string& fieldName);
60 
61  ClassDefinitionBuilder& addCharField(const std::string& fieldName);
62 
63  ClassDefinitionBuilder& addDoubleField(const std::string& fieldName);
64 
65  ClassDefinitionBuilder& addFloatField(const std::string& fieldName);
66 
67  ClassDefinitionBuilder& addShortField(const std::string& fieldName);
68 
69  ClassDefinitionBuilder& addByteArrayField(const std::string& fieldName);
70 
71  ClassDefinitionBuilder& addCharArrayField(const std::string& fieldName);
72 
73  ClassDefinitionBuilder& addIntArrayField(const std::string& fieldName);
74 
75  ClassDefinitionBuilder& addLongArrayField(const std::string& fieldName);
76 
77  ClassDefinitionBuilder& addDoubleArrayField(const std::string& fieldName);
78 
79  ClassDefinitionBuilder& addFloatArrayField(const std::string& fieldName);
80 
81  ClassDefinitionBuilder& addShortArrayField(const std::string& fieldName);
82 
83  ClassDefinitionBuilder& addPortableField(const std::string& fieldName, boost::shared_ptr<ClassDefinition> def);
84 
85  ClassDefinitionBuilder& addPortableArrayField(const std::string& fieldName, boost::shared_ptr<ClassDefinition> def);
86 
87  ClassDefinitionBuilder& addField(FieldDefinition &fieldDefinition);
88 
89  boost::shared_ptr<ClassDefinition> build();
90 
91  int getFactoryId();
92 
93  int getClassId();
94 
95  int getVersion();
96 
97  private:
98  int factoryId;
99  int classId;
100  int version;
101  int index;
102  bool done;
103  std::vector<FieldDefinition> fieldDefinitions;
104 
105  void addField(const std::string& fieldName , FieldType const &fieldType);
106 
107  void check();
108  };
109  }
110  }
111 }
112 
113 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
114 #pragma warning(pop)
115 #endif
116 
117 #endif //HAZELCAST_ClassDefinitionBuilder
ClassDefinitionBuilder is used to build and register ClassDefinitions manually.
Definition: ClassDefinitionBuilder.h:45
FieldDefinition defines name, type, index of a field.
Definition: FieldDefinition.h:47