Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 : #ifndef _IDLC_ASTINTERFACE_HXX_
20 : #define _IDLC_ASTINTERFACE_HXX_
21 :
22 : #include <idlc/asttype.hxx>
23 : #include <idlc/astscope.hxx>
24 : #include "idlc/inheritedinterface.hxx"
25 :
26 : #include <map>
27 : #include <vector>
28 :
29 3 : class AstInterface : public AstType
30 : , public AstScope
31 : {
32 : public:
33 : typedef std::vector< InheritedInterface > InheritedInterfaces;
34 :
35 : typedef std::vector< AstInterface const * > DoubleInterfaceDeclarations;
36 :
37 : struct DoubleMemberDeclaration {
38 : AstDeclaration const * first;
39 : AstDeclaration const * second;
40 : };
41 :
42 : typedef std::vector< DoubleMemberDeclaration > DoubleMemberDeclarations;
43 :
44 538 : struct DoubleDeclarations {
45 : DoubleInterfaceDeclarations interfaces;
46 : DoubleMemberDeclarations members;
47 : };
48 :
49 : AstInterface(
50 : const OString& name, AstInterface const * pInherits,
51 : AstScope* pScope);
52 : virtual ~AstInterface();
53 :
54 0 : InheritedInterfaces const & getAllInheritedInterfaces() const
55 0 : { return m_inheritedInterfaces; }
56 :
57 238 : bool hasMandatoryInheritedInterfaces() const
58 238 : { return m_mandatoryInterfaces > 0; }
59 :
60 : void setForwarded(bool bForwarded)
61 : { m_bForwarded = bForwarded; }
62 : bool isForwarded()
63 : { return m_bForwarded; }
64 : void setForwardedInSameFile(bool bForwarded)
65 : { m_bForwardedInSameFile = bForwarded; }
66 : bool isForwardedInSameFile()
67 : { return m_bForwardedInSameFile; }
68 :
69 567 : void setDefined() { m_bIsDefined = true; }
70 431 : bool isDefined() const
71 431 : { return m_bIsDefined; }
72 :
73 83 : bool usesSingleInheritance() const { return m_bSingleInheritance; }
74 :
75 : DoubleDeclarations checkInheritedInterfaceClashes(
76 : AstInterface const * ifc, bool optional) const;
77 :
78 : void addInheritedInterface(
79 : AstType const * ifc, bool optional,
80 : OUString const & documentation);
81 :
82 : DoubleMemberDeclarations checkMemberClashes(
83 : AstDeclaration const * member) const;
84 :
85 : void addMember(AstDeclaration /*TODO: const*/ * member);
86 :
87 : void forwardDefined(AstInterface const & def);
88 :
89 : virtual bool dump(RegistryKey& rKey) SAL_OVERRIDE;
90 :
91 : private:
92 : enum InterfaceKind {
93 : INTERFACE_INDIRECT_OPTIONAL, INTERFACE_DIRECT_OPTIONAL,
94 : INTERFACE_INDIRECT_MANDATORY, INTERFACE_DIRECT_MANDATORY };
95 :
96 7358 : struct VisibleMember {
97 1856 : explicit VisibleMember(AstDeclaration const * theMandatory = 0):
98 1856 : mandatory(theMandatory) {}
99 :
100 : typedef std::map< OString, AstDeclaration const * > Optionals;
101 :
102 : AstDeclaration const * mandatory;
103 : Optionals optionals;
104 : };
105 :
106 : typedef std::map< OString, InterfaceKind > VisibleInterfaces;
107 : typedef std::map< OString, VisibleMember > VisibleMembers;
108 :
109 : void checkInheritedInterfaceClashes(
110 : DoubleDeclarations & doubleDeclarations,
111 : std::set< OString > & seenInterfaces, AstInterface const * ifc,
112 : bool direct, bool optional, bool mainOptional) const;
113 :
114 : void checkMemberClashes(
115 : DoubleMemberDeclarations & doubleMembers, AstDeclaration const * member,
116 : bool checkOptional) const;
117 :
118 : void addVisibleInterface(
119 : AstInterface const * ifc, bool direct, bool optional);
120 :
121 : void addOptionalVisibleMembers(AstInterface const * ifc);
122 :
123 : bool increment(sal_uInt16 * counter, char const * sort) const;
124 :
125 : InheritedInterfaces m_inheritedInterfaces;
126 : InheritedInterfaces::size_type m_mandatoryInterfaces;
127 : bool m_bIsDefined;
128 : bool m_bForwarded;
129 : bool m_bForwardedInSameFile;
130 : bool m_bSingleInheritance;
131 : VisibleInterfaces m_visibleInterfaces;
132 : VisibleMembers m_visibleMembers;
133 : };
134 :
135 : #endif // _IDLC_ASTINTERFACE_HXX_
136 :
137 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|