Merge "Fix memory leaks in Locales" into tizen_2.1
[platform/framework/native/appfw.git] / src / io / inc / FIo_FileLockImpl.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2013 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            FIo_FileLockImpl.h
19 * @brief          This is the header file for the %_FileLockImpl class.
20 *
21 * This header file contains the declarations of the %FileLockImpl class.
22 */
23
24 #ifndef _FIO_INTERNAL_FILE_LOCK_IMPL_H_
25 #define _FIO_INTERNAL_FILE_LOCK_IMPL_H_
26
27 #include <FBaseObject.h>
28 #include <FBaseInternalTypes.h>
29 #include <FOspConfig.h>
30 #include <FIoFileLock.h>
31
32 namespace Tizen { namespace Io
33 {
34
35 class _FileImpl;
36
37 class _OSP_EXPORT_ _FileLockImpl
38         : public Tizen::Base::Object
39 {
40 public:
41
42         _FileLockImpl(void);
43
44         virtual ~_FileLockImpl(void);
45
46         static _FileLockImpl* GetInstance(FileLock& fileLock);
47
48         static const _FileLockImpl* GetInstance(const FileLock& fileLock);
49
50         /**
51         * Checks whether the file lock is shared.
52         *
53         * @since          2.1
54         *
55         * @return         @c true if the file lock is shared, @n
56         *                    else @c false
57         */
58         bool IsShared(void) const;
59
60         /**
61         * Checks whether the file lock is exclusive.
62         *
63         * @since          2.1
64         *
65         * @return         @c true if the file lock is exclusive, @n
66         *                    else @c false
67         */
68         bool IsExclusive(void) const;
69
70         /**
71         * Checks whether the file lock is valid. @n
72         * The lock is valid unless the associated %File has been closed.
73         *
74         * @since          2.1
75         *
76         * @return         @c true if the file lock is valid, @n
77         *                    else @c false
78         */
79         bool IsValid(void) const;
80
81         //
82         // Constructs the instance of this class.
83         //
84         // @since       2.1
85         //
86         // @return          An error code
87         // @param[in]   pFile           An instance of %File
88         // @param[in]   lockType        The type of file lock to be created
89         // @param[in]   offset          The starting offset for the locked region
90         // @param[in]   size            The size of the locked region in bytes
91         // @param[in]   pid                     process id of the proccess aquiring this lock
92         // @exception   E_SUCCESS               The method is successful.
93         // @exception   E_OUT_OF_MEMORY The memory is insufficient.
94         // @exception   E_SYSTEM                A system error has occurred.
95         //
96         result Construct(const _FileImpl* pFileImpl, FileLockType lockType, int offset, int size, int pid);
97
98         static FileLock* CreateFileLockInstanceN(const _FileImpl* pFileImpl, FileLockType lockType, int offset, int size, int pid);
99
100 private:
101         //
102         // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
103         //
104         _FileLockImpl(const _FileLockImpl& rhs);
105
106         //
107         // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
108         //
109         _FileLockImpl& operator =(const _FileLockImpl& rhs);
110
111         _FileImpl* __pFileImpl;
112         FileLockType __lockType;
113         int __offset;
114         int __size;
115         int __pid;
116
117         friend class _FileImpl;
118
119 }; // _FileLockImpl
120
121 }} // Tizen::Io
122
123 #endif // _FIO_INTERNAL_FILE_LOCK_IMPL_H_