Mailinglist Archive: zypp-commit (301 mails)

< Previous Next >
[zypp-commit] r7707 - /branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/base/PtrTypes.h
  • From: mlandres@xxxxxxxxxxxxxxxx
  • Date: Tue, 30 Oct 2007 16:32:07 -0000
  • Message-id: <20071030163208.1D1D037513@xxxxxxxxxxxxxxxx>
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<class _D, class _Ptr>
+ inline bool
+ operator==( const RW_pointer<_D, _Ptr> & lhs, const RW_pointer<_D, _Ptr>
& rhs )
+ {
+ return( lhs.get() == rhs.get() );
+ }
+
+ /** \relates RW_pointer */
+ template<class _D, class _Ptr>
+ inline bool
+ operator!=( const RW_pointer<_D, _Ptr> & lhs, const RW_pointer<_D, _Ptr>
& rhs )
+ {
+ return ! ( lhs == rhs );
+ }
+
///////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////
@@ -402,10 +457,25 @@
return str << std::string("NULL");
}

+ /** \relates RWCOW_pointer */
+ template<class _D, class _Ptr>
+ inline bool
+ operator==( const RWCOW_pointer<_D, _Ptr> & lhs, const RWCOW_pointer<_D,
_Ptr> & rhs )
+ {
+ return( lhs.get() == rhs.get() );
+ }
+
+ /** \relates RWCOW_pointer */
+ template<class _D, class _Ptr>
+ inline bool
+ operator!=( const RWCOW_pointer<_D, _Ptr> & lhs, const RWCOW_pointer<_D,
_Ptr> & rhs )
+ {
+ return ! ( lhs == rhs );
+ }
+
///////////////////////////////////////////////////////////////////

/*@}*/
-
/////////////////////////////////////////////////////////////////
} // namespace zypp
///////////////////////////////////////////////////////////////////

--
To unsubscribe, e-mail: zypp-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: zypp-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages