bmv2
Designing your own switch target with bmv2
action_entry.h
1 /* Copyright 2013-present Barefoot Networks, Inc.
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 /*
17  * Antonin Bas (antonin@barefootnetworks.com)
18  *
19  */
20 
21 #ifndef BM_BM_SIM_ACTION_ENTRY_H_
22 #define BM_BM_SIM_ACTION_ENTRY_H_
23 
24 #include <iosfwd>
25 #include <utility>
26 
27 #include "actions.h"
28 #include "control_flow.h"
29 
30 namespace bm {
31 
32 struct ActionEntry {
33  ActionEntry() { }
34 
35  ActionEntry(ActionFnEntry action_fn, const ControlFlowNode *next_node)
36  : action_fn(std::move(action_fn)), next_node(next_node) { }
37 
38  void dump(std::ostream *stream) const {
39  action_fn.dump(stream);
40  }
41 
42  void serialize(std::ostream *out) const;
43  void deserialize(std::istream *in, const P4Objects &objs);
44 
45  friend std::ostream& operator<<(std::ostream &out, const ActionEntry &e) {
46  e.dump(&out);
47  return out;
48  }
49 
50  ActionEntry(const ActionEntry &other) = default;
51  ActionEntry &operator=(const ActionEntry &other) = default;
52 
53  ActionEntry(ActionEntry &&other) /*noexcept*/ = default;
54  ActionEntry &operator=(ActionEntry &&other) /*noexcept*/ = default;
55 
56  ActionFnEntry action_fn{};
57  const ControlFlowNode *next_node{nullptr};
58 };
59 
60 } // namespace bm
61 
62 #endif // BM_BM_SIM_ACTION_ENTRY_H_
actions.h