1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 #ifndef _IDLC_ASTINTERFACE_HXX_ 24 #define _IDLC_ASTINTERFACE_HXX_ 25 26 #include <idlc/asttype.hxx> 27 #include <idlc/astscope.hxx> 28 #include "idlc/inheritedinterface.hxx" 29 30 #include <map> 31 #include <vector> 32 33 class AstInterface : public AstType 34 , public AstScope 35 { 36 public: 37 typedef std::vector< InheritedInterface > InheritedInterfaces; 38 39 typedef std::vector< AstInterface const * > DoubleInterfaceDeclarations; 40 41 struct DoubleMemberDeclaration { 42 AstDeclaration const * first; 43 AstDeclaration const * second; 44 }; 45 46 typedef std::vector< DoubleMemberDeclaration > DoubleMemberDeclarations; 47 48 struct DoubleDeclarations { 49 DoubleInterfaceDeclarations interfaces; 50 DoubleMemberDeclarations members; 51 }; 52 53 AstInterface( 54 const ::rtl::OString& name, AstInterface const * pInherits, 55 AstScope* pScope); 56 virtual ~AstInterface(); 57 getAllInheritedInterfaces() const58 InheritedInterfaces const & getAllInheritedInterfaces() const 59 { return m_inheritedInterfaces; } 60 hasMandatoryInheritedInterfaces() const61 bool hasMandatoryInheritedInterfaces() const 62 { return m_mandatoryInterfaces > 0; } 63 setForwarded(sal_Bool bForwarded)64 void setForwarded(sal_Bool bForwarded) 65 { m_bForwarded = bForwarded; } isForwarded()66 sal_Bool isForwarded() 67 { return m_bForwarded; } setForwardedInSameFile(sal_Bool bForwarded)68 void setForwardedInSameFile(sal_Bool bForwarded) 69 { m_bForwardedInSameFile = bForwarded; } isForwardedInSameFile()70 sal_Bool isForwardedInSameFile() 71 { return m_bForwardedInSameFile; } 72 setDefined()73 void setDefined() { m_bIsDefined = true; } isDefined() const74 sal_Bool isDefined() const 75 { return m_bIsDefined; } 76 usesSingleInheritance() const77 bool usesSingleInheritance() const { return m_bSingleInheritance; } 78 79 DoubleDeclarations checkInheritedInterfaceClashes( 80 AstInterface const * ifc, bool optional) const; 81 82 void addInheritedInterface( 83 AstType const * ifc, bool optional, 84 rtl::OUString const & documentation); 85 86 DoubleMemberDeclarations checkMemberClashes( 87 AstDeclaration const * member) const; 88 89 void addMember(AstDeclaration /*TODO: const*/ * member); 90 91 void forwardDefined(AstInterface const & def); 92 93 virtual sal_Bool dump(RegistryKey& rKey); 94 95 private: 96 enum InterfaceKind { 97 INTERFACE_INDIRECT_OPTIONAL, INTERFACE_DIRECT_OPTIONAL, 98 INTERFACE_INDIRECT_MANDATORY, INTERFACE_DIRECT_MANDATORY }; 99 100 struct VisibleMember { VisibleMemberAstInterface::VisibleMember101 explicit VisibleMember(AstDeclaration const * theMandatory = 0): 102 mandatory(theMandatory) {} 103 104 typedef std::map< rtl::OString, AstDeclaration const * > Optionals; 105 106 AstDeclaration const * mandatory; 107 Optionals optionals; 108 }; 109 110 typedef std::map< rtl::OString, InterfaceKind > VisibleInterfaces; 111 typedef std::map< rtl::OString, VisibleMember > VisibleMembers; 112 113 void checkInheritedInterfaceClashes( 114 DoubleDeclarations & doubleDeclarations, 115 std::set< rtl::OString > & seenInterfaces, AstInterface const * ifc, 116 bool optional, bool direct, bool mainOptional) const; 117 118 void checkMemberClashes( 119 DoubleMemberDeclarations & doubleMembers, AstDeclaration const * member, 120 bool checkOptional) const; 121 122 void addVisibleInterface( 123 AstInterface const * ifc, bool direct, bool optional); 124 125 void addOptionalVisibleMembers(AstInterface const * ifc); 126 127 bool increment(sal_uInt16 * counter, char const * sort) const; 128 129 InheritedInterfaces m_inheritedInterfaces; 130 InheritedInterfaces::size_type m_mandatoryInterfaces; 131 sal_Bool m_bIsDefined; 132 sal_Bool m_bForwarded; 133 sal_Bool m_bForwardedInSameFile; 134 bool m_bSingleInheritance; 135 VisibleInterfaces m_visibleInterfaces; 136 VisibleMembers m_visibleMembers; 137 }; 138 139 #endif // _IDLC_ASTINTERFACE_HXX_ 140