merged tag ooo/DEV300_m102
[LibreOffice.git] / fpicker / source / win32 / filepicker / asynceventnotifier.hxx
blob5b8854aae38c8d44ff38f104fff4075445f25837
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 #ifndef _ASYNCEVENTNOTIFIER_HXX_
29 #define _ASYNCEVENTNOTIFIER_HXX_
31 //------------------------------------------------------------------------
32 // includes
33 //------------------------------------------------------------------------
35 #include <osl/mutex.hxx>
36 #include <osl/conditn.hxx>
37 #include <cppuhelper/interfacecontainer.h>
39 #if defined _MSC_VER
40 #pragma warning(push, 1)
41 #endif
42 #include <windows.h>
43 #if defined _MSC_VER
44 #pragma warning(pop)
45 #endif
47 #include <list>
48 #include <utility>
49 #include "eventnotification.hxx"
51 //---------------------------------------------
53 //---------------------------------------------
55 class CAsyncEventNotifier
57 public:
58 CAsyncEventNotifier(cppu::OBroadcastHelper& rBroadcastHelper);
59 ~CAsyncEventNotifier();
61 bool SAL_CALL startup(bool bCreateSuspended = true);
62 void SAL_CALL shutdown();
64 // notifications may be added the
65 // the event queue but will only
66 // be notified to the clients after
67 // resume was called
68 void suspend();
70 // resume notifying events
71 void resume();
73 // this class is responsible for the memory management of
74 // the CEventNotification instance
75 void SAL_CALL notifyEvent(CEventNotification* EventNotification);
77 void SAL_CALL addListener (const ::com::sun::star::uno::Type& aType ,
78 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xListener);
79 void SAL_CALL removeListener(const ::com::sun::star::uno::Type& aType ,
80 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xListener);
82 private:
83 size_t SAL_CALL getEventListSize();
84 void SAL_CALL resetNotifyEvent();
85 CEventNotification* SAL_CALL getNextEventRecord();
86 void SAL_CALL removeNextEventRecord();
88 void SAL_CALL run( );
90 static unsigned int WINAPI ThreadProc(LPVOID pParam);
92 private:
93 std::list<CEventNotification*> m_EventList;
94 HANDLE m_hThread;
95 bool m_bRun;
96 unsigned m_ThreadId;
97 ::cppu::OBroadcastHelper& m_rBroadcastHelper;
98 HANDLE m_hEvents[2];
99 HANDLE& m_NotifyEvent;
100 HANDLE& m_ResumeNotifying;
101 osl::Mutex m_Mutex;
103 // prevent copy and assignment
104 private:
105 CAsyncEventNotifier( const CAsyncEventNotifier& );
106 CAsyncEventNotifier& operator=( const CAsyncEventNotifier& );
109 #endif