7 #ifndef __core_Handled_h__ 8 #define __core_Handled_h__ 13 class FE_DL_EXPORT HandleToken:
public Counted
18 m_name(
"HandleToken"),
23 virtual ~HandleToken(
void) {}
25 BWORD valid(
void) {
return m_valid; }
31 const String& name(
void)
const {
return m_name; }
32 virtual void setName(String name)
34 RecursiveMutex::Guard guard(
36 m_name.sPrintf(
"HandleToken %s",name.c_str());
78 { m_spHandleToken=rhpT.m_spHandleToken;
79 m_pObject=rhpT.m_pObject; }
83 { operator=(rspX->getHandle()); }
88 m_pObject=fe_cast<T>(rhpX.
raw()); }
94 { m_spHandleToken=
new HandleToken();
106 operator=(rspX->getHandle());
109 m_spHandleToken=NULL;
123 const hp<T>& operator=(
const X* pX)
126 operator=(pX->getHandle());
129 m_spHandleToken=NULL;
135 { m_spHandleToken=rhpT.m_spHandleToken;
136 m_pObject=rhpT.m_pObject;
140 BWORD operator<(const hp<T>& rhpT)
const 141 {
return (FE_UWORD)(m_pObject) < (FE_UWORD)(rhpT.m_pObject); }
145 {
if(!handleToken() || !handleToken()->valid())
152 if(!handleToken() || !handleToken()->valid())
153 feX(e_invalidHandle,(
"fe::hp< "+FE_TYPESTRING(T)+
154 " >::operator->").c_str(),
155 "attempt to use invalid Handle");
163 if(!handleToken() || !handleToken()->valid())
164 feX(e_invalidHandle,(
"fe::hp< "+FE_TYPESTRING(T)+
165 " >::operator->").c_str(),
166 "attempt to use invalid Handle");
180 {
return handleToken() && handleToken()->valid(); }
184 {
return !isValid(); }
191 handleToken()->invalidate();
192 m_spHandleToken=NULL; }
198 {
return m_spHandleToken.raw(); }
212 Handled(
void) { m_handle.initialize((T*)
this); }
213 virtual ~
Handled(
void) { abandonHandle(); }
229 void abandonHandle(
void) { m_handle.invalidate(); }
236 template <
class T,
class X>
243 template <
class T,
class X>
246 return (rhpLeft.
raw()==rspRight.raw());
250 template <
class T,
class X>
253 return (rspLeft.raw()==rhpRight.
raw());
264 template <
class T,
class X>
267 return (rhpLeft.
raw()!=rspRight.raw());
271 template <
class T,
class X>
274 return (rspLeft.raw()!=rhpRight.
raw());
280 FE_UWORD operator()(
const hp<T>& rhpT)
const 281 {
return reinterpret_cast<FE_UWORD
>(rhpT.
raw()); }
287 bool operator()(
const hp<T>& rhpT1,
const hp<T>& rhpT2)
const 288 {
return rhpT1 == rhpT2; }
291 template<
typename T,
typename U>
292 class AutoHashMap< hp<T>, U >:
293 public HashMap< hp<T>, U, hash_hp<T>, eq_hp<T> > {};
BWORD isNull(void) const
Returns true if the pointer is not set.
Definition: Handled.h:183
BWORD operator==(const sp< X > &rspLeft, const hp< T > &rhpRight)
Definition: Handled.h:251
Base class providing protection counting for cp<>
Definition: Protectable.h:28
kernel
Definition: namespace.dox:3
BWORD operator==(const hp< T > &rhpLeft, const sp< X > &rspRight)
Definition: Handled.h:244
sp< T > object(void) const
Returns a smart pointer of the same templated type.
Definition: Handled.h:176
T * operator->(void) const
Use the handled pointer.
Definition: Handled.h:150
HandleToken * handleToken(void) const
Access the shared token.
Definition: Handled.h:197
BWORD operator!=(const sp< X > &rspLeft, const hp< T > &rhpRight)
Definition: Handled.h:272
Safe handle for shared pointer.
Definition: Handled.h:61
void initialize(T *pObject)
Initialize during Handled construction.
Definition: Handled.h:93
BWORD operator!=(const hp< T > &rhpLeft, const sp< X > &rspRight)
Definition: Handled.h:265
void invalidate(void)
Nulls the shared pointer.
Definition: Handled.h:189
T * raw(void) const
Returns the handled pointer, potentially NULL.
Definition: Handled.h:144
const hp< T > & operator=(const sp< X > &rspX)
Converts from a smart pointer of any type.
Definition: Handled.h:103
Intrusive Smart Pointer.
Definition: src/core/ptr.h:53
const hp< T > & getHandle(void) const
Get a safe handle to this object.
Definition: Handled.h:220
Base class providing an fe::Handle to the derived class.
Definition: Handled.h:209
BWORD isValid(void) const
Returns true if the pointer is set.
Definition: Handled.h:179
BWORD operator!=(const hp< T > &rhpLeft, const hp< T > &rhpRight)
Definition: Handled.h:258
BWORD operator==(const hp< T > &rhpLeft, const hp< X > &rhpRight)
Definition: Handled.h:237
T & operator*(void) const
Dereference to the handled pointer.
Definition: Handled.h:161