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 _STOC_RDBTDP_TDENUMERATION_HXX
25 #define _STOC_RDBTDP_TDENUMERATION_HXX
26 
27 #include <list>
28 #include <osl/mutex.hxx>
29 #include <rtl/ref.hxx>
30 #include <registry/refltype.hxx>
31 #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
32 #include <com/sun/star/reflection/InvalidTypeNameException.hpp>
33 #include <com/sun/star/reflection/NoSuchTypeNameException.hpp>
34 #include <com/sun/star/reflection/TypeDescriptionSearchDepth.hpp>
35 #include <com/sun/star/reflection/XTypeDescriptionEnumeration.hpp>
36 #include <com/sun/star/uno/Sequence.hxx>
37 #include <com/sun/star/uno/TypeClass.hpp>
38 #include <cppuhelper/implbase1.hxx>
39 #include "base.hxx"
40 
41 namespace stoc_rdbtdp
42 {
43 
44 typedef ::std::list< ::com::sun::star::uno::Reference<
45     ::com::sun::star::reflection::XTypeDescription > > TypeDescriptionList;
46 
47 class TypeDescriptionEnumerationImpl
48     : public cppu::WeakImplHelper1<
49                 com::sun::star::reflection::XTypeDescriptionEnumeration >
50 {
51 public:
52     static rtl::Reference< TypeDescriptionEnumerationImpl > createInstance(
53         const ::com::sun::star::uno::Reference<
54             ::com::sun::star::container::XHierarchicalNameAccess > & xTDMgr,
55         const rtl::OUString & rModuleName,
56         const ::com::sun::star::uno::Sequence<
57             ::com::sun::star::uno::TypeClass > & rTypes,
58         ::com::sun::star::reflection::TypeDescriptionSearchDepth eDepth,
59         const RegistryKeyList & rBaseKeys )
60             throw ( ::com::sun::star::reflection::NoSuchTypeNameException,
61                     ::com::sun::star::reflection::InvalidTypeNameException,
62                     ::com::sun::star::uno::RuntimeException );
63 
64     virtual ~TypeDescriptionEnumerationImpl();
65 
66     // XEnumeration (base of XTypeDescriptionEnumeration)
67     virtual sal_Bool SAL_CALL hasMoreElements()
68         throw ( ::com::sun::star::uno::RuntimeException );
69     virtual ::com::sun::star::uno::Any SAL_CALL nextElement()
70         throw ( ::com::sun::star::container::NoSuchElementException,
71                 ::com::sun::star::lang::WrappedTargetException,
72                 ::com::sun::star::uno::RuntimeException );
73 
74     // XTypeDescriptionEnumeration
75     virtual ::com::sun::star::uno::Reference<
76         ::com::sun::star::reflection::XTypeDescription > SAL_CALL
77     nextTypeDescription()
78         throw ( ::com::sun::star::container::NoSuchElementException,
79                 ::com::sun::star::uno::RuntimeException );
80 
81 private:
82     // Note: keys must be open (XRegistryKey->openKey(...)).
83     TypeDescriptionEnumerationImpl(
84         const ::com::sun::star::uno::Reference<
85             ::com::sun::star::container::XHierarchicalNameAccess > & xTDMgr,
86         const RegistryKeyList & rModuleKeys,
87         const ::com::sun::star::uno::Sequence<
88             ::com::sun::star::uno::TypeClass > & rTypes,
89         ::com::sun::star::reflection::TypeDescriptionSearchDepth eDepth );
90 
91     static bool match( ::RTTypeClass eType1,
92                        ::com::sun::star::uno::TypeClass eType2 );
93     bool queryMore();
94     ::com::sun::star::uno::Reference<
95         ::com::sun::star::reflection::XTypeDescription > queryNext();
96 
97     // members
98     osl::Mutex m_aMutex;
99     RegistryKeyList     m_aModuleKeys;
100     RegistryKeyList     m_aCurrentModuleSubKeys;
101     TypeDescriptionList m_aTypeDescs;
102     ::com::sun::star::uno::Sequence<
103         ::com::sun::star::uno::TypeClass > m_aTypes;
104     ::com::sun::star::reflection::TypeDescriptionSearchDepth m_eDepth;
105     ::com::sun::star::uno::Reference<
106         ::com::sun::star::container::XHierarchicalNameAccess > m_xTDMgr;
107 };
108 
109 } // namespace stoc_rdbtdp
110 
111 #endif /* _STOC_RDBTDP_TDENUMERATION_HXX */
112 
113