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