1 #ifndef __DALI_INTERNAL_FILE_DESCRIPTOR_MONITOR_H__
2 #define __DALI_INTERNAL_FILE_DESCRIPTOR_MONITOR_H__
5 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <dali/public-api/signals/callback.h>
39 * @brief Monitors the given file descriptor and whenever anything is written to it, the provided
42 class FileDescriptorMonitor
47 * @brief Bitmask of file descriptor event types
52 FD_READABLE = 0x1, // For example when monitoring a socket, data is available to read from the socket receive buffer
53 FD_WRITABLE = 0x2, // For example when monitoring a socket space is available in socket send buffer
60 * The callback will be passed a EventType bitmask to signal what type of events occured on the file
66 * mFileDescriptorMonitor = new FileDescriptorMonitor( myFd, MakeCallback( this, &MyClass::FdCallback ), FileDescriptorMonitor::FD_READABLE );
69 * void MyClass::FdCallback( EventType event )
71 * if( event & FileDescriptorMonitor::FD_ERROR)
75 * if( event & FileDescriptorMonitor::FD_READABLE )
82 * @param[in] fileDescriptor The file descriptor to monitor
83 * @param[in] callback Called when anything is written to the file descriptor
84 * @param[in] eventBitmask Bitmask of what to monitor on the file descriptor ( readable / writable ).
85 * @note The ownership of callback is taken by this class.
86 * @note Under Linux it is possible the file descriptor monitor will signal a fd is
87 * readable or writable even when it isn’t. The developer should check for handle EAGAIN or equivalent
88 * when reading from or write to the fd.
90 FileDescriptorMonitor( int fileDescriptor, CallbackBase* callback, int eventBitmask );
95 ~FileDescriptorMonitor();
100 FileDescriptorMonitor( const FileDescriptorMonitor& fileDescriptorMonitor );
103 FileDescriptorMonitor& operator=( const FileDescriptorMonitor& fileDescriptorMonitor );
110 } // namespace Adaptor
112 } // namespace Internal
116 #endif // __DALI_INTERNAL_FILE_DESCRIPTOR_MONITOR_H__