From 036474ee0c2c4d0d0a8396b5cc800eb2f65dc52d Mon Sep 17 00:00:00 2001 From: Hyunbin Lee Date: Mon, 18 Mar 2013 23:07:54 +0900 Subject: [PATCH] Update FileLock class doxygen. Change-Id: I568bbc878fd9c3d19f87ac8b1ba615b63cdda4f6 Signed-off-by: Hyunbin Lee --- inc/FIoFileLock.h | 70 ++++++++++++++++++++++--------------------- src/io/FIoFileLock.cpp | 21 ++----------- src/io/FIo_FileLockImpl.cpp | 3 +- src/io/inc/FIo_FileLockImpl.h | 15 ++++++++++ 4 files changed, 56 insertions(+), 53 deletions(-) diff --git a/inc/FIoFileLock.h b/inc/FIoFileLock.h index 2493a25..78467e1 100644 --- a/inc/FIoFileLock.h +++ b/inc/FIoFileLock.h @@ -15,11 +15,11 @@ // limitations under the License. /** -* @file FIoFileLock.h -* @brief This is the header file for the %FileLock class. -* -* This header file contains the declarations of the %FileLock class. -*/ + * @file FIoFileLock.h + * @brief This is the header file for the %FileLock class. + * + * This header file contains the declarations of the %FileLock class. + */ #ifndef _FIO_FILE_LOCK_H_ #define _FIO_FILE_LOCK_H_ @@ -27,27 +27,40 @@ namespace Tizen { namespace Io { -class _FileImpl; /** -* @enum FileLockType -* -* Defines the file lock type -* -* @since 2.1 -*/ + * @enum FileLockType + * + * Defines the file lock type + * + * @since 2.1 + */ enum FileLockType { - FILE_LOCK_SHARED, /**< More than one process can hold a shared file lock on a file region. - A shared lock prevents any other process from setting an exclusive lock on the file - region . */ - FILE_LOCK_EXCLUSIVE /**< Only one process can hold an exclusive lock on a file region. - An exclusive lock prevents any other process from setting both shared and exclusive - lock on the file region. */ + FILE_LOCK_SHARED, /**< More than one process can hold a shared file lock on a file region. + A shared lock prevents any other process from setting an exclusive lock on the file + region . */ + FILE_LOCK_EXCLUSIVE /**< Only one process can hold an exclusive lock on a file region. + An exclusive lock prevents any other process from setting both shared and exclusive + lock on the file region. */ }; +/** + * @class FileLock + * @brief This class provides methods to check %FileLock type and release it. + * + * @since 2.1 + * + * @final This class is not intended for extension. + * + * The %FileLock class provides methods to check %FileLock type and release it. + * + * @see Tizen::Io::File + * @see Tizen::Io::Registry + */ class _OSP_EXPORT_ FileLock : public Tizen::Base::Object { + public: /** * This destructor releases the file lock on the current opened file if acquired @@ -91,34 +104,23 @@ private: // // This default constructor is intentionally declared as private so that only the platform can create an instance. // + // @since 2.1 + // FileLock(void); // // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. // + // @since 2.1 + // FileLock(const FileLock& rhs); // // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. // - FileLock& operator =(const FileLock& rhs); - - // - // Constructs the instance of this class. - // // @since 2.1 // - // @return An error code - // @param[in] fileImpl Am instance of _FileImpl - // @param[in] lockType The type of file lock to be created - // @param[in] offset The starting offset for the locked region - // @param[in] size The size of the locked region in bytes - // @param[in] pid process id of the proccess aquiring this lock - // @exception E_SUCCESS The method is successful. - // @exception E_OUT_OF_MEMORY The memory is insufficient. - // @exception E_SYSTEM A system error has occurred. - // - result Construct(const _FileImpl* pFileImpl, FileLockType lockType, int offset, int size, int pid); + FileLock& operator =(const FileLock& rhs); class _FileLockImpl* __pFileLockImpl; diff --git a/src/io/FIoFileLock.cpp b/src/io/FIoFileLock.cpp index 8329d1e..a5e3ab3 100644 --- a/src/io/FIoFileLock.cpp +++ b/src/io/FIoFileLock.cpp @@ -36,6 +36,8 @@ namespace Tizen { namespace Io FileLock::FileLock(void) : __pFileLockImpl(null) { + __pFileLockImpl = new (std::nothrow) _FileLockImpl(); + SysTryReturnVoidResult(NID_IO, __pFileLockImpl != null, E_OUT_OF_MEMORY, "The memory is insufficient."); } FileLock::~FileLock(void) @@ -43,40 +45,23 @@ FileLock::~FileLock(void) delete __pFileLockImpl; } -result -FileLock::Construct(const _FileImpl* pFileImpl, FileLockType lockType, int offset, int size, int pid) -{ - SysAssertf(__pFileLockImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class\n"); - - std::unique_ptr<_FileLockImpl> pFileLockImpl(new (std::nothrow) _FileLockImpl); - SysTryReturnResult(NID_IO, pFileLockImpl != null, E_OUT_OF_MEMORY, "The memory is insufficient."); - - result r = pFileLockImpl->Construct(pFileImpl, lockType, offset, size, pid); - SysTryReturn(NID_IO, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r)); - - __pFileLockImpl = pFileLockImpl.release(); - return r; -} - bool FileLock::IsShared(void) const { - SysAssertf(__pFileLockImpl != null, "Not yet constructed. Construct() should be called before use.\n"); return __pFileLockImpl->IsShared(); } bool FileLock::IsExclusive(void) const { - SysAssertf(__pFileLockImpl != null, "Not yet constructed. Construct() should be called before use.\n"); return __pFileLockImpl->IsExclusive(); } bool FileLock::IsValid(void) const { - SysAssertf(__pFileLockImpl != null, "Not yet constructed. Construct() should be called before use.\n"); return __pFileLockImpl->IsValid(); } }} // Tizen::Io + diff --git a/src/io/FIo_FileLockImpl.cpp b/src/io/FIo_FileLockImpl.cpp index d088d38..e2667f9 100644 --- a/src/io/FIo_FileLockImpl.cpp +++ b/src/io/FIo_FileLockImpl.cpp @@ -130,8 +130,9 @@ _FileLockImpl::CreateFileLockInstanceN(const _FileImpl* pFileImpl, FileLockType { std::unique_ptr pFileLock(new (std::nothrow) FileLock()); SysTryReturn(NID_IO, pFileLock != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + _FileLockImpl* pFileLockImpl = _FileLockImpl::GetInstance(*pFileLock); - result r = pFileLock->Construct(pFileImpl, lockType, offset, size, pid); + result r = pFileLockImpl->Construct(pFileImpl, lockType, offset, size, pid); SysTryReturn(NID_IO, !IsFailed(r), null, r, "[%s] Propagating to caller...", GetErrorMessage(r)); SetLastResult(E_SUCCESS); diff --git a/src/io/inc/FIo_FileLockImpl.h b/src/io/inc/FIo_FileLockImpl.h index 058227d..3621c98 100644 --- a/src/io/inc/FIo_FileLockImpl.h +++ b/src/io/inc/FIo_FileLockImpl.h @@ -78,6 +78,21 @@ public: */ bool IsValid(void) const; + // + // Constructs the instance of this class. + // + // @since 2.1 + // + // @return An error code + // @param[in] pFile An instance of %File + // @param[in] lockType The type of file lock to be created + // @param[in] offset The starting offset for the locked region + // @param[in] size The size of the locked region in bytes + // @param[in] pid process id of the proccess aquiring this lock + // @exception E_SUCCESS The method is successful. + // @exception E_OUT_OF_MEMORY The memory is insufficient. + // @exception E_SYSTEM A system error has occurred. + // result Construct(const _FileImpl* pFileImpl, FileLockType lockType, int offset, int size, int pid); static FileLock* CreateFileLockInstanceN(const _FileImpl* pFileImpl, FileLockType lockType, int offset, int size, int pid); -- 2.7.4