Author: mlandres
Date: Mon Jul 28 11:26:44 2008
New Revision: 10672
URL: http://svn.opensuse.org/viewcvs/zypp?rev=10672&view=rev
Log:
backup
Added:
trunk/libzypp/devel/devel.ma/testdrafts/SigTrackableFail.cc
Modified:
trunk/libzypp/devel/devel.ma/MaTest.cc
Modified: trunk/libzypp/devel/devel.ma/MaTest.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/devel/devel.ma/MaTest.cc?rev=10672&r1=10671&r2=10672&view=diff
==============================================================================
--- trunk/libzypp/devel/devel.ma/MaTest.cc (original)
+++ trunk/libzypp/devel/devel.ma/MaTest.cc Mon Jul 28 11:26:44 2008
@@ -17,16 +17,16 @@
return str << "Connected slots: " << obj.num_slots();
}
- namespace signals
- {
- std::ostream & operator<<( std::ostream & str, const connection & obj )
+ namespace signals
{
- return str << "Connection: "
- << ( obj.connected() ? '*' : '_' )
- << ( obj.blocked() ? 'B' : '_' )
- ;
+ std::ostream & operator<<( std::ostream & str, const connection & obj )
+ {
+ return str << "Connection: "
+ << ( obj.connected() ? '*' : '_' )
+ << ( obj.blocked() ? 'B' : '_' )
+ ;
+ }
}
- }
}
using namespace zypp;
@@ -56,7 +56,9 @@
void ping() const
{
static unsigned i = 0;
- _sigA( ++i );
+ ++i;
+ MIL << i << " -> " << _sigA << endl;
+ _sigA( i );
}
typedef signal SigA;
@@ -68,14 +70,16 @@
struct X : public trackable
{
- X() {++s;}
- X( const X & ) {++s;}
- ~X() {--s;}
+ X() {_s=++s;}
+ X( const X & ) {_s=++s;}
+ X& operator=( const X & ) { return *this; }
+ ~X() {_s=-_s;}
static int s;
+ int _s;
void pong( unsigned i ) const
{
- DBG << s << ' ' << i << endl;
+ DBG << _s << ' ' << i << endl;
}
};
@@ -91,6 +95,7 @@
--argc; ++argv; // skip arg 0
M m;
+ m.ping();
X xx;
m.siga().connect( boost::bind( &X::pong, &xx, _1 ) );
m.ping();
@@ -99,6 +104,11 @@
X x;
m.siga().connect( boost::bind( &X::pong, &x, _1 ) );
m.ping();
+
+ X y;
+ m.siga().connect( boost::bind( &X::pong, &y, _1 ) );
+ m.ping();
+
}
m.ping();
Added: trunk/libzypp/devel/devel.ma/testdrafts/SigTrackableFail.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/devel/devel.ma/testdrafts/SigTrackableFail.cc?rev=10672&view=auto
==============================================================================
--- trunk/libzypp/devel/devel.ma/testdrafts/SigTrackableFail.cc (added)
+++ trunk/libzypp/devel/devel.ma/testdrafts/SigTrackableFail.cc Mon Jul 28 11:26:44 2008
@@ -0,0 +1,121 @@
+#include <iostream>
+
+#include
+#include
+
+#include
+#include
+
+using std::endl;
+using std::cout;
+
+namespace boost
+{
+ template<class Tp>
+ std::ostream & operator<<( std::ostream & str, const signal<Tp> & obj )
+ {
+ return str << "Connected slots: " << obj.num_slots();
+ }
+
+ namespace signals
+ {
+ std::ostream & operator<<( std::ostream & str, const connection & obj )
+ {
+ return str << "Connection: "
+ << ( obj.connected() ? '*' : '_' )
+ << ( obj.blocked() ? 'B' : '_' )
+ ;
+ }
+ }
+}
+
+using namespace zypp;
+
+using boost::signal;
+using boost::signals::connection;
+using boost::signals::trackable;
+
+struct HelloWorld
+{
+ HelloWorld() {++i;}
+ HelloWorld(const HelloWorld &) {++i;}
+ ~HelloWorld() { --i;}
+
+ void operator()(unsigned) const
+ {
+ USR << "Hello, World! " << i << std::endl;
+ }
+
+ static int i;
+};
+
+int HelloWorld::i = 0;
+
+struct M
+{
+ void ping() const
+ {
+ static unsigned i = 0;
+ ++i;
+ MIL << i << " -> " << _sigA << endl;
+ _sigA( i );
+ }
+
+ typedef signal SigA;
+
+ SigA & siga() const { return _sigA; }
+
+ mutable SigA _sigA;
+};
+
+struct X : public trackable
+{
+ X() {_s=++s;}
+ X( const X & ) {_s=++s;}
+ X& operator=( const X & ) { return *this; }
+ ~X() {_s=-_s;}
+ static int s;
+ int _s;
+
+ void pong( unsigned i ) const
+ {
+ DBG << _s << ' ' << i << endl;
+ }
+};
+
+int X::s;
+
+/******************************************************************
+**
+** FUNCTION NAME : main
+** FUNCTION TYPE : int
+*/
+int main( int argc, const char * argv[] )
+{
+ --argc; ++argv; // skip arg 0
+
+ M m;
+ m.ping();
+ X xx;
+ m.siga().connect( boost::bind( &X::pong, &xx, _1 ) );
+ m.ping();
+
+ {
+ X x;
+ m.siga().connect( boost::bind( &X::pong, &x, _1 ) );
+ m.ping();
+
+ X y;
+ m.siga().connect( boost::bind( &X::pong, &y, _1 ) );
+ m.ping();
+
+ }
+
+ m.ping();
+
+ ///////////////////////////////////////////
+
+ INT << "---STOP" << endl;
+ return 0;
+}
+
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org