Merge "Fix the defect of calculating time" into tizen_2.2
[platform/framework/native/appfw.git] / src / io / FIo_FileEventDispatcher.h
1 //
2 // Copyright (c) 2013 Samsung Electronics Co., Ltd.
3 //
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
7 //
8 //     http://www.apache.org/licenses/LICENSE-2.0
9 //
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.
15 //
16
17 /**
18  * @file        FIo_FileEventDispatcher.h
19  * @brief       This is the header file for the _FileEventDispatcher class.
20  *
21  * This header file contains the declarations of the _FileEventDispatcher class.
22  */
23
24 #ifndef _FIO_INTERNAL_FILE_EVENT_DISPATCHER_H_
25 #define _FIO_INTERNAL_FILE_EVENT_DISPATCHER_H_
26
27 #include <glib.h>
28
29 #include <FBaseInteger.h>
30 #include <FBaseString.h>
31 #include <FBaseColHashMap.h>
32
33 namespace Tizen { namespace Io
34 {
35
36 class _FileEventManagerImpl;
37
38 class _FileEventInfo
39         : public Tizen::Base::Object
40 {
41 public:
42         _FileEventInfo(void)
43                 : pFileEventManagerImpl(null)
44         {
45         }
46         virtual ~_FileEventInfo(void)
47         {
48         }
49         _FileEventManagerImpl* pFileEventManagerImpl;
50         Tizen::Base::String path;
51 }; // _FileEventInfo
52
53 class _FileEventDispatcher
54         : public Tizen::Base::Object
55 {
56
57 public:
58         result SendEvent(void);
59
60         int GetInotifyFd(void)
61         {
62                 return __inotifyFd;
63         }
64
65         result AddFileEventInfo(Tizen::Base::Integer* pWatchDescription, _FileEventInfo* pFileEventInfo);
66
67         _FileEventInfo* GetFileEventInfo(Tizen::Base::Integer& watchDescription);
68
69         void RemoveFileEventInfo(Tizen::Base::Integer& watchDescription);
70
71         static _FileEventDispatcher* GetInstance(void);
72
73 private:
74         _FileEventDispatcher(void);
75
76         result Construct(void);
77
78         virtual ~_FileEventDispatcher(void);
79
80         _FileEventDispatcher(const _FileEventDispatcher& rhs);
81
82         _FileEventDispatcher& operator =(const _FileEventDispatcher& rhs);
83
84         static void InitSingleton(void);
85
86         static void DestroySingleton(void);
87
88         static gboolean OnFileEventOccurred(GIOChannel* source, GIOCondition condition, gpointer data);
89
90 private:
91         static _FileEventDispatcher* __pFileEventDispatcherInstance;
92         Tizen::Base::Collection::HashMap* __pWatchList;
93         int __inotifyFd;
94         GSource* __pGSource;
95         GIOChannel* __pGIOChannel;
96
97 }; // _FileEventDispatcher
98
99 }} // Tizen::Io
100
101 #endif // _FIO_INTERNAL_FILE_EVENT_DISPATCHER_H_
102