2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 * @file waitable_input_output_execution_context_support.h
18 * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
20 * @brief This file is the header file for waitable input-output execution context support
22 #ifndef DPL_WAITABLE_INPUT_OUTPUT_EXECUTION_CONTEXT_SUPPORT_H
23 #define DPL_WAITABLE_INPUT_OUTPUT_EXECUTION_CONTEXT_SUPPORT_H
25 #include <dpl/abstract_waitable_input_output.h>
26 #include <dpl/waitable_handle_watch_support.h>
27 #include <dpl/binary_queue.h>
34 class WaitableInputOutputExecutionContextSupport
35 : private WaitableHandleWatchSupport::WaitableHandleListener
41 DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
42 DECLARE_EXCEPTION_TYPE(Base, AlreadyOpened)
43 DECLARE_EXCEPTION_TYPE(Base, NotOpened)
44 DECLARE_EXCEPTION_TYPE(Base, OpenFailed)
45 DECLARE_EXCEPTION_TYPE(Base, CloseFailed)
50 AbstractWaitableInputOutput *m_waitableInputOutput;
57 void RemoveReadWatch();
59 void RemoveWriteWatch();
63 void CheckedRemoveReadWatch();
64 void CheckedRemoveWriteWatch();
66 void CheckedRemoveReadWriteWatch();
68 virtual void OnWaitableHandleEvent(WaitableHandle waitableHandle, WaitMode::Type mode);
71 // Incoming/Outgoing streams
72 BinaryQueue m_inputStream;
73 BinaryQueue m_outputStream;
75 // Support calbback methods
76 virtual void OnInputStreamRead() = 0;
77 virtual void OnInputStreamClosed() = 0;
78 virtual void OnInputStreamBroken() = 0;
80 // Trigger feeding output - after updating output stream
83 // Open/Close destination waitable input-output
84 void Open(AbstractWaitableInputOutput *waitableInputOutput);
91 explicit WaitableInputOutputExecutionContextSupport();
96 virtual ~WaitableInputOutputExecutionContextSupport();
102 #endif // DPL_WAITABLE_INPUT_OUTPUT_EXECUTION_CONTEXT_SUPPORT_H