bmv2
Designing your own switch target with bmv2
Loading...
Searching...
No Matches
named_p4object.h
Go to the documentation of this file.
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
22
23#ifndef BM_BM_SIM_NAMED_P4OBJECT_H_
24#define BM_BM_SIM_NAMED_P4OBJECT_H_
25
27#include <memory>
28#include <string>
29#include <utility>
30
31namespace bm {
32
33using p4object_id_t = int;
34
40 public:
41 NamedP4Object(const std::string &name, p4object_id_t id)
42 : name(name), id(id) {}
43 NamedP4Object(const std::string &name, p4object_id_t id,
44 std::unique_ptr<SourceInfo> source_info)
45 : name(name), id(id), source_info(std::move(source_info)) {}
46
47 virtual ~NamedP4Object() { }
48
50 const std::string &get_name() const { return name; }
51
53 p4object_id_t get_id() const { return id; }
54
56 NamedP4Object(const NamedP4Object &other) = delete;
58 NamedP4Object &operator=(const NamedP4Object &other) = delete;
59
61 NamedP4Object(NamedP4Object &&other) = default;
64
65 const SourceInfo *get_source_info() const { return source_info.get(); }
66
67 protected:
68 std::string name;
69 p4object_id_t id;
70 std::unique_ptr<SourceInfo> source_info;
71};
72
73} // namespace bm
74
75#endif // BM_BM_SIM_NAMED_P4OBJECT_H_
Definition named_p4object.h:39
NamedP4Object & operator=(NamedP4Object &&other)=default
Default assignment operator.
NamedP4Object(NamedP4Object &&other)=default
Default move constructor.
p4object_id_t get_id() const
Get the compiler-provided id.
Definition named_p4object.h:53
NamedP4Object & operator=(const NamedP4Object &other)=delete
Deleted copy assignment operator.
const std::string & get_name() const
Get the name of the P4 instance.
Definition named_p4object.h:50
NamedP4Object(const NamedP4Object &other)=delete
Deleted copy constructor.