IDL compiler front-end library
Loading...
Searching...
No Matches
Interface.h
Go to the documentation of this file.
1
2/*
3* Nirvana IDL front-end library.
4*
5* This is a part of the Nirvana project.
6*
7* Author: Igor Popov
8*
9* Copyright (c) 2021 Igor Popov.
10*
11* This program is free software; you can redistribute it and/or modify
12* it under the terms of the GNU Lesser General Public License as published by
13* the Free Software Foundation; either version 3 of the License, or
14* (at your option) any later version.
15*
16* This program is distributed in the hope that it will be useful,
17* but WITHOUT ANY WARRANTY; without even the implied warranty of
18* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19* GNU General Public License for more details.
20*
21* You should have received a copy of the GNU Lesser General Public
22* License along with this library. If not, see <http://www.gnu.org/licenses/>.
23*
24* Send comments and/or bug reports to:
25* popov.nirvana@gmail.com
26*/
27#ifndef IDLFE_AST_INTERFACE_H_
28#define IDLFE_AST_INTERFACE_H_
29#pragma once
30
31#include "IV_Base.h"
32#include <unordered_set>
33
34namespace AST {
35
36class Interface;
37
40{
41public:
52
54 Kind interface_kind () const noexcept
55 {
56 return kind_;
57 }
58
59 InterfaceKind (Kind kind = UNCONSTRAINED) noexcept :
60 kind_ (kind)
61 {}
62
63private:
64 friend class Builder;
65
66 const char* interface_kind_name () const noexcept;
67
68private:
69 Kind kind_;
70};
71
73typedef std::vector <const Interface*> Interfaces;
74
92class Interface :
93 public IV_Base,
94 public InterfaceKind
95{
96public:
98 const Interfaces& bases () const noexcept
99 {
100 return bases_;
101 }
102
107
108private:
109 template <class T> friend class Ptr;
110 friend class Builder;
111 friend class ValueType;
112
113 void get_all_interfaces (IV_Bases& all) const;
114
115 Interface (Builder& builder, const SimpleDeclarator& name, InterfaceKind kind = InterfaceKind ()) :
116 IV_Base (Item::Kind::INTERFACE, builder, name),
117 InterfaceKind (kind)
118 {}
119
120 void add_base (const Interface& base)
121 {
122 bases_.push_back (&base);
123 }
124
125 void get_all_bases (std::unordered_set <const Interface*>& bset, Interfaces& bvec) const;
126
127private:
128 Interfaces bases_;
129};
130
136 public ItemWithId,
137 public InterfaceKind
138{
139private:
140 template <class T> friend class Ptr;
141
142 InterfaceDecl (Builder& builder, const SimpleDeclarator& name, InterfaceKind kind = InterfaceKind ()) :
143 ItemWithId (Item::Kind::INTERFACE_DECL, builder, name),
144 InterfaceKind (kind)
145 {}
146};
147
148}
149
150#endif
The AST builder.
Definition Builder.h:60
The common base for Interface and ValueType.
Definition IV_Base.h:42
Interface forward declaration.
Definition Interface.h:138
Interface definition.
Definition Interface.h:95
const Interfaces & bases() const noexcept
Definition Interface.h:98
Interfaces get_all_bases() const
The kind of interface.
Definition Interface.h:40
Kind
The kind of interface.
Definition Interface.h:44
@ UNCONSTRAINED
interface
Definition Interface.h:45
@ LOCAL
local interface
Definition Interface.h:47
@ PSEUDO
pseudo interface is Nirvana IDL extension
Definition Interface.h:50
@ ABSTRACT
abstract interface
Definition Interface.h:46
Kind interface_kind() const noexcept
Definition Interface.h:54
An AST item.
Definition Item.h:41
Items which have repository identifiers derive from this class.
Definition ItemWithId.h:42
AST item smart pointer.
Definition Item.h:134
The IDL simple declarator.
Definition Declarators.h:41
Value type definition.
Definition ValueType.h:61
Abstract Syntax Tree namespace.
Definition Array.h:34
std::vector< const Interface * > Interfaces
The sequence of interfaces.
Definition Interface.h:73