1*1c4c525fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*1c4c525fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*1c4c525fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*1c4c525fSAndrew Rist  * distributed with this work for additional information
6*1c4c525fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*1c4c525fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*1c4c525fSAndrew Rist  * "License"); you may not use this file except in compliance
9*1c4c525fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*1c4c525fSAndrew Rist  *
11*1c4c525fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*1c4c525fSAndrew Rist  *
13*1c4c525fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*1c4c525fSAndrew Rist  * software distributed under the License is distributed on an
15*1c4c525fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*1c4c525fSAndrew Rist  * KIND, either express or implied.  See the License for the
17*1c4c525fSAndrew Rist  * specific language governing permissions and limitations
18*1c4c525fSAndrew Rist  * under the License.
19*1c4c525fSAndrew Rist  *
20*1c4c525fSAndrew Rist  *************************************************************/
21*1c4c525fSAndrew Rist 
22*1c4c525fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _STOC_RDBTDP_TDENUMERATION_HXX
25cdf0e10cSrcweir #define _STOC_RDBTDP_TDENUMERATION_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <list>
28cdf0e10cSrcweir #include <osl/mutex.hxx>
29cdf0e10cSrcweir #include <rtl/ref.hxx>
30cdf0e10cSrcweir #include <registry/refltype.hxx>
31cdf0e10cSrcweir #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
32cdf0e10cSrcweir #include <com/sun/star/reflection/InvalidTypeNameException.hpp>
33cdf0e10cSrcweir #include <com/sun/star/reflection/NoSuchTypeNameException.hpp>
34cdf0e10cSrcweir #include <com/sun/star/reflection/TypeDescriptionSearchDepth.hpp>
35cdf0e10cSrcweir #include <com/sun/star/reflection/XTypeDescriptionEnumeration.hpp>
36cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.hxx>
37cdf0e10cSrcweir #include <com/sun/star/uno/TypeClass.hpp>
38cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx>
39cdf0e10cSrcweir #include "base.hxx"
40cdf0e10cSrcweir 
41cdf0e10cSrcweir namespace stoc_rdbtdp
42cdf0e10cSrcweir {
43cdf0e10cSrcweir 
44cdf0e10cSrcweir typedef ::std::list< ::com::sun::star::uno::Reference<
45cdf0e10cSrcweir     ::com::sun::star::reflection::XTypeDescription > > TypeDescriptionList;
46cdf0e10cSrcweir 
47cdf0e10cSrcweir class TypeDescriptionEnumerationImpl
48cdf0e10cSrcweir     : public cppu::WeakImplHelper1<
49cdf0e10cSrcweir                 com::sun::star::reflection::XTypeDescriptionEnumeration >
50cdf0e10cSrcweir {
51cdf0e10cSrcweir public:
52cdf0e10cSrcweir     static rtl::Reference< TypeDescriptionEnumerationImpl > createInstance(
53cdf0e10cSrcweir         const ::com::sun::star::uno::Reference<
54cdf0e10cSrcweir             ::com::sun::star::container::XHierarchicalNameAccess > & xTDMgr,
55cdf0e10cSrcweir         const rtl::OUString & rModuleName,
56cdf0e10cSrcweir         const ::com::sun::star::uno::Sequence<
57cdf0e10cSrcweir             ::com::sun::star::uno::TypeClass > & rTypes,
58cdf0e10cSrcweir         ::com::sun::star::reflection::TypeDescriptionSearchDepth eDepth,
59cdf0e10cSrcweir         const RegistryKeyList & rBaseKeys )
60cdf0e10cSrcweir             throw ( ::com::sun::star::reflection::NoSuchTypeNameException,
61cdf0e10cSrcweir                     ::com::sun::star::reflection::InvalidTypeNameException,
62cdf0e10cSrcweir                     ::com::sun::star::uno::RuntimeException );
63cdf0e10cSrcweir 
64cdf0e10cSrcweir     virtual ~TypeDescriptionEnumerationImpl();
65cdf0e10cSrcweir 
66cdf0e10cSrcweir     // XEnumeration (base of XTypeDescriptionEnumeration)
67cdf0e10cSrcweir     virtual sal_Bool SAL_CALL hasMoreElements()
68cdf0e10cSrcweir         throw ( ::com::sun::star::uno::RuntimeException );
69cdf0e10cSrcweir     virtual ::com::sun::star::uno::Any SAL_CALL nextElement()
70cdf0e10cSrcweir         throw ( ::com::sun::star::container::NoSuchElementException,
71cdf0e10cSrcweir                 ::com::sun::star::lang::WrappedTargetException,
72cdf0e10cSrcweir                 ::com::sun::star::uno::RuntimeException );
73cdf0e10cSrcweir 
74cdf0e10cSrcweir     // XTypeDescriptionEnumeration
75cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference<
76cdf0e10cSrcweir         ::com::sun::star::reflection::XTypeDescription > SAL_CALL
77cdf0e10cSrcweir     nextTypeDescription()
78cdf0e10cSrcweir         throw ( ::com::sun::star::container::NoSuchElementException,
79cdf0e10cSrcweir                 ::com::sun::star::uno::RuntimeException );
80cdf0e10cSrcweir 
81cdf0e10cSrcweir private:
82cdf0e10cSrcweir     // Note: keys must be open (XRegistryKey->openKey(...)).
83cdf0e10cSrcweir     TypeDescriptionEnumerationImpl(
84cdf0e10cSrcweir         const ::com::sun::star::uno::Reference<
85cdf0e10cSrcweir             ::com::sun::star::container::XHierarchicalNameAccess > & xTDMgr,
86cdf0e10cSrcweir         const RegistryKeyList & rModuleKeys,
87cdf0e10cSrcweir         const ::com::sun::star::uno::Sequence<
88cdf0e10cSrcweir             ::com::sun::star::uno::TypeClass > & rTypes,
89cdf0e10cSrcweir         ::com::sun::star::reflection::TypeDescriptionSearchDepth eDepth );
90cdf0e10cSrcweir 
91cdf0e10cSrcweir     static bool match( ::RTTypeClass eType1,
92cdf0e10cSrcweir                        ::com::sun::star::uno::TypeClass eType2 );
93cdf0e10cSrcweir     bool queryMore();
94cdf0e10cSrcweir     ::com::sun::star::uno::Reference<
95cdf0e10cSrcweir         ::com::sun::star::reflection::XTypeDescription > queryNext();
96cdf0e10cSrcweir 
97cdf0e10cSrcweir     // members
98cdf0e10cSrcweir     osl::Mutex m_aMutex;
99cdf0e10cSrcweir     RegistryKeyList     m_aModuleKeys;
100cdf0e10cSrcweir     RegistryKeyList     m_aCurrentModuleSubKeys;
101cdf0e10cSrcweir     TypeDescriptionList m_aTypeDescs;
102cdf0e10cSrcweir     ::com::sun::star::uno::Sequence<
103cdf0e10cSrcweir         ::com::sun::star::uno::TypeClass > m_aTypes;
104cdf0e10cSrcweir     ::com::sun::star::reflection::TypeDescriptionSearchDepth m_eDepth;
105cdf0e10cSrcweir     ::com::sun::star::uno::Reference<
106cdf0e10cSrcweir         ::com::sun::star::container::XHierarchicalNameAccess > m_xTDMgr;
107cdf0e10cSrcweir };
108cdf0e10cSrcweir 
109cdf0e10cSrcweir } // namespace stoc_rdbtdp
110cdf0e10cSrcweir 
111cdf0e10cSrcweir #endif /* _STOC_RDBTDP_TDENUMERATION_HXX */
112cdf0e10cSrcweir 
113