Modifying code according to coding idioms
[framework/osp/social.git] / src / FScl_CalendarbookDbMonitor.h
1 //
2 // Copyright (c) 2012 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 * @file         FScl_CalendarbookDbMonitor.h
18 * @brief        This is the header file for the _CalendarbookDbMonitor class.
19 *
20 * This header file contains the declarations of the _CalendarbookDbMonitor class.
21 */
22
23 #ifndef _FSCL_INTERNAL_CALENDARBOOK_DB_MONITOR_H_
24 #define _FSCL_INTERNAL_CALENDARBOOK_DB_MONITOR_H_
25
26 #include <unique_ptr.h>
27 #include <FBaseObject.h>
28 #include <FBaseResult.h>
29 #include <FBaseTypes.h>
30
31 namespace Tizen { namespace Base { namespace Runtime
32 {
33 class Mutex;
34 }}}
35
36 namespace Tizen { namespace Social
37 {
38 class _ICalendarbookDbChangeEventListener;
39 class _CalendarbookDbChangeEvent;
40
41 /**
42  * @class       _CalendarbookDbMonitor
43  * @brief       This class handles the _CalendarbookDbMonitor operations.
44  * @since       2.0
45  * @see   _CalendarbookImpl
46  *
47  */
48 class _CalendarbookDbMonitor
49         : public Tizen::Base::Object
50 {
51                 class _CalendarbookCallback
52                 {
53                 public :
54                         _CalendarbookCallback(void);
55                         ~_CalendarbookCallback(void);
56                         result Register(calendar_db_changed_cb callback, void* pUserData);
57                 private :
58                         calendar_db_changed_cb __callback;
59                         void* __pUserData;
60                         bool __isRegistered;
61                 };
62
63 public:
64         void Release(void);
65
66         result AddListener(const _ICalendarbookDbChangeEventListener& listener);
67
68         result RemoveListener(const _ICalendarbookDbChangeEventListener& listener);
69
70         static _CalendarbookDbMonitor* GetInstance(void);
71
72 private:
73         /**
74          * This constructor is intentionally declared as private to implement the Singleton semantic.
75          */
76         _CalendarbookDbMonitor(void);
77
78         /**
79          * This destructor is intentionally declared as private to implement the Singleton semantic.
80          */
81         virtual ~_CalendarbookDbMonitor(void);
82
83         result Construct(void);
84
85         /**
86          * The implementation of this copy constructor is intentionally blank and declared as private @n
87          * to prohibit copying of objects.
88          */
89         _CalendarbookDbMonitor(const _CalendarbookDbMonitor& rhs);
90
91         static void OnCalendarbookDbChanged(const char* pViewUri, void* pUserData);
92
93         static void InitCalendarbookDbMonitor(void);
94
95         _CalendarbookDbMonitor& operator =(const _CalendarbookDbMonitor& rhs);
96
97 private:
98         std::unique_ptr<_CalendarbookDbChangeEvent> __pEvent;
99         std::unique_ptr<_CalendarbookCallback> __pChangeCallback;
100
101         static Tizen::Base::Runtime::Mutex __mutex;
102         static int __refCnt;
103         static _CalendarbookDbMonitor* __pCalendarbookDbMonitor;
104         friend class std::default_delete<_CalendarbookDbMonitor>;
105
106 };      // _CalendarbookDbMonitor
107
108 }}  // Tizen::Social
109
110 #endif //_FSCL_INTERNAL_CALENDARBOOK_DB_MONITOR_H_