diff --git a/include/utils/StrongPointer.h b/include/utils/StrongPointer.h index 40aebfd3c..aba9577da 100644 --- a/include/utils/StrongPointer.h +++ b/include/utils/StrongPointer.h @@ -26,9 +26,6 @@ // --------------------------------------------------------------------------- namespace android { -class TextOutput; -TextOutput& printStrongPointer(TextOutput& to, const void* val); - template class wp; // --------------------------------------------------------------------------- @@ -58,9 +55,8 @@ inline bool operator _op_ (const wp& o) const { \ // --------------------------------------------------------------------------- -template -class sp -{ +template +class sp { public: inline sp() : m_ptr(0) { } @@ -110,92 +106,93 @@ private: #undef COMPARE -template -TextOutput& operator<<(TextOutput& to, const sp& val); - // --------------------------------------------------------------------------- // No user serviceable parts below here. template sp::sp(T* other) -: m_ptr(other) - { - if (other) other->incStrong(this); - } + : m_ptr(other) { + if (other) + other->incStrong(this); +} template sp::sp(const sp& other) -: m_ptr(other.m_ptr) - { - if (m_ptr) m_ptr->incStrong(this); - } + : m_ptr(other.m_ptr) { + if (m_ptr) + m_ptr->incStrong(this); +} template template -sp::sp(U* other) : m_ptr(other) -{ - if (other) ((T*)other)->incStrong(this); +sp::sp(U* other) + : m_ptr(other) { + if (other) + ((T*) other)->incStrong(this); } template template sp::sp(const sp& other) -: m_ptr(other.m_ptr) - { - if (m_ptr) m_ptr->incStrong(this); - } - -template -sp::~sp() -{ - if (m_ptr) m_ptr->decStrong(this); + : m_ptr(other.m_ptr) { + if (m_ptr) + m_ptr->incStrong(this); } template -sp& sp::operator = (const sp& other) { +sp::~sp() { + if (m_ptr) + m_ptr->decStrong(this); +} + +template +sp& sp::operator =(const sp& other) { T* otherPtr(other.m_ptr); - if (otherPtr) otherPtr->incStrong(this); - if (m_ptr) m_ptr->decStrong(this); + if (otherPtr) + otherPtr->incStrong(this); + if (m_ptr) + m_ptr->decStrong(this); m_ptr = otherPtr; return *this; } template -sp& sp::operator = (T* other) -{ - if (other) other->incStrong(this); - if (m_ptr) m_ptr->decStrong(this); +sp& sp::operator =(T* other) { + if (other) + other->incStrong(this); + if (m_ptr) + m_ptr->decStrong(this); m_ptr = other; return *this; } template template -sp& sp::operator = (const sp& other) -{ +sp& sp::operator =(const sp& other) { T* otherPtr(other.m_ptr); - if (otherPtr) otherPtr->incStrong(this); - if (m_ptr) m_ptr->decStrong(this); + if (otherPtr) + otherPtr->incStrong(this); + if (m_ptr) + m_ptr->decStrong(this); m_ptr = otherPtr; return *this; } template template -sp& sp::operator = (U* other) -{ - if (other) ((T*)other)->incStrong(this); - if (m_ptr) m_ptr->decStrong(this); +sp& sp::operator =(U* other) { + if (other) + ((T*) other)->incStrong(this); + if (m_ptr) + m_ptr->decStrong(this); m_ptr = other; return *this; } -template -void sp::force_set(T* other) -{ +template +void sp::force_set(T* other) { other->forceIncStrong(this); m_ptr = other; } template -void sp::clear() -{ +void sp::clear() { if (m_ptr) { m_ptr->decStrong(this); m_ptr = 0;