backup
authorMichael Andres <ma@suse.de>
Sat, 11 Mar 2006 00:27:06 +0000 (00:27 +0000)
committerMichael Andres <ma@suse.de>
Sat, 11 Mar 2006 00:27:06 +0000 (00:27 +0000)
devel/devel.ma/Main.cc
devel/devel.ma/Parse.cc
devel/devel.ma/Test.cc [new file with mode: 0644]
devel/devel.ma/Tools.h
devel/devel.ma/ma_test
devel/devel.ma/main.cc
devel/devel.ma/testdrafts/Arch.cc
devel/devel.ma/testdrafts/Locale.cc [new file with mode: 0644]

index 3696277..ec86332 100644 (file)
 #include <list>
 #include <set>
 
-#include "Printing.h"
+#include "Tools.h"
 
 #include <zypp/base/LogControl.h>
-#include <zypp/base/String.h>
-#include <zypp/base/Exception.h>
-#include <zypp/base/PtrTypes.h>
-#include <zypp/base/Iterator.h>
-#include <zypp/base/Algorithm.h>
-
-#include <zypp/Arch.h>
+#include <zypp/ResStatus.h>
 
 using namespace std;
 using namespace zypp;
-using namespace zypp::functor;
-
-inline const char * compResult( int res )
-{
-  return( res ? ( res < 0 ? "<" : ">" ) : "=" );
-}
-
-template<class _Iter, class _Function>
-  inline void sym_compare( _Iter begin, _Iter end, _Function fnc )
-  {
-    for ( _Iter l = begin; l != end; ++l )
-      for ( _Iter r = begin; r != end; ++r )
-        fnc( *l, *r );
-  }
-
-template<class _LIter, class _RIter, class _BinaryFunction>
-  inline _BinaryFunction
-  nest_for_earch( _LIter lbegin, _LIter lend,
-                  _RIter rbegin, _RIter rend,
-                  _BinaryFunction fnc )
-  {
-    for ( ; lbegin != lend; ++lbegin )
-      for ( _RIter r = rbegin; r != rend; ++r )
-        fnc( *lbegin, *r );
-    return fnc;
-  }
-
-template<class _Iter, class _BinaryFunction>
-  inline _BinaryFunction
-  nest_for_earch( _Iter begin, _Iter end,
-                  _BinaryFunction fnc )
-  { return nest_for_earch( begin, end, begin, end, fnc ); }
-
-
-template<class _Iter, class _Function>
-  inline void sym_compare( _Iter begin, _Iter end )
-  {
-    sym_compare( begin, end, _Function() );
-  }
-
-inline list<Arch> archList()
-{
-  list<Arch> ret;
-  ret.push_back( Arch_noarch );
-  ret.push_back( Arch_src );
-  ret.push_back( Arch_x86_64 );
-  ret.push_back( Arch_athlon );
-  ret.push_back( Arch_i686 );
-  ret.push_back( Arch_i586 );
-  ret.push_back( Arch_i486 );
-  ret.push_back( Arch_i386 );
-  ret.push_back( Arch_s390x );
-  ret.push_back( Arch_s390 );
-  ret.push_back( Arch_ppc64 );
-  ret.push_back( Arch_ppc );
-  ret.push_back( Arch_ia64 );
-  ret.push_back( Arch( "unknown" ) );
-  ret.push_back( Arch( "unknown2" ) );
-  ret.push_back( Arch() );
-  ret.push_back( Arch("") );
-  return ret;
-}
-
-static list<Arch> archlist( archList() );
-static set<Arch>  archset( archlist.begin(), archlist.end() );
-
-struct CompatTest
-{
-  void operator()( const Arch & lhs, const Arch & rhs ) const
-  {
 
-    DBG << str::form( "%-10s --> %-10s : %6s : %s",
-                      lhs.asString().c_str(),
-                      rhs.asString().c_str(),
-                      ( lhs.compatibleWith( rhs ) ? "COMPAT" : "no" ),
-                      compResult( lhs.compare( rhs ) ) )
-
-        << std::endl;
-  }
-};
-
-struct OrderByCompare : public std::binary_function<Arch, Arch, bool>
-{
-  bool operator()( const Arch & lhs, const Arch & rhs ) const
-  { return lhs.compare( rhs ) < 0; }
-};
 
 /******************************************************************
 **
@@ -111,22 +20,24 @@ int main( int argc, char * argv[] )
 {
   INT << "===[START]==========================================" << endl;
 
-  // All archs in test
-  print( archlist );
+  ResStatus stat;
+  MIL << stat << endl;
+
+  DBG << stat.setSoftTransact( true, ResStatus::SOLVER, ResStatus::APPL_LOW )
+      << ' ' << stat << endl;
+
+  DBG << stat.setTransact( false, ResStatus::APPL_LOW )
+      << ' ' << stat << endl;
 
-  // set ordering
-  print( archset );
+  DBG << stat.setSoftTransact( true, ResStatus::SOLVER, ResStatus::APPL_LOW )
+      << ' ' << stat << endl;
 
-  // compatibleWith
-  sym_compare( archset.begin(), archset.end(), CompatTest() );
+  DBG << stat.setTransact( false, ResStatus::APPL_HIGH )
+      << ' ' << stat << endl;
 
-  // compare order
-  typedef set<Arch,OrderByCompare> OrderedArch;
+  DBG << stat.setSoftTransact( true, ResStatus::SOLVER, ResStatus::APPL_LOW )
+      << ' ' << stat << endl;
 
-  OrderedArch a( archset.begin(), archset.end() );
-  print( a );
-  OrderedArch b( archset.rbegin(), archset.rend() );
-  print( b );
 
   INT << "===[END]============================================" << endl << endl;
   return 0;
index 9173265..200a644 100644 (file)
@@ -23,7 +23,9 @@
 #include "zypp/ResPool.h"
 #include "zypp/ResFilters.h"
 #include "zypp/CapFilters.h"
+#include "zypp/Package.h"
 
+#include <zypp/SourceManager.h>
 #include <zypp/SourceFactory.h>
 #include <zypp/source/susetags/SuseTagsImpl.h>
 
@@ -72,7 +74,7 @@ namespace zypp
 } // namespace zypp
 ///////////////////////////////////////////////////////////////////
 
-struct X : public base::ProvideNumericId<X>
+struct X : public base::ProvideNumericId<X,unsigned>
 {
 
 };
@@ -94,15 +96,20 @@ template<>
     bool operator()( const ui::Selectable::Ptr & obj )
     {
       if ( obj ) {
+        obj->set_status( ui::S_Install );
         USR << *obj << std::endl;
         std::for_each( obj->availableBegin(), obj->availableEnd(),
                        PrintPtr<ResObject::constPtr>() );
+        if ( obj->availableBegin() != obj->availableEnd() )
+          SEC << PrintPtr<ResObject::constPtr>()(*obj->availableBegin() )
+              << " " << asKind<Package>(*obj->availableBegin())->vendor() << endl;
       }
       else
         USR << "(NULL)" << std::endl;
       return true;
     }
   };
+
 /******************************************************************
 **
 **      FUNCTION NAME : main
@@ -117,7 +124,17 @@ int main( int argc, char * argv[] )
   if (argc >= 2 )
     infile = argv[1];
 
-  Source_Ref src( createSource("dir:/Local/ma/zypp/libzypp/devel/devel.ma/SOURCE") );
+  DBG << Source_Ref() << endl;
+  DBG << Source_Ref::noSource << endl;
+  Source_Ref src( createSource("dir:/Local/ma/zypp/libzypp/devel/devel.ma") );
+  DBG << *SourceManager::sourceManager() << endl;
+  SourceManager::sourceManager()->addSource( src );
+  SourceManager::sourceManager()->removeSource( 0 );
+  SourceManager::sourceManager()->removeSource( src.numericId() );
+  return 0;
+
+  //Source_Ref src( createSource("dir:/Local/ma/zypp/libzypp/devel/devel.ma") );
+  //Source_Ref src( createSource("dir:/Local/ma/zypp/libzypp/devel/devel.ma/SOURCE") );
   Source_Ref trg( createSource("dir:/Local/ma/zypp/libzypp/devel/devel.ma/TARGET") );
 
   ResPoolManager pool;
@@ -129,10 +146,16 @@ int main( int argc, char * argv[] )
   std::for_each( query.begin(), query.end(), Print<PoolItem>() );
 
   ResPoolProxy y2pm( query );
+  y2pm.saveState<Package>();
   std::for_each( y2pm.byKindBegin<Package>(), y2pm.byKindEnd<Package>(),
                  PrintPtr<ui::Selectable::Ptr>() );
 
 
+
+  y2pm.saveState<Package>();
+  SEC << y2pm.diffState<Package>() << endl;
+
+
   INT << "===[END]============================================" << endl << endl;
   return 0;
 }
diff --git a/devel/devel.ma/Test.cc b/devel/devel.ma/Test.cc
new file mode 100644 (file)
index 0000000..1644e70
--- /dev/null
@@ -0,0 +1,102 @@
+#include <iostream>
+
+#include "zypp/base/LogControl.h"
+
+#include "zypp/Locale.h"
+
+
+using std::endl;
+using namespace zypp;
+
+inline std::string vstr( const char * str )
+{
+  std::string ret;
+  if ( str )
+    {
+      ret+="\"";
+      ret+=str;
+      ret+="\"";
+    }
+  return ret;
+}
+
+void test( const Locale & val_r )
+{
+  DBG << " <<:        " << (val_r) << endl;
+  DBG << " code:      " << (val_r.code()) << endl;
+  DBG << " name:      " << (val_r.name()) << endl;
+  DBG << " ==noCode:  " << (val_r == Locale::noCode) << endl;
+  DBG << " !=noCode:  " << (val_r != Locale::noCode) << endl;
+  DBG << " Language:  " << (val_r.language()) << endl;
+  DBG << " Country:   " << (val_r.country()) << endl;
+}
+
+void test( const LanguageCode & val_r )
+{
+  DBG << " <<:        " << (val_r) << endl;
+  DBG << " code:      " << (val_r.code()) << endl;
+  DBG << " name:      " << (val_r.name()) << endl;
+  DBG << " ==noCode:  " << (val_r == LanguageCode::noCode) << endl;
+  DBG << " !=noCode:  " << (val_r != LanguageCode::noCode) << endl;
+  DBG << " ==default: " << (val_r == LanguageCode::useDefault) << endl;
+  DBG << " !=default: " << (val_r != LanguageCode::useDefault) << endl;
+}
+
+void test( const CountryCode & val_r )
+{
+  DBG << " <<:       " << (val_r) << endl;
+  DBG << " code:     " << (val_r.code()) << endl;
+  DBG << " name:     " << (val_r.name()) << endl;
+  DBG << " ==noCode: " << (val_r == CountryCode::noCode) << endl;
+  DBG << " !=noCode: " << (val_r != CountryCode::noCode) << endl;
+}
+
+void testLocale( const char * str = 0 )
+{
+  MIL << "Locale(" << vstr(str) << ")" << endl;
+  test( str ? Locale( str ) : Locale() );
+}
+
+void testLanguage( const char * str = 0 )
+{
+  MIL << "Language(" << vstr(str) << ")" << endl;
+  test( str ? LanguageCode( str ) : LanguageCode() );
+}
+
+void testCountry( const char * str = 0 )
+{
+  MIL << "Country(" << vstr(str) << ")" << endl;
+  test( str ? CountryCode( str ) : CountryCode() );
+}
+
+/******************************************************************
+**
+**      FUNCTION NAME : main
+**      FUNCTION TYPE : int
+*/
+int main( int argc, char * argv[] )
+{
+  //zypp::base::LogControl::instance().logfile( "xxx" );
+  INT << "===[START]==========================================" << endl;
+
+  testLocale();
+  testLocale( "" );
+  testLocale( "en" );
+  testLocale( "de_DE" );
+  testLocale( "C" );
+  testLocale( "POSIX" );
+  testLocale( "default" );
+
+  testLanguage();
+  testLanguage( "" );
+  testLanguage( "en" );
+  testLanguage( "default" );
+
+  testCountry();
+  testCountry( "" );
+  testCountry( "US" );
+  testCountry( "DE" );
+
+  INT << "===[END]============================================" << endl;
+  return 0;
+}
index 9c5cb72..29b1808 100644 (file)
@@ -68,12 +68,22 @@ template<class _Container>
 ///////////////////////////////////////////////////////////////////
 inline Source_Ref createSource( const std::string & url_r )
 {
+  Source_Ref ret;
   Measure x( "createSource: " + url_r );
-  Source_Ref ret( SourceFactory().createFrom( Url(url_r) ) );
+  try
+    {
+      ret = SourceFactory().createFrom( Url(url_r) );
+    }
+  catch ( const Exception & )
+    {
+      return Source_Ref::noSource;
+    }
   x.start( "parseSource: " + url_r );
   ret.resolvables();
   x.stop();
+  MIL << "Content " << ret << "{" << endl;
   rstats( ret.resolvables() );
+  MIL << "}" << endl;
 
   return ret;
 }
index d1f6e33..76b9c13 100755 (executable)
@@ -32,4 +32,5 @@ fi
 #$MAKE -C ../../zypp || exit 1
 $MAKE $PRG || exit 1
 
+export ZYPP_LOGFILE=-
 ./$PRG "$@" 2> $LPIPE
index 539e6d2..257e63b 100644 (file)
@@ -6,41 +6,6 @@
 using std::string;
 using std::map;
 
-struct Resolvable::Impl
-{
-  string _kind;
-};
-
-Resolvable::Resolvable( const string kind_r /*NVRA*/ )
-: _impl( new Impl )
-{
-  _impl->_kind = kind_r;
-}
-Resolvable::~Resolvable()
-{}
-std::ostream & Resolvable::dumpOn( std::ostream & str ) const
-{
-  return str << '[' << kind() << ']' << name();
-}
-
-string Resolvable::kind() const { return _impl->_kind; }
-string Resolvable::name() const { return "n"; }
-
-
-Object::Object( const string kind_r /*NVRA*/ )
-: Resolvable( kind_r )
-{}
-Object::~Object()
-{}
-
-string       Object::summary()         const { return impl().summary(); }
-list<string> Object::description()     const { return impl().description(); }
-
-
-Package::Package( /*NVRA*/ )
-: Object( "Package" /*NVRA*/ )
-{}
-Package::~Package()
 {}
 
 string Package::packagedata() const { return impl().packagedata(); }
index 8823525..28d7ad9 100644 (file)
@@ -4,7 +4,7 @@
 
 #include "Printing.h"
 
-#include <zypp/base/Logger.h>
+#include <zypp/base/LogControl.h>
 #include <zypp/base/String.h>
 #include <zypp/base/Exception.h>
 #include <zypp/base/PtrTypes.h>
@@ -12,6 +12,8 @@
 #include <zypp/base/Algorithm.h>
 
 #include <zypp/Arch.h>
+#include <zypp/Bit.h>
+#include <zypp/RelCompare.h>
 
 using namespace std;
 using namespace zypp;
@@ -29,6 +31,26 @@ template<class _Iter, class _Function>
       for ( _Iter r = begin; r != end; ++r )
         fnc( *l, *r );
   }
+
+template<class _LIter, class _RIter, class _BinaryFunction>
+  inline _BinaryFunction
+  nest_for_earch( _LIter lbegin, _LIter lend,
+                  _RIter rbegin, _RIter rend,
+                  _BinaryFunction fnc )
+  {
+    for ( ; lbegin != lend; ++lbegin )
+      for ( _RIter r = rbegin; r != rend; ++r )
+        fnc( *lbegin, *r );
+    return fnc;
+  }
+
+template<class _Iter, class _BinaryFunction>
+  inline _BinaryFunction
+  nest_for_earch( _Iter begin, _Iter end,
+                  _BinaryFunction fnc )
+  { return nest_for_earch( begin, end, begin, end, fnc ); }
+
+
 template<class _Iter, class _Function>
   inline void sym_compare( _Iter begin, _Iter end )
   {
@@ -54,6 +76,7 @@ inline list<Arch> archList()
   ret.push_back( Arch( "unknown" ) );
   ret.push_back( Arch( "unknown2" ) );
   ret.push_back( Arch() );
+  ret.push_back( Arch("") );
   return ret;
 }
 
@@ -81,6 +104,14 @@ struct OrderByCompare : public std::binary_function<Arch, Arch, bool>
   { return lhs.compare( rhs ) < 0; }
 };
 
+
+void dumpOn( const Arch::CompatSet & s )
+{
+  SEC << str::join( make_transform_iterator( s.begin(), std::mem_fun_ref(&Arch::asString) ),
+                    make_transform_iterator( s.end(), std::mem_fun_ref(&Arch::asString) ) )
+  << endl;
+}
+
 /******************************************************************
 **
 **      FUNCTION NAME : main
@@ -107,6 +138,19 @@ int main( int argc, char * argv[] )
   OrderedArch b( archset.rbegin(), archset.rend() );
   print( b );
 
+  dumpOn( Arch::compatSet( Arch_noarch ) );
+  dumpOn( Arch::compatSet( Arch_i486 ) );
+  dumpOn( Arch::compatSet( Arch_x86_64 ) );
+  dumpOn( Arch::compatSet( Arch("Foo") ) );
+
+  typedef set<Arch,CompareByGT<Arch> > AS;
+  Arch::CompatSet x( Arch::compatSet(Arch_x86_64) );
+  AS rx( x.begin(), x.end() );
+  INT << str::join( make_transform_iterator( rx.begin(), std::mem_fun_ref(&Arch::asString) ),
+                    make_transform_iterator( rx.end(), std::mem_fun_ref(&Arch::asString) ) )
+  << endl;
+
+
   INT << "===[END]============================================" << endl << endl;
   return 0;
 }
diff --git a/devel/devel.ma/testdrafts/Locale.cc b/devel/devel.ma/testdrafts/Locale.cc
new file mode 100644 (file)
index 0000000..1644e70
--- /dev/null
@@ -0,0 +1,102 @@
+#include <iostream>
+
+#include "zypp/base/LogControl.h"
+
+#include "zypp/Locale.h"
+
+
+using std::endl;
+using namespace zypp;
+
+inline std::string vstr( const char * str )
+{
+  std::string ret;
+  if ( str )
+    {
+      ret+="\"";
+      ret+=str;
+      ret+="\"";
+    }
+  return ret;
+}
+
+void test( const Locale & val_r )
+{
+  DBG << " <<:        " << (val_r) << endl;
+  DBG << " code:      " << (val_r.code()) << endl;
+  DBG << " name:      " << (val_r.name()) << endl;
+  DBG << " ==noCode:  " << (val_r == Locale::noCode) << endl;
+  DBG << " !=noCode:  " << (val_r != Locale::noCode) << endl;
+  DBG << " Language:  " << (val_r.language()) << endl;
+  DBG << " Country:   " << (val_r.country()) << endl;
+}
+
+void test( const LanguageCode & val_r )
+{
+  DBG << " <<:        " << (val_r) << endl;
+  DBG << " code:      " << (val_r.code()) << endl;
+  DBG << " name:      " << (val_r.name()) << endl;
+  DBG << " ==noCode:  " << (val_r == LanguageCode::noCode) << endl;
+  DBG << " !=noCode:  " << (val_r != LanguageCode::noCode) << endl;
+  DBG << " ==default: " << (val_r == LanguageCode::useDefault) << endl;
+  DBG << " !=default: " << (val_r != LanguageCode::useDefault) << endl;
+}
+
+void test( const CountryCode & val_r )
+{
+  DBG << " <<:       " << (val_r) << endl;
+  DBG << " code:     " << (val_r.code()) << endl;
+  DBG << " name:     " << (val_r.name()) << endl;
+  DBG << " ==noCode: " << (val_r == CountryCode::noCode) << endl;
+  DBG << " !=noCode: " << (val_r != CountryCode::noCode) << endl;
+}
+
+void testLocale( const char * str = 0 )
+{
+  MIL << "Locale(" << vstr(str) << ")" << endl;
+  test( str ? Locale( str ) : Locale() );
+}
+
+void testLanguage( const char * str = 0 )
+{
+  MIL << "Language(" << vstr(str) << ")" << endl;
+  test( str ? LanguageCode( str ) : LanguageCode() );
+}
+
+void testCountry( const char * str = 0 )
+{
+  MIL << "Country(" << vstr(str) << ")" << endl;
+  test( str ? CountryCode( str ) : CountryCode() );
+}
+
+/******************************************************************
+**
+**      FUNCTION NAME : main
+**      FUNCTION TYPE : int
+*/
+int main( int argc, char * argv[] )
+{
+  //zypp::base::LogControl::instance().logfile( "xxx" );
+  INT << "===[START]==========================================" << endl;
+
+  testLocale();
+  testLocale( "" );
+  testLocale( "en" );
+  testLocale( "de_DE" );
+  testLocale( "C" );
+  testLocale( "POSIX" );
+  testLocale( "default" );
+
+  testLanguage();
+  testLanguage( "" );
+  testLanguage( "en" );
+  testLanguage( "default" );
+
+  testCountry();
+  testCountry( "" );
+  testCountry( "US" );
+  testCountry( "DE" );
+
+  INT << "===[END]============================================" << endl;
+  return 0;
+}