ONE - On-device Neural Engine
Loading...
Searching...
No Matches
Visitor.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef _MIR_VISITOR_H_
18#define _MIR_VISITOR_H_
19
20namespace mir
21{
22
23// Forward declare operations as we don't need anything but references
24namespace ops
25{
26#define HANDLE_OP(OpType, OpClass) class OpClass;
27#include "mir/Operations.inc"
28#undef HANDLE_OP
29} // namespace ops
30
31class Operation;
32
38{
39public:
40#define HANDLE_OP(OpType, OpClass) virtual void visit(ops::OpClass &) = 0;
41#include "Operations.inc"
42#undef HANDLE_OP
43
44 virtual ~IVisitor() = default;
45};
46
50class Visitor : public IVisitor
51{
52public:
53#define HANDLE_OP(OpType, OpClass) void visit(ops::OpClass &) override;
54#include "Operations.inc"
55#undef HANDLE_OP
56
57protected:
58 virtual void visit_fallback(Operation &) {}
59};
60
61} // namespace mir
62
63#endif //_MIR_VISITOR_H_
Interface for visitors Use in MIR component if you want to enforce to implement visits for all operat...
Definition Visitor.h:38
virtual ~IVisitor()=default
Base visitor with empty fallback function.
Definition Visitor.h:51
virtual void visit_fallback(Operation &)
Definition Visitor.h:58