2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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.
19 #include "file-descriptor-monitor.h"
34 * Using Impl to hide away EFL specific members
36 struct FileDescriptorMonitor::Impl
39 Impl(int fileDescriptor, boost::function<void()> functor)
40 : mFileDescriptor(fileDescriptor),
48 boost::function<void()> mFunctor;
49 Ecore_Fd_Handler* mHandler;
54 * Called when the file descriptor receives an event.
56 static Eina_Bool EventDispatch(void* data, Ecore_Fd_Handler *handler)
58 Impl* impl = reinterpret_cast<Impl*>(data);
62 return ECORE_CALLBACK_RENEW;
66 FileDescriptorMonitor::FileDescriptorMonitor(int fileDescriptor, boost::function<void()> functor)
68 mImpl = new Impl(fileDescriptor, functor);
70 if (fileDescriptor >= 0)
72 mImpl->mHandler = ecore_main_fd_handler_add(fileDescriptor, ECORE_FD_READ, &Impl::EventDispatch, mImpl, NULL, NULL);
76 FileDescriptorMonitor::~FileDescriptorMonitor()
80 ecore_main_fd_handler_del(mImpl->mHandler);
87 } // namespace Adaptor
89 } // namespace Internal