backup
authorMichael Andres <ma@suse.de>
Thu, 19 Jun 2008 15:42:55 +0000 (15:42 +0000)
committerMichael Andres <ma@suse.de>
Thu, 19 Jun 2008 15:42:55 +0000 (15:42 +0000)
devel/devel.ma/CMakeLists.txt
devel/devel.ma/MaTest.cc
devel/devel.ma/Main.cc

index 7ec27f6..6da51e9 100644 (file)
@@ -44,7 +44,7 @@ FOREACH( loop_var MaTest )
       ${loop_var}.cc
    )
    TARGET_LINK_LIBRARIES( ${loop_var}
-      zypp
+      zypp boost_signals
       ${QT_LIBRARIES}
    )
 ENDFOREACH( loop_var )
index 9bc0b50..5d743e3 100644 (file)
@@ -1,12 +1,86 @@
 #include <iostream>
+
+#include <boost/signal.hpp>
+#include <boost/bind.hpp>
+
 #include <zypp/base/LogTools.h>
 #include <zypp/base/Easy.h>
-#include <zypp/sat/Pool.h>
 
 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;
+    _sigA( ++i );
+  }
+
+  typedef signal<void(unsigned)> SigA;
+
+  SigA & siga() const { return _sigA; }
+
+  mutable SigA _sigA;
+};
+
+struct X : public trackable
+{
+  X() {++s;}
+  X( const X & ) {++s;}
+  ~X() {--s;}
+  static int s;
+
+  void pong( unsigned i ) const
+  {
+    DBG << s << ' ' << i << endl;
+  }
+};
+
+int X::s;
+
 /******************************************************************
 **
 **      FUNCTION NAME : main
@@ -15,24 +89,23 @@ using namespace zypp;
 int main( int argc, const char * argv[] )
 {
   --argc; ++argv; // skip arg 0
-  sat::Pool satpool( sat::Pool::instance() );
 
-  for ( ; argc;  --argc, ++argv )
+  M m;
+  X xx;
+  m.siga().connect( boost::bind( &X::pong, &xx, _1 ) );
+  m.ping();
+
   {
-    cout << "Read: " << argv[0] << endl;
-    satpool.addRepoSolv( argv[0] );
+    X x;
+    m.siga().connect( boost::bind( &X::pong, &x, _1 ) );
+    m.ping();
   }
 
-  cout << "Done: " << satpool << endl;
+  m.ping();
 
-  if ( getenv("VERBOSE") )
-  {
-    for_( it, satpool.solvablesBegin(), satpool.solvablesEnd() )
-    {
-      cout << dump(*it) << endl;
-    }
-  }
+  ///////////////////////////////////////////
 
+  INT << "---STOP" << endl;
   return 0;
 }
 
index 1fa052d..2457e19 100644 (file)
@@ -15,42 +15,9 @@ using namespace zypp;
 
 ///////////////////////////////////////////////////////////////////
 
-RepoManager makeRepoManager( const Pathname & mgrdir_r )
-{
-
-  RepoManagerOptions mgropt;
-  mgropt.repoCachePath    = mgrdir_r/"cache";
-  mgropt.repoRawCachePath = mgrdir_r/"raw_cache";
-  mgropt.knownReposPath   = mgrdir_r/"repos";
-
-  return RepoManager( mgropt );
-}
-
-struct Impl : public base::ReferenceCounted
-{
-  Impl() : i(13) {}
-  int i;
-};
-DEFINE_PTR_TYPE(Impl);
-IMPL_PTR_TYPE(Impl);
+static const Pathname sysRoot( getenv("SYSROOT") ? getenv("SYSROOT") : "/Local/ROOT" );
 
-inline std::ostream & operator<<( std::ostream & str, const Impl & obj )
-{ return str << &obj; }
-
-#define TCODE \
-  SEC << endl; \
-  MIL << "n " << _nimpl << endl; \
-  MIL << "n " << (_nimpl?1:0) << endl; \
-  MIL << "p " << _pimpl << endl; \
-  MIL << "p " << (_pimpl?1:0) << endl; \
-  MIL << "P " << _Pimpl << endl; \
-  MIL << "P " << (_Pimpl?1:0) << endl; \
-  MIL << "= " << (_nimpl == _pimpl) << endl; \
-  MIL << "! " << (_nimpl != _pimpl) << endl; \
-  MIL << "= " << (_Pimpl == _pimpl) << endl; \
-  MIL << "! " << (_Pimpl != _pimpl) << endl; \
-  MIL << "= " << (_pimpl == _pimpl) << endl; \
-  MIL << "! " << (_pimpl != _pimpl) << endl;
+///////////////////////////////////////////////////////////////////
 
 /******************************************************************
 **
@@ -61,53 +28,21 @@ int main( int argc, char * argv[] )
 {
   INT << "===[START]==========================================" << endl;
 
-  {
-    RW_pointer<Impl,rw_pointer::Intrusive<Impl> > _nimpl;
-    RW_pointer<Impl,rw_pointer::Intrusive<Impl> > _pimpl(new Impl);
-    RW_pointer<Impl,rw_pointer::Intrusive<Impl> > _Pimpl(new Impl);
-    TCODE;
-  }
-  {
-    RW_pointer<Impl,rw_pointer::Shared<Impl> >    _nimpl;
-    RW_pointer<Impl,rw_pointer::Shared<Impl> >    _pimpl(new Impl);
-    RW_pointer<Impl,rw_pointer::Shared<Impl> >    _Pimpl(new Impl);
-   TCODE;
-  }
-  {
-    RW_pointer<Impl,rw_pointer::Scoped<Impl> >    _nimpl;
-    RW_pointer<Impl,rw_pointer::Scoped<Impl> >    _pimpl(new Impl);
-    RW_pointer<Impl,rw_pointer::Scoped<Impl> >    _Pimpl(new Impl);
-    TCODE;
-  }
-
-  INT << "===[END]============================================" << endl << endl;
-  return 0;
-
-  RepoManager repoManager( makeRepoManager( "/ROOT" ) );
-  RepoInfoList repos = repoManager.knownRepositories();
-  SEC << repos << endl;
+  //TmpDir tmp_dir;
+  //KeyRing keyring( tmp_dir.path() );
 
-  if ( repos.empty() )
   {
-    RepoInfo nrepo;
-    nrepo
-       .setAlias( "factorytest" )
-       .setName( "Test Repo for factory." )
-       .setEnabled( true )
-       .setAutorefresh( false )
-       .addBaseUrl( Url("ftp://dist.suse.de/install/stable-x86/") );
-
-    repoManager.addRepository( nrepo );
-    repos = repoManager.knownRepositories();
-    SEC << repos << endl;
-
-//    SEC << "refreshMetadat" << endl;
-//    repoManager.refreshMetadata( nrepo );
-//    SEC << "buildCache" << endl;
-//    repoManager.buildCache( nrepo );
-//    SEC << "------" << endl;
+    Measure x( "INIT TARGET" );
+    {
+      {
+        //zypp::base::LogControl::TmpLineWriter shutUp;
+        getZYpp()->initializeTarget( sysRoot );
+      }
+      //getZYpp()->target()->load();
+    }
   }
 
+
   INT << "===[END]============================================" << endl << endl;
   return 0;
 }