00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef GRID_CLIENT_MESSAGE_CACHE_COMMAND_HPP
00011 #define GRID_CLIENT_MESSAGE_CACHE_COMMAND_HPP
00012
00013 #include <string>
00014 #include <exception>
00015 #include <map>
00016 #include <set>
00017 #include <cassert>
00018
00019 #include "gridgain/gridclientvariant.hpp"
00020 #include "gridgain/gridclientcacheflag.hpp"
00021 #include "gridgain/impl/cmd/gridclientmessagecommand.hpp"
00022
00026 class GridCacheRequestCommand : public GridClientMessageCommand {
00027 public:
00029 typedef std::map<GridClientVariant, GridClientVariant> TKeyValueMap;
00030
00034 enum GridCacheOperation {
00036 PUT= 0x01,
00037
00039 PUT_ALL= 0x02,
00040
00042 GET = 0x03,
00043
00045 GET_ALL = 0x04,
00046
00048 RMV = 0x05,
00049
00051 RMV_ALL = 0x06,
00052
00054 ADD = 0x07,
00055
00057 REPLACE = 0x08,
00058
00060 CAS = 0x09,
00061
00063 METRICS = 0x0A
00064 };
00065
00072 static GridCacheOperation findByOperationCode(const int& val) {
00073 switch (val) {
00074 case 1:
00075 return PUT;
00076 case 2:
00077 return PUT_ALL;
00078 case 3:
00079 return GET;
00080 case 4:
00081 return GET_ALL;
00082 case 5:
00083 return RMV;
00084 case 6:
00085 return RMV_ALL;
00086 case 7:
00087 return ADD;
00088 case 8:
00089 return REPLACE;
00090 case 9:
00091 return CAS;
00092 case 10:
00093 return METRICS;
00094 default: {
00095 assert(false);
00096
00097 throw new std::exception();
00098 }break;
00099 }
00100 return PUT;
00101 }
00102
00108 GridCacheRequestCommand(GridCacheOperation op) {
00109 this->op = op;
00110 }
00111
00115 GridCacheOperation getOperation() const {
00116 return op;
00117 }
00118
00124 std::string getCacheName() const {
00125 return cacheName;
00126 }
00127
00133 void setCacheName(const std::string& cacheName) {
00134 this->cacheName = cacheName;
00135 }
00136
00140 GridClientVariant getKey() const {
00141 return key;
00142 }
00143
00147 void setKey(const GridClientVariant& key) {
00148 this->key = key;
00149 }
00150
00154 GridClientVariant getValue() const {
00155 return val;
00156 }
00157
00161 void setValue(const GridClientVariant& val) {
00162 this->val = val;
00163 }
00164
00168 GridClientVariant getValue2() const {
00169 return val2;
00170 }
00171
00175 void setValue2(const GridClientVariant& val2) {
00176 this->val2 = val2;
00177 }
00178
00182 TKeyValueMap getValues() const {
00183 return vals;
00184 }
00185
00189 void setValues(const TKeyValueMap& vals) {
00190 this->vals = vals;
00191 }
00192
00196 void setFlags(const std::set<GridClientCacheFlag>& flags) {
00197 this->flags = flags;
00198 }
00199
00203 std::set<GridClientCacheFlag> getFlags() const {
00204 return flags;
00205 }
00206
00207 private:
00209 GridCacheOperation op;
00210
00212 std::string cacheName;
00213
00215 GridClientVariant key;
00216
00218 GridClientVariant val;
00219
00221 GridClientVariant val2;
00222
00224 TKeyValueMap vals;
00225
00227 std::set<GridClientCacheFlag> flags;
00228 };
00229
00230 #endif