Author: mlandres
Date: Tue Oct 30 17:32:07 2007
New Revision: 7707
URL: http://svn.opensuse.org/viewcvs/zypp?rev=7707&view=rev
Log:
fix missing operator==, add scoped RW_Pointer
Modified:
branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/base/PtrTypes.h
Modified: branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/base/PtrTypes.h
URL: http://svn.opensuse.org/viewcvs/zypp/branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/base/PtrTypes.h?rev=7707&r1=7706&r2=7707&view=diff
==============================================================================
--- branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/base/PtrTypes.h (original)
+++ branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/base/PtrTypes.h Tue Oct 30 17:32:07 2007
@@ -97,25 +97,46 @@
/** */
using boost::dynamic_pointer_cast;
- /** \relates shared_ptr Stream output. */
- template<class _D>
- inline std::ostream &
- operator<<( std::ostream & str, const shared_ptr<_D> & obj )
- {
- if ( obj )
- return str << *obj;
- return str << std::string("NULL");
- }
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////
+namespace std
+{ /////////////////////////////////////////////////////////////////
- /** \relates intrusive_ptr Stream output. */
- template<class _D>
- inline std::ostream &
- operator<<( std::ostream & str, const intrusive_ptr<_D> & obj )
- {
- if ( obj )
- return str << *obj;
- return str << std::string("NULL");
- }
+ // namespace sub {
+ // class Foo;
+ // typedef zypp::intrusive_ptr<Foo> Foo_Ptr; // see DEFINE_PTR_TYPE(NAME) macro below
+ // }
+
+ // Defined in namespace std g++ finds the output operator (König-Lookup),
+ // even if we typedef the pointer in a different namespace than ::zypp.
+ // Otherwise we had to define an output operator always in the same namespace
+ // as the typedef (else g++ will just print the pointer value).
+
+ /** \relates zypp::shared_ptr Stream output. */
+ template<class _D>
+ inline std::ostream & operator<<( std::ostream & str, const zypp::shared_ptr<_D> & obj )
+ {
+ if ( obj )
+ return str << *obj;
+ return str << std::string("NULL");
+ }
+
+ /** \relates zypp::intrusive_ptr Stream output. */
+ template<class _D>
+ inline std::ostream & operator<<( std::ostream & str, const zypp::intrusive_ptr<_D> & obj )
+ {
+ if ( obj )
+ return str << *obj;
+ return str << std::string("NULL");
+ }
+ /////////////////////////////////////////////////////////////////
+} // namespace std
+///////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
//
@@ -162,7 +183,25 @@
long use_count( const _Ptr & ptr_r ) const
{ return ptr_r ? ptr_r->refCount() : 0; }
};
- }
+
+ template<class _D>
+ struct Scoped
+ {
+ typedef scoped_ptr<_D> _Ptr;
+ typedef scoped_ptr<const _D> _constPtr;
+ /** Check whether pointer is not shared. */
+ bool unique( const _constPtr & ptr_r )
+ { return true; }
+ bool unique( const _Ptr & ptr_r )
+ { return true; }
+ /** Return number of references. */
+ long use_count( const _constPtr & ptr_r ) const
+ { return ptr_r ? 1 : 0; }
+ long use_count( const _Ptr & ptr_r ) const
+ { return ptr_r ? 1 : 0; }
+ };
+
+ }
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
@@ -288,6 +327,22 @@
return str << std::string("NULL");
}
+ /** \relates RW_pointer */
+ template