3e6c2b547fb475b122c632719c2e7bba0a846e79
[platform/framework/native/appfw.git] / inc / FIoFileLock.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  * @file        FIoFileLock.h
18  * @brief       This is the header file for the %FileLock class.
19  *
20  * This header file contains the declarations of the %FileLock class.
21  */
22
23 #ifndef _FIO_FILE_LOCK_H_
24 #define _FIO_FILE_LOCK_H_
25
26 #include <FBaseObject.h>
27
28 namespace Tizen { namespace Io
29 {
30
31 /**
32  * @enum FileLockType
33  *
34  * Defines the file lock types.
35  *
36  * @since       2.1
37  */
38 enum FileLockType
39 {
40         FILE_LOCK_SHARED,               /**< More than one process can hold a shared file lock on a file region @n
41                                                         A shared lock prevents any other process from setting an exclusive lock on the file
42                                                         region. */
43         FILE_LOCK_EXCLUSIVE             /**< Only one process can hold an exclusive lock on a file region @n
44                                                         An exclusive lock prevents any other process from setting both shared and exclusive
45                                                         lock on the file region. */
46 };
47
48 /**
49  * @class       FileLock
50  * @brief       This class provides methods to check %FileLock type and release it.
51  *
52  * @since       2.1
53  *
54  * @final       This class is not intended for extension.
55  *
56  * The %FileLock class provides methods to check %FileLock type and release it.
57  *
58  * @see Tizen::Io::File
59  * @see Tizen::Io::Registry
60  */
61 class _OSP_EXPORT_ FileLock
62         : public Tizen::Base::Object
63 {
64
65 public:
66         /**
67         * This destructor releases the file lock on the current opened file if acquired.
68         *
69         * @since          2.1
70         */
71         virtual ~FileLock(void);
72
73         /**
74         * Checks whether the file lock is shared.
75         *
76         * @since          2.1
77         *
78         * @return         @c true if the file lock is shared, @n
79         *                    else @c false
80         */
81         bool IsShared(void) const;
82
83         /**
84         * Checks whether the file lock is exclusive.
85         *
86         * @since          2.1
87         *
88         * @return         @c true if the file lock is exclusive, @n
89         *                    else @c false
90         */
91         bool IsExclusive(void) const;
92
93         /**
94         * Checks whether the file lock is valid. @n
95         * The lock is valid unless the associated file has been closed.
96         *
97         * @since          2.1
98         *
99         * @return         @c true if the file lock is valid, @n
100         *                    else @c false
101         */
102         bool IsValid(void) const;
103
104 private:
105         //
106         // This default constructor is intentionally declared as private so that only the platform can create an instance.
107         //
108         // @since       2.1
109         //
110         FileLock(void);
111
112         //
113         // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
114         //
115         // @since       2.1
116         //
117         FileLock(const FileLock& rhs);
118
119         //
120         // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
121         //
122         // @since       2.1
123         //
124         FileLock& operator =(const FileLock& rhs);
125
126         class _FileLockImpl* __pFileLockImpl;
127
128         friend class _FileLockImpl;
129
130 }; // FileLock
131
132 }} // Tizen::Io
133
134 #endif // _FIO_FILE_LOCK_H_