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