85e611c53fb0e158c09337881ce5d62c07fa8bc3
[framework/osp/social.git] / src / FScl_CalendarbookDbMonitor.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 /**
18 * @file         FScl_CalendarbookDbMonitor.h
19 * @brief        This is the header file for the _CalendarbookDbMonitor class.
20 *
21 * This header file contains the declarations of the _CalendarbookDbMonitor class.
22 */
23
24 #ifndef _FSCL_INTERNAL_CALENDARBOOK_DB_MONITOR_H_
25 #define _FSCL_INTERNAL_CALENDARBOOK_DB_MONITOR_H_
26
27 #include <unique_ptr.h>
28 #include <FBaseTypes.h>
29 #include <FBaseResult.h>
30 #include <FBaseObject.h>
31
32 namespace Tizen { namespace Base { namespace Runtime
33 {
34 class Mutex;
35 }}}
36
37 namespace Tizen { namespace Social
38 {
39 class _ICalendarbookDbChangeEventListener;
40 class _CalendarbookDbChangeEvent;
41
42 /**
43  * @class       _CalendarbookDbMonitor
44  * @brief       This class handles the _CalendarbookDbMonitor operations.
45  * @since       2.0
46  * @see   _CalendarbookImpl
47  *
48  */
49 class _CalendarbookDbMonitor
50         : public Tizen::Base::Object
51 {
52                 class _CalendarbookCallback
53                 {
54                 public :
55                         _CalendarbookCallback(void);
56                         ~_CalendarbookCallback(void);
57                         result Register(calendar_db_changed_cb callback, void* pUserData);
58                 private :
59                         calendar_db_changed_cb __callback;
60                         void* __pUserData;
61                         bool __isRegistered;
62                 };
63
64 public:
65         void Release(void);
66
67         result AddListener(const _ICalendarbookDbChangeEventListener& listener);
68
69         result RemoveListener(const _ICalendarbookDbChangeEventListener& listener);
70
71         static _CalendarbookDbMonitor* GetInstance(void);
72
73 private:
74         /**
75          * This constructor is intentionally declared as private to implement the Singleton semantic.
76          */
77         _CalendarbookDbMonitor(void);
78
79         /**
80          * This destructor is intentionally declared as private to implement the Singleton semantic.
81          */
82         virtual ~_CalendarbookDbMonitor(void);
83
84         result Construct(void);
85
86         /**
87          * The implementation of this copy constructor is intentionally blank and declared as private @n
88          * to prohibit copying of objects.
89          */
90         _CalendarbookDbMonitor(const _CalendarbookDbMonitor& rhs);
91
92         static void OnCalendarbookDbChanged(const char* pViewUri, void* pUserData);
93
94         static void InitCalendarbookDbMonitor(void);
95
96         _CalendarbookDbMonitor& operator =(const _CalendarbookDbMonitor& rhs);
97
98 private:
99         std::unique_ptr<_CalendarbookDbChangeEvent> __pEvent;
100         std::unique_ptr<_CalendarbookCallback> __pChangeCallback;
101
102         static Tizen::Base::Runtime::Mutex __mutex;
103         static int __refCnt;
104         static _CalendarbookDbMonitor* __pCalendarbookDbMonitor;
105         friend class std::default_delete<_CalendarbookDbMonitor>;
106
107 };      // _CalendarbookDbMonitor
108
109 }}  // Tizen::Social
110
111 #endif //_FSCL_INTERNAL_CALENDARBOOK_DB_MONITOR_H_