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