xref: /AOO41X/main/framework/inc/helper/ocomponentenumeration.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #ifndef __FRAMEWORK_HELPER_OCOMPONENTENUMERATION_HXX_
29*cdf0e10cSrcweir #define __FRAMEWORK_HELPER_OCOMPONENTENUMERATION_HXX_
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
32*cdf0e10cSrcweir //	my own includes
33*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir #ifndef __FRAMEWORK_OMUTEXMEMBER_HXX_
36*cdf0e10cSrcweir #include <threadhelp/threadhelpbase.hxx>
37*cdf0e10cSrcweir #endif
38*cdf0e10cSrcweir #include <macros/generic.hxx>
39*cdf0e10cSrcweir #include <macros/xinterface.hxx>
40*cdf0e10cSrcweir #include <macros/xtypeprovider.hxx>
41*cdf0e10cSrcweir #include <macros/debug.hxx>
42*cdf0e10cSrcweir #include <general.h>
43*cdf0e10cSrcweir 
44*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
45*cdf0e10cSrcweir //	interface includes
46*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
47*cdf0e10cSrcweir #include <com/sun/star/lang/XEventListener.hpp>
48*cdf0e10cSrcweir #include <com/sun/star/container/XEnumeration.hpp>
49*cdf0e10cSrcweir #include <com/sun/star/lang/XComponent.hpp>
50*cdf0e10cSrcweir 
51*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
52*cdf0e10cSrcweir //	other includes
53*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
54*cdf0e10cSrcweir #include <cppuhelper/implbase2.hxx>
55*cdf0e10cSrcweir 
56*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
57*cdf0e10cSrcweir //	namespace
58*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
59*cdf0e10cSrcweir 
60*cdf0e10cSrcweir namespace framework{
61*cdf0e10cSrcweir 
62*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
63*cdf0e10cSrcweir //	exported const
64*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
67*cdf0e10cSrcweir //	exported definitions
68*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
69*cdf0e10cSrcweir 
70*cdf0e10cSrcweir /*-************************************************************************************************************//**
71*cdf0e10cSrcweir 	@short			implement a helper for a oneway enumeration of components
72*cdf0e10cSrcweir 	@descr			You can step during this list only for one time! Its a snapshot.
73*cdf0e10cSrcweir 					Don't forget to release the reference. You are the owner of an instance of this implementation.
74*cdf0e10cSrcweir 					You cant use this as a baseclass. Please use it as a dynamical object for return.
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir 	@implements		XInterface
77*cdf0e10cSrcweir 					XTypeProvider
78*cdf0e10cSrcweir 					XEventListener
79*cdf0e10cSrcweir 					XEnumeration
80*cdf0e10cSrcweir 
81*cdf0e10cSrcweir 	@base			ThreadHelpBase
82*cdf0e10cSrcweir 					OWeakObject
83*cdf0e10cSrcweir 
84*cdf0e10cSrcweir 	@devstatus		ready to use
85*cdf0e10cSrcweir 	@threadsafe		yes
86*cdf0e10cSrcweir *//*-*************************************************************************************************************/
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir class OComponentEnumeration	:	public ThreadHelpBase               ,
89*cdf0e10cSrcweir 								public ::cppu::WeakImplHelper2< ::com::sun::star::container::XEnumeration,::com::sun::star::lang::XEventListener >
90*cdf0e10cSrcweir {
91*cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
92*cdf0e10cSrcweir 	//	public methods
93*cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
94*cdf0e10cSrcweir 
95*cdf0e10cSrcweir 	public:
96*cdf0e10cSrcweir 
97*cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
98*cdf0e10cSrcweir 		//	constructor / destructor
99*cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
100*cdf0e10cSrcweir 
101*cdf0e10cSrcweir 		/*-****************************************************************************************************//**
102*cdf0e10cSrcweir 			@short		constructor to initialize this enumeration
103*cdf0e10cSrcweir 			@descr		An enumeration is a list with oneway-access! You can get every member only for one time.
104*cdf0e10cSrcweir 						This method allow to initialize this oneway list with values.
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir 			@seealso	-
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir 			@param		"seqComponents" is a sequence of interfaces, which are components.
109*cdf0e10cSrcweir 			@return		-
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir 			@onerror	Do nothing and reset this object to default with an empty list.
112*cdf0e10cSrcweir 		*//*-*****************************************************************************************************/
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir 	 	OComponentEnumeration( const css::uno::Sequence< css::uno::Reference< css::lang::XComponent > >& seqComponents );
115*cdf0e10cSrcweir 
116*cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
117*cdf0e10cSrcweir 		//	XEventListener
118*cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir 		/*-****************************************************************************************************//**
121*cdf0e10cSrcweir 			@short		last chance to release all references and free memory
122*cdf0e10cSrcweir 			@descr		This method is called, if the enumeration is used completly and has no more elements.
123*cdf0e10cSrcweir 						Then we must destroy ouer list and release all references to other objects.
124*cdf0e10cSrcweir 
125*cdf0e10cSrcweir 			@seealso	interface XEventListener
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir 			@param		"aEvent" describe the source of this event.
128*cdf0e10cSrcweir 			@return		-
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir 			@onerror	-
131*cdf0e10cSrcweir 		*//*-*****************************************************************************************************/
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir 		virtual void SAL_CALL disposing( const css::lang::EventObject& aEvent ) throw( css::uno::RuntimeException );
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
136*cdf0e10cSrcweir 		//	XEnumeration
137*cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
138*cdf0e10cSrcweir 
139*cdf0e10cSrcweir 		/*-****************************************************************************************************//**
140*cdf0e10cSrcweir 			@short		check count of accessible elements of enumeration
141*cdf0e10cSrcweir 			@descr		You can call this method to get information about accessible elements in future.
142*cdf0e10cSrcweir 						Elements you have already getted are not accessible!
143*cdf0e10cSrcweir 
144*cdf0e10cSrcweir 			@seealso	interface XEnumeration
145*cdf0e10cSrcweir 
146*cdf0e10cSrcweir 			@param		-
147*cdf0e10cSrcweir 			@return		sal_True  = if more elements accessible<BR>
148*cdf0e10cSrcweir 						sal_False = other way
149*cdf0e10cSrcweir 
150*cdf0e10cSrcweir 			@onerror	sal_False<BR>
151*cdf0e10cSrcweir 						(List is emtpy and there no accessible elements ...)
152*cdf0e10cSrcweir 		*//*-*****************************************************************************************************/
153*cdf0e10cSrcweir 
154*cdf0e10cSrcweir     	virtual sal_Bool SAL_CALL hasMoreElements() throw( css::uno::RuntimeException );
155*cdf0e10cSrcweir 
156*cdf0e10cSrcweir 		/*-****************************************************************************************************//**
157*cdf0e10cSrcweir 			@short		give the next element, if some exist
158*cdf0e10cSrcweir 			@descr		If a call "hasMoreElements()" return true, you can get the next element of list.
159*cdf0e10cSrcweir 
160*cdf0e10cSrcweir 			@seealso	interface XEnumeration
161*cdf0e10cSrcweir 
162*cdf0e10cSrcweir 			@param		-
163*cdf0e10cSrcweir 			@return		A Reference to a component, safed in an Any-structure.
164*cdf0e10cSrcweir 
165*cdf0e10cSrcweir 			@onerror	If end of enumeration is arrived or there are no elements in list => a NoSuchElementException is thrown.
166*cdf0e10cSrcweir 		*//*-*****************************************************************************************************/
167*cdf0e10cSrcweir 
168*cdf0e10cSrcweir     	virtual css::uno::Any SAL_CALL nextElement() throw(	css::container::NoSuchElementException	,
169*cdf0e10cSrcweir 							 								css::lang::WrappedTargetException		,
170*cdf0e10cSrcweir 															css::uno::RuntimeException				);
171*cdf0e10cSrcweir 
172*cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
173*cdf0e10cSrcweir 	//	protected methods
174*cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
175*cdf0e10cSrcweir 
176*cdf0e10cSrcweir 	protected:
177*cdf0e10cSrcweir 
178*cdf0e10cSrcweir 		/*-****************************************************************************************************//**
179*cdf0e10cSrcweir 			@short		standard destructor
180*cdf0e10cSrcweir 			@descr		This method destruct an instance of this class and clear some member.
181*cdf0e10cSrcweir 						We make it protected, because its not supported to use this class as normal instance!
182*cdf0e10cSrcweir 						You must create it dynamical in memory and use a pointer.
183*cdf0e10cSrcweir 
184*cdf0e10cSrcweir 			@seealso	-
185*cdf0e10cSrcweir 
186*cdf0e10cSrcweir 			@param		-
187*cdf0e10cSrcweir 			@return		-
188*cdf0e10cSrcweir 
189*cdf0e10cSrcweir 			@onerror	-
190*cdf0e10cSrcweir 		*//*-*****************************************************************************************************/
191*cdf0e10cSrcweir 
192*cdf0e10cSrcweir 		virtual	~OComponentEnumeration();
193*cdf0e10cSrcweir 
194*cdf0e10cSrcweir 		/*-****************************************************************************************************//**
195*cdf0e10cSrcweir 			@short		reset instance to default values
196*cdf0e10cSrcweir 
197*cdf0e10cSrcweir 			@descr		There are two ways to delete an instance of this class.<BR>
198*cdf0e10cSrcweir 						1) delete with destructor<BR>
199*cdf0e10cSrcweir 						2) dispose from parent or factory ore ...<BR>
200*cdf0e10cSrcweir 						This method do the same for both ways! It free used memory and release references ...
201*cdf0e10cSrcweir 
202*cdf0e10cSrcweir 			@seealso	method dispose()
203*cdf0e10cSrcweir 			@seealso	destructor ~TaskEnumeration()
204*cdf0e10cSrcweir 
205*cdf0e10cSrcweir 			@param		-
206*cdf0e10cSrcweir 
207*cdf0e10cSrcweir 			@return		-
208*cdf0e10cSrcweir 
209*cdf0e10cSrcweir 			@onerror	-
210*cdf0e10cSrcweir 		*//*-*****************************************************************************************************/
211*cdf0e10cSrcweir 
212*cdf0e10cSrcweir 		virtual void impl_resetObject();
213*cdf0e10cSrcweir 
214*cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
215*cdf0e10cSrcweir 	//	private methods
216*cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
217*cdf0e10cSrcweir 
218*cdf0e10cSrcweir 	private:
219*cdf0e10cSrcweir 
220*cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
221*cdf0e10cSrcweir 	//	debug methods
222*cdf0e10cSrcweir 	//	(should be private everyway!)
223*cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
224*cdf0e10cSrcweir 
225*cdf0e10cSrcweir 		/*-****************************************************************************************************//**
226*cdf0e10cSrcweir 			@short		debug-method to check incoming parameter of some other mehods of this class
227*cdf0e10cSrcweir 			@descr		The following methods are used to check parameters for other methods
228*cdf0e10cSrcweir 						of this class. The return value is used directly for an ASSERT(...).
229*cdf0e10cSrcweir 
230*cdf0e10cSrcweir 			@seealso	ASSERT in implementation!
231*cdf0e10cSrcweir 
232*cdf0e10cSrcweir 			@param		references to checking variables
233*cdf0e10cSrcweir 			@return		sal_False on invalid parameter<BR>
234*cdf0e10cSrcweir 						sal_True  otherway
235*cdf0e10cSrcweir 
236*cdf0e10cSrcweir 			@onerror	-
237*cdf0e10cSrcweir 		*//*-*****************************************************************************************************/
238*cdf0e10cSrcweir 
239*cdf0e10cSrcweir 	#ifdef ENABLE_ASSERTIONS
240*cdf0e10cSrcweir 
241*cdf0e10cSrcweir 	private:
242*cdf0e10cSrcweir 
243*cdf0e10cSrcweir 		static sal_Bool impldbg_checkParameter_OComponentEnumerationCtor	(	const	css::uno::Sequence< css::uno::Reference< css::lang::XComponent > >&	seqComponents	);
244*cdf0e10cSrcweir 		static sal_Bool impldbg_checkParameter_disposing					(	const	css::lang::EventObject&			   									aEvent			);
245*cdf0e10cSrcweir 
246*cdf0e10cSrcweir 	#endif	// #ifdef ENABLE_ASSERTIONS
247*cdf0e10cSrcweir 
248*cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
249*cdf0e10cSrcweir 	//	variables
250*cdf0e10cSrcweir 	//	(should be private everyway!)
251*cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
252*cdf0e10cSrcweir 
253*cdf0e10cSrcweir 	private:
254*cdf0e10cSrcweir 
255*cdf0e10cSrcweir 		sal_uInt32																m_nPosition			;	/// current position in enumeration
256*cdf0e10cSrcweir 		css::uno::Sequence< css::uno::Reference< css::lang::XComponent > >		m_seqComponents		;	/// list of current components
257*cdf0e10cSrcweir 
258*cdf0e10cSrcweir };		//	class OComponentEnumeration
259*cdf0e10cSrcweir 
260*cdf0e10cSrcweir }		//	namespace framework
261*cdf0e10cSrcweir 
262*cdf0e10cSrcweir #endif	//	#ifndef __FRAMEWORK_HELPER_OCOMPONENTENUMERATION_HXX_
263