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_GENERATEDTYPESET_HXX
25 #define INCLUDED_CODEMAKER_GENERATEDTYPESET_HXX
26 
27 #include "rtl/string.hxx"
28 
29 #include <hash_set>
30 
31 /// @HTML
32 
33 namespace codemaker {
34 
35 /**
36    A simple class to track which types have already been processed by a code
37    maker.
38 
39    <p>This class is not multi-thread&ndash;safe.</p>
40  */
41 class GeneratedTypeSet {
42 public:
GeneratedTypeSet()43     GeneratedTypeSet() {}
44 
~GeneratedTypeSet()45     ~GeneratedTypeSet() {}
46 
47     /**
48        Add a type to the set of generated types.
49 
50        <p>If the type was already present, nothing happens.</p>
51 
52        @param type a UNO type registry name
53      */
add(rtl::OString const & type)54     void add(rtl::OString const & type) { m_set.insert(type); }
55 
56     /**
57        Checks whether a given type has already been generated.
58 
59        @param type a UNO type registry name
60 
61        @return true iff the given type has already been generated
62      */
contains(rtl::OString const & type) const63     bool contains(rtl::OString const & type) const
64     { return m_set.find(type) != m_set.end(); }
65 
66 private:
67     GeneratedTypeSet(GeneratedTypeSet &); // not implemented
68     void operator =(GeneratedTypeSet); // not implemented
69 
70     std::hash_set< rtl::OString, rtl::OStringHash > m_set;
71 };
72 
73 }
74 
75 #endif // INCLUDED_CODEMAKER_GENERATEDTYPESET_HXX
76