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 24 #ifndef INCLUDED_CODEMAKER_DEPENDENCIES_HXX 25 #define INCLUDED_CODEMAKER_DEPENDENCIES_HXX 26 27 #include "rtl/string.hxx" 28 29 #include <hash_map> 30 31 namespace rtl { class OUString; } 32 class TypeManager; 33 34 /// @HTML 35 36 namespace codemaker { 37 38 /** 39 A simple class to track which other types a given type depends on. 40 41 <p>This class is not multi-thread–safe.</p> 42 */ 43 class Dependencies { 44 public: 45 /** 46 Flags to distinguish whether or not one type depends on another type 47 because the second is a direct base of the first. 48 */ 49 enum Kind { KIND_NO_BASE, KIND_BASE }; 50 51 typedef std::hash_map< rtl::OString, Kind, rtl::OStringHash > Map; 52 53 /** 54 Constructs the dependencies for a given type. 55 56 <p>If the given type is not successfully available at the given type 57 manager, <code>isValid()</code> will return <code>false</code>.</p> 58 59 @param manager a type manager, to obtain information about the given type 60 61 @param type the UNO type registry name of an enum type, plain struct 62 type, polymorphic struct type template, exception type, interface type, 63 typedef, module, constant group, service, or singleton 64 */ 65 Dependencies(TypeManager const & manager, rtl::OString const & type); 66 67 ~Dependencies(); 68 69 /** 70 Add a special dependency (which is not obvious from the type's data 71 available at the type manager). 72 73 @param type a UNO type registry name 74 */ add(rtl::OString const & type)75 void add(rtl::OString const & type) { insert(type, false); } 76 isValid() const77 bool isValid() const { return m_valid; } 78 getMap() const79 Map const & getMap() const { return m_map; } 80 hasVoidDependency() const81 bool hasVoidDependency() const { return m_voidDependency; } 82 hasBooleanDependency() const83 bool hasBooleanDependency() const { return m_booleanDependency; } 84 hasByteDependency() const85 bool hasByteDependency() const { return m_byteDependency; } 86 hasShortDependency() const87 bool hasShortDependency() const { return m_shortDependency; } 88 hasUnsignedShortDependency() const89 bool hasUnsignedShortDependency() const 90 { return m_unsignedShortDependency; } 91 hasLongDependency() const92 bool hasLongDependency() const { return m_longDependency; } 93 hasUnsignedLongDependency() const94 bool hasUnsignedLongDependency() const { return m_unsignedLongDependency; } 95 hasHyperDependency() const96 bool hasHyperDependency() const { return m_hyperDependency; } 97 hasUnsignedHyperDependency() const98 bool hasUnsignedHyperDependency() const 99 { return m_unsignedHyperDependency; } 100 hasFloatDependency() const101 bool hasFloatDependency() const { return m_floatDependency; } 102 hasDoubleDependency() const103 bool hasDoubleDependency() const { return m_doubleDependency; } 104 hasCharDependency() const105 bool hasCharDependency() const { return m_charDependency; } 106 hasStringDependency() const107 bool hasStringDependency() const { return m_stringDependency; } 108 hasTypeDependency() const109 bool hasTypeDependency() const { return m_typeDependency; } 110 hasAnyDependency() const111 bool hasAnyDependency() const { return m_anyDependency; } 112 hasSequenceDependency() const113 bool hasSequenceDependency() const { return m_sequenceDependency; } 114 115 private: 116 Dependencies(Dependencies &); // not implemented 117 void operator =(Dependencies); // not implemented 118 119 void insert(rtl::OUString const & type, bool base); 120 121 void insert(rtl::OString const & type, bool base); 122 123 Map m_map; 124 bool m_valid; 125 bool m_voidDependency; 126 bool m_booleanDependency; 127 bool m_byteDependency; 128 bool m_shortDependency; 129 bool m_unsignedShortDependency; 130 bool m_longDependency; 131 bool m_unsignedLongDependency; 132 bool m_hyperDependency; 133 bool m_unsignedHyperDependency; 134 bool m_floatDependency; 135 bool m_doubleDependency; 136 bool m_charDependency; 137 bool m_stringDependency; 138 bool m_typeDependency; 139 bool m_anyDependency; 140 bool m_sequenceDependency; 141 }; 142 143 } 144 145 #endif // INCLUDED_CODEMAKER_DEPENDENCIES_HXX 146