31 #ifndef CORE_CP_COMMANDS_H_
32 #define CORE_CP_COMMANDS_H_
43 typedef std::vector<uint8_t> Bytes;
50 explicit Action(std::string name);
51 void add_param(Bytes param);
53 const std::vector<Bytes> & get_params()
const;
54 const std::string & get_name()
const;
57 std::vector<Bytes> params;
68 virtual void print(std::ostream & os)
const = 0;
71 const Bytes & get_data()
const;
72 virtual size_t get_prefix_len()
const;
73 virtual const Bytes & get_mask()
const;
74 virtual Type get_type()
const = 0;
83 void print(std::ostream & os)
const override;
85 Type get_type()
const override;
90 LpmKey(Bytes data,
size_t prefix_len);
91 void print(std::ostream & os)
const override;
92 virtual ~
LpmKey() =
default;
93 size_t get_prefix_len()
const override;
94 Type get_type()
const override;
97 const size_t prefix_len;
103 void print(std::ostream & os)
const override;
105 const Bytes & get_mask()
const override;
106 Type get_type()
const override;
112 typedef std::unique_ptr<MatchKey> MatchKeyUPtr;
113 typedef std::vector<MatchKeyUPtr> MatchKeyContainer;
124 class Command :
public std::enable_shared_from_this<Command> {
126 virtual void print() = 0;
128 virtual void set_table_name(std::string s);
129 const std::string & get_table_name()
const;
133 std::shared_ptr<CommandResult> failure_result();
136 std::string table_name;
139 #define OVERRIDE_PROCESS() \
140 std::shared_ptr<CommandResult> process(CommandProcessor *p) override
144 void print()
override;
146 void set_match_keys(MatchKeyContainer * v);
147 void set_action(
Action * a);
149 const MatchKeyContainer & get_keys()
const;
150 const Action & get_action()
const;
154 std::shared_ptr<CommandResult> success_result(
size_t handle);
157 std::unique_ptr<MatchKeyContainer> keys;
158 std::unique_ptr<Action> action;
163 void print()
override;
165 void set_handle(
size_t h);
166 size_t get_handle()
const;
167 void set_action(
Action * a);
168 const Action & get_action()
const;
171 std::shared_ptr<CommandResult> success_result();
175 std::unique_ptr<Action> action;
180 void print()
override;
182 void set_handle(
size_t h);
183 size_t get_handle()
const;
186 std::shared_ptr<CommandResult> success_result();
194 void print()
override;
199 #undef OVERRIDE_PROCESS
203 #define DECLARE_PROCESS(TYPE) \
205 virtual std::shared_ptr<CommandResult> process(TYPE* t) = 0
209 std::shared_ptr<CommandResult>
210 accept_command(
const std::shared_ptr<Command> & cmd);
218 #undef DECLARE_PROCESS
223 #define OVERRIDE_PROCESS() \
224 void process(ResultProcessor *p) override
234 const std::shared_ptr<Command> command;
242 InsertResult(std::shared_ptr<Command> cmd,
size_t handle);
252 using CommandResult::CommandResult;
260 using CommandResult::CommandResult;
268 using CommandResult::CommandResult;
270 const std::string message;
272 #undef OVERRIDE_PROCESS
274 #define DECLARE_PROCESS(TYPE) \
276 virtual void process(TYPE* t) = 0
280 void accept_result(
const std::shared_ptr<CommandResult> & res);
288 #undef DECLARE_PROCESS
294 std::ostream & operator<< (std::ostream & os,
const pfp::cp::Bytes & b);
297 #endif // CORE_CP_COMMANDS_H_
Definition: Commands.h:255
Definition: Commands.h:207
Definition: Commands.h:80
Definition: Commands.h:161
Definition: Commands.h:263
Definition: Commands.h:100
Definition: Commands.h:237
Definition: Commands.h:60
Definition: Commands.h:278
Definition: Commands.h:48
Definition: Commands.h:226
Definition: Commands.h:247
Definition: Commands.h:178
Definition: Commands.h:192
Definition: Commands.h:142
Definition: Commands.h:88
Definition: Commands.h:124
PacketBase.h.
Definition: ConfigurationParameters.cpp:36