2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
8 // http://www.apache.org/licenses/LICENSE-2.0
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.
18 * @file FBase_HandleT.h
19 * @brief This is the header file for the %_HandleT class.
21 * This file contains the declarations of the %_HandleT class.
23 #ifndef _FBASE_INTERNAL_HANDLE_TEMPLATE_H_
24 #define _FBASE_INTERNAL_HANDLE_TEMPLATE_H_
26 #include <FBaseObject.h>
27 #include "FBase_ObjectManagerImpl.h"
29 namespace Tizen { namespace Base
32 template< typename T >
33 class _ObjectManagerT;
35 template< typename T >
37 : public Tizen::Base::Object
41 * This is the default constructor for this class.
47 , __pObjectManagerImpl(null)
52 * This is the destructor for this class.
56 virtual ~_HandleT(void)
61 * Checks whether the handle is initialized or not.
64 * @return @c true if the handle is not initialized, @n
67 bool IsNull(void) const
73 * Checks whether the handle is valid or not.
76 * return @c true if the handle is valid, @n else @c false
78 bool IsValid(void) const
80 if (__handle == 0 || __pObjectManagerImpl == null)
85 return __pObjectManagerImpl->IsValidHandle(__handle);
89 * Get the signed @c int equivalent of the current instance.
92 * @return Signed @c int equivalent of the current instance
96 return (int) __handle;
100 * Checks whether the two instances of _HandleT are equal.
103 * @return @c true if the values of the two instances of _HandleT are similar, @n
105 * @param[in] rhs An instance of %_HandleT
107 inline bool operator ==(const _HandleT< T >& rhs) const
109 return __handle == rhs.__handle;
113 * Checks whether the two instances of _HandleT are not equal.
116 * @return @c true if the values of the two instances of _HandleT are not similar, @n
118 * @param[in] rhs An instance of %_HandleT
121 inline bool operator !=(const _HandleT< T >& rhs) const
123 return !(*this == rhs);
126 _HandleT(const _HandleT< T >& handle)
128 this->__handle = handle.__handle;
129 this->__pObjectManagerImpl = handle.__pObjectManagerImpl;
132 _HandleT< T >& operator =(const _HandleT& handle)
139 this->__handle = handle.__handle;
140 this->__pObjectManagerImpl = handle.__pObjectManagerImpl;
146 void Initialize(unsigned int handle, _ObjectManagerImpl* pObjectManagerImpl)
149 __pObjectManagerImpl = pObjectManagerImpl;
153 unsigned int __handle;
154 _ObjectManagerImpl* __pObjectManagerImpl;
156 friend class _ObjectManagerT< T >;
159 #endif // _FBASE_RT_INTERNAL_HANDLE_TEMPLATE_H_