00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef GRIDCLIENT_PROTOBUFF_MARSHALLER_HPP_INCLUDED
00011 #define GRIDCLIENT_PROTOBUFF_MARSHALLER_HPP_INCLUDED
00012
00013 #include <vector>
00014
00015 #include "gridgain/impl/marshaller/protobuf/ClientMessages.pb.h"
00016 #include "gridgain/gridclientnodemetricsbean.hpp"
00017 #include "gridgain/impl/cmd/gridclientmessageauthrequestcommand.hpp"
00018 #include "gridgain/impl/cmd/gridclientmessageauthresult.hpp"
00019 #include "gridgain/impl/cmd/gridclientmessagelogrequestcommand.hpp"
00020 #include "gridgain/impl/cmd/gridclientmessagelogresult.hpp"
00021 #include "gridgain/impl/cmd/gridclientmessagetopologyrequestcommand.hpp"
00022 #include "gridgain/impl/cmd/gridclientmessagetopologyresult.hpp"
00023 #include "gridgain/impl/cmd/gridclientmessagecacheresult.hpp"
00024 #include "gridgain/impl/cmd/gridclientmessagecacherequestcommand.hpp"
00025 #include "gridgain/impl/cmd/gridclientmessagecachemodifyresult.hpp"
00026 #include "gridgain/impl/cmd/gridclientmessagecachemetricsresult.hpp"
00027 #include "gridgain/impl/cmd/gridclientmessagecachegetresult.hpp"
00028 #include "gridgain/impl/cmd/gridclientmessagetaskrequestcommand.hpp"
00029 #include "gridgain/impl/cmd/gridclientmessagetaskresult.hpp"
00030 #include "gridgain/impl/marshaller/protobuf/gridclientobjectwrapperconvertor.hpp"
00031
00032 using namespace org::gridgain::grid::kernal::processors::rest::client::message;
00033
00037 class GridClientProtobufMarshaller {
00038 public:
00045 static void wrap(const GridAuthenticationRequestCommand& req, ObjectWrapper& obj);
00046
00053 static void unwrap(const ObjectWrapper& obj, GridClientMessageAuthenticationResult& resp);
00054
00061 static void wrap(const GridLogRequestCommand& req, ObjectWrapper& obj);
00062
00069 static void unwrap(const ObjectWrapper& obj, GridClientMessageLogResult& resp);
00070
00077 static void wrap(const GridTopologyRequestCommand& req, ObjectWrapper& obj);
00078
00085 static void unwrap(const ObjectWrapper& obj, GridClientMessageTopologyResult& resp);
00086
00093 static void wrap(const GridCacheRequestCommand& req, ObjectWrapper& obj);
00094
00101 static void unwrap(const ObjectWrapper& obj, GridClientMessageCacheModifyResult& resp);
00102
00109 static void unwrap(const ObjectWrapper& obj, GridClientMessageCacheMetricResult& resp);
00110
00117 static void unwrap(const ObjectWrapper& obj, GridClientMessageCacheGetResult&);
00118
00125 static void wrap(const GridTaskRequestCommand& req, ObjectWrapper& obj);
00126
00133 static void unwrap(const ObjectWrapper& obj, GridClientMessageTaskResult& resp);
00134
00141 static void marshal(const ::google::protobuf::Message& msg, std::vector<int8_t>& bytes);
00142
00149 static void marshal(const std::string& str, std::vector<int8_t>& bytes);
00150
00157 static void marshal(int64_t i64, std::vector<int8_t>& bytes);
00158
00165 static void marshal(const GridClientUuid& uuid, std::vector<int8_t>& bytes);
00166
00173 static void unmarshal(const std::vector<int8_t>& bytes, ::google::protobuf::Message& msg);
00174
00175 static const std::string& msgType2Str(const ObjectWrapper& msg){
00176 return ObjectWrapperType_Name(msg.type());
00177 }
00178
00187 static void marshalMsg(const ::google::protobuf::Message& msg, int8_t*& pBuffer, unsigned long & bufferLength);
00188 };
00189
00195 class ProtobufCollInserter {
00196 public:
00202 ProtobufCollInserter(::Collection& coll) :
00203 protoColl(coll) {}
00204
00210 void operator() (GridClientVariant val) {
00211 ObjectWrapper* item = protoColl.add_item();
00212
00213 GridClientObjectWrapperConvertor::wrapSimpleType(val, *item);
00214 }
00215 private:
00216 ::Collection& protoColl;
00217 };
00218
00219 #endif