1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef INCLUDED_CODEMAKER_DEPENDENCIES_HXX 29 #define INCLUDED_CODEMAKER_DEPENDENCIES_HXX 30 31 #include "rtl/string.hxx" 32 33 #include <hash_map> 34 35 namespace rtl { class OUString; } 36 class TypeManager; 37 38 /// @HTML 39 40 namespace codemaker { 41 42 /** 43 A simple class to track which other types a given type depends on. 44 45 <p>This class is not multi-thread–safe.</p> 46 */ 47 class Dependencies { 48 public: 49 /** 50 Flags to distinguish whether or not one type depends on another type 51 because the second is a direct base of the first. 52 */ 53 enum Kind { KIND_NO_BASE, KIND_BASE }; 54 55 typedef std::hash_map< rtl::OString, Kind, rtl::OStringHash > Map; 56 57 /** 58 Constructs the dependencies for a given type. 59 60 <p>If the given type is not successfully available at the given type 61 manager, <code>isValid()</code> will return <code>false</code>.</p> 62 63 @param manager a type manager, to obtain information about the given type 64 65 @param type the UNO type registry name of an enum type, plain struct 66 type, polymorphic struct type template, exception type, interface type, 67 typedef, module, constant group, service, or singleton 68 */ 69 Dependencies(TypeManager const & manager, rtl::OString const & type); 70 71 ~Dependencies(); 72 73 /** 74 Add a special dependency (which is not obvious from the type's data 75 available at the type manager). 76 77 @param type a UNO type registry name 78 */ 79 void add(rtl::OString const & type) { insert(type, false); } 80 81 bool isValid() const { return m_valid; } 82 83 Map const & getMap() const { return m_map; } 84 85 bool hasVoidDependency() const { return m_voidDependency; } 86 87 bool hasBooleanDependency() const { return m_booleanDependency; } 88 89 bool hasByteDependency() const { return m_byteDependency; } 90 91 bool hasShortDependency() const { return m_shortDependency; } 92 93 bool hasUnsignedShortDependency() const 94 { return m_unsignedShortDependency; } 95 96 bool hasLongDependency() const { return m_longDependency; } 97 98 bool hasUnsignedLongDependency() const { return m_unsignedLongDependency; } 99 100 bool hasHyperDependency() const { return m_hyperDependency; } 101 102 bool hasUnsignedHyperDependency() const 103 { return m_unsignedHyperDependency; } 104 105 bool hasFloatDependency() const { return m_floatDependency; } 106 107 bool hasDoubleDependency() const { return m_doubleDependency; } 108 109 bool hasCharDependency() const { return m_charDependency; } 110 111 bool hasStringDependency() const { return m_stringDependency; } 112 113 bool hasTypeDependency() const { return m_typeDependency; } 114 115 bool hasAnyDependency() const { return m_anyDependency; } 116 117 bool hasSequenceDependency() const { return m_sequenceDependency; } 118 119 private: 120 Dependencies(Dependencies &); // not implemented 121 void operator =(Dependencies); // not implemented 122 123 void insert(rtl::OUString const & type, bool base); 124 125 void insert(rtl::OString const & type, bool base); 126 127 Map m_map; 128 bool m_valid; 129 bool m_voidDependency; 130 bool m_booleanDependency; 131 bool m_byteDependency; 132 bool m_shortDependency; 133 bool m_unsignedShortDependency; 134 bool m_longDependency; 135 bool m_unsignedLongDependency; 136 bool m_hyperDependency; 137 bool m_unsignedHyperDependency; 138 bool m_floatDependency; 139 bool m_doubleDependency; 140 bool m_charDependency; 141 bool m_stringDependency; 142 bool m_typeDependency; 143 bool m_anyDependency; 144 bool m_sequenceDependency; 145 }; 146 147 } 148 149 #endif // INCLUDED_CODEMAKER_DEPENDENCIES_HXX 150