Author: mlandres
Date: Thu Jan 10 17:56:09 2008
New Revision: 8258
URL: http://svn.opensuse.org/viewcvs/zypp?rev=8258&view=rev
Log:
backup
Added:
branches/tmp/ma/jump_sat/libzypp/devel/devel.ma/DumpSolv.cc
branches/tmp/ma/jump_sat/libzypp/tests/zypp/ResKind_test.cc
branches/tmp/ma/jump_sat/libzypp/zypp/ResKind.cc
branches/tmp/ma/jump_sat/libzypp/zypp/ResKind.h
branches/tmp/ma/jump_sat/libzypp/zypp/sat/IdStrType.h
Removed:
branches/tmp/ma/jump_sat/libzypp/zypp/ResTraits.cc
Modified:
branches/tmp/ma/jump_sat/libzypp/devel/devel.ma/CMakeLists.txt
branches/tmp/ma/jump_sat/libzypp/devel/devel.ma/NewPool.cc
branches/tmp/ma/jump_sat/libzypp/devel/devel.ma/Parse.cc
branches/tmp/ma/jump_sat/libzypp/tests/zypp/CMakeLists.txt
branches/tmp/ma/jump_sat/libzypp/zypp/@DOXYGEN/DOXYGEN.h
branches/tmp/ma/jump_sat/libzypp/zypp/CMakeLists.txt
branches/tmp/ma/jump_sat/libzypp/zypp/ResTraits.h
branches/tmp/ma/jump_sat/libzypp/zypp/base/LogTools.h
branches/tmp/ma/jump_sat/libzypp/zypp/pool/Res2Sat.cc
branches/tmp/ma/jump_sat/libzypp/zypp/sat/Capability.cc
branches/tmp/ma/jump_sat/libzypp/zypp/sat/Capability.h
branches/tmp/ma/jump_sat/libzypp/zypp/sat/IdStr.cc
branches/tmp/ma/jump_sat/libzypp/zypp/sat/IdStr.h
branches/tmp/ma/jump_sat/libzypp/zypp/sat/Pool.cc
branches/tmp/ma/jump_sat/libzypp/zypp/sat/Pool.h
branches/tmp/ma/jump_sat/libzypp/zypp/sat/Solvable.cc
branches/tmp/ma/jump_sat/libzypp/zypp/sat/Solvable.h
Modified: branches/tmp/ma/jump_sat/libzypp/devel/devel.ma/CMakeLists.txt
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/devel/devel.ma/CMakeLists.txt?rev=8258&r1=8257&r2=8258&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/devel/devel.ma/CMakeLists.txt (original)
+++ branches/tmp/ma/jump_sat/libzypp/devel/devel.ma/CMakeLists.txt Thu Jan 10 17:56:09 2008
@@ -29,7 +29,7 @@
## ############################################################
-FOREACH( loop_var NewPool ScanSource Iorder Xml Ex Main FakePool AOUT Parse Test Basic Sat)
+FOREACH( loop_var NewPool DumpSolv ScanSource Iorder Xml Ex Main FakePool AOUT Parse Test Basic Sat)
ADD_EXECUTABLE( ${loop_var}
${loop_var}.cc
)
Added: branches/tmp/ma/jump_sat/libzypp/devel/devel.ma/DumpSolv.cc
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/devel/devel.ma/DumpSolv.cc?rev=8258&view=auto
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/devel/devel.ma/DumpSolv.cc (added)
+++ branches/tmp/ma/jump_sat/libzypp/devel/devel.ma/DumpSolv.cc Thu Jan 10 17:56:09 2008
@@ -0,0 +1,38 @@
+#include <iostream>
+#include
+#include
+#include
+
+using std::endl;
+using std::cout;
+using namespace zypp;
+
+/******************************************************************
+**
+** FUNCTION NAME : main
+** FUNCTION TYPE : int
+*/
+int main( int argc, const char * argv[] )
+{
+ --argc; ++argv; // skip arg 0
+ sat::Pool satpool( sat::Pool::instance() );
+
+ for ( ; argc; --argc, ++argv )
+ {
+ cout << "Read: " << argv[0] << endl;
+ satpool.addRepoSolv( argv[0] );
+ }
+
+ cout << "Done: " << satpool << endl;
+
+ if ( getenv("VERBOSE") )
+ {
+ for_( it, satpool.solvablesBegin(), satpool.solvablesEnd() )
+ {
+ cout << dump(*it) << endl;
+ }
+ }
+
+ return 0;
+}
+
Modified: branches/tmp/ma/jump_sat/libzypp/devel/devel.ma/NewPool.cc
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/devel/devel.ma/NewPool.cc?rev=8258&r1=8257&r2=8258&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/devel/devel.ma/NewPool.cc (original)
+++ branches/tmp/ma/jump_sat/libzypp/devel/devel.ma/NewPool.cc Thu Jan 10 17:56:09 2008
@@ -45,6 +45,7 @@
#include "zypp/sat/Repo.h"
#include "zypp/sat/Solvable.h"
#include "zypp/sat/detail/PoolImpl.h"
+#include "zypp/sat/IdStrType.h"
#include
@@ -406,8 +407,63 @@
{ return HasValue<_MemFun, _Value>( fun_r, val_r ); }
}
+namespace zypp
+{
+ namespace sat
+ {
+
+ } // namespace sat
+ namespace par
+ {
+ class Foo : public sat::IdStrType<Foo>
+ {
+ public:
+ Foo() {}
+ explicit Foo( sat::detail::IdType id_r ) : _str( str::toLower(sat::IdStr(id_r).c_str()) ) {}
+ explicit Foo( const sat::IdStr & idstr_r ) : _str( str::toLower(idstr_r.c_str()) ) {}
+ explicit Foo( const char * cstr_r ) : _str( str::toLower(cstr_r) ) {}
+ explicit Foo( const std::string & str_r ) : _str( str::toLower(str_r) ) {}
+ private:
+ int _doDompareC( const char * rhs ) const
+ { return str::compareCI( _str.c_str(), rhs ); }
+ private:
+ friend class sat::IdStrType<Foo>;
+ sat::IdStr _str;
+ };
+
+ } // namespace par
+}
+
+template <class L>
+struct _TestO { _TestO( const L & lhs ) : _lhs( lhs ) {} const L & _lhs; };
+
+template <class L>
+std::ostream & operator<<( std::ostream & str, const _TestO<L> & obj )
+{ const L & lhs( obj._lhs); return str << (lhs?'_':'*') << (lhs.empty()?'e':'_') << "'" << lhs << "'"; }
+
+template <class L>
+_TestO<L> testO( const L & lhs )
+{ return _TestO<L>( lhs ); }
+
+
+template
+void testCMP( const L & lhs, const R & rhs )
+{
+ MIL << "LHS " << testO(lhs) << endl;
+ MIL << "RHS " << rhs << endl;
+
+#define OUTS(S) DBG << #S << ": " << (S) << endl
+ OUTS( lhs.compare(rhs) );
+ OUTS( lhs != rhs );
+ OUTS( lhs < rhs );
+ OUTS( lhs <= rhs );
+ OUTS( lhs == rhs );
+ OUTS( lhs >= rhs );
+ OUTS( lhs > rhs );
+#undef OUTS
+}
/******************************************************************
**
@@ -421,10 +477,9 @@
sat::Pool satpool( sat::Pool::instance() );
-#if 1
- //sat::Repo r( satpool.addRepoSolv( "sl10.1-beta7-packages.solv" ) );
- //sat::Repo s( satpool.addRepoSolv( "sl10.1-beta7-selections.solv" ) );
- sat::Repo s( satpool.addRepoSolv( "target.solv" ) );
+#if 0
+ sat::Repo s( satpool.addRepoSolv( "10.3.solv" ) );
+ //sat::Repo s( satpool.addRepoSolv( "target.solv" ) );
sat::Capabilities r( (*satpool.solvablesBegin())[Dep::PROVIDES] );
MIL << r << endl;
@@ -434,11 +489,20 @@
DBG << *it << endl;
if ( 1 )
- std::for_each( make_filter_iterator( filter::byValue( &sat::Solvable::name, "bash" ),
- satpool.solvablesBegin(), satpool.solvablesEnd() ),
- make_filter_iterator( filter::byValue( &sat::Solvable::name, "bash" ),
- satpool.solvablesEnd(), satpool.solvablesEnd() ),
- Xprint() );
+ {
+ std::for_each( make_filter_iterator( filter::byValue( &sat::Solvable::name, "bash" ),
+ satpool.solvablesBegin(), satpool.solvablesEnd() ),
+ make_filter_iterator( filter::byValue( &sat::Solvable::name, "bash" ),
+ satpool.solvablesEnd(), satpool.solvablesEnd() ),
+ Xprint() );
+ std::for_each( make_filter_iterator( filter::byValue( &sat::Solvable::name, "pattern:yast2_install_wf" ),
+ satpool.solvablesBegin(), satpool.solvablesEnd() ),
+ make_filter_iterator( filter::byValue( &sat::Solvable::name, "pattern:yast2_install_wf" ),
+ satpool.solvablesEnd(), satpool.solvablesEnd() ),
+ Xprint() );
+ }
+
+
// make_filter_iterator(detail::ByRepo( *this ),
// Repo.cc- detail::SolvableIterator(_repo->end),
@@ -519,7 +583,7 @@
}
- if ( 1 )
+ if ( 0 )
{
Measure x( "INIT TARGET" );
{
@@ -535,13 +599,14 @@
USR << "pool: " << pool << endl;
pool.satSync();
- waitForInput();
-
+ //waitForInput();
//std::for_each( pool.begin(), pool.end(), Xprint() );
- //sat::detail::PoolImpl satpool;
- //sat::Pool satpool;
- //MIL << satpool << endl;
+ MIL << satpool << endl;
+ for_( it, satpool.solvablesBegin(), satpool.solvablesEnd() )
+ {
+ dumpOn( MIL, *it );
+ }
///////////////////////////////////////////////////////////////////
INT << "===[END]============================================" << endl << endl;
Modified: branches/tmp/ma/jump_sat/libzypp/devel/devel.ma/Parse.cc
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/devel/devel.ma/Parse.cc?rev=8258&r1=8257&r2=8258&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/devel/devel.ma/Parse.cc (original)
+++ branches/tmp/ma/jump_sat/libzypp/devel/devel.ma/Parse.cc Thu Jan 10 17:56:09 2008
@@ -35,7 +35,10 @@
#include "zypp/RepoManager.h"
#include "zypp/RepoInfo.h"
+#include "zypp/repo/DeltaCandidates.h"
#include "zypp/repo/PackageProvider.h"
+#include "zypp/repo/ScriptProvider.h"
+#include "zypp/repo/SrcPackageProvider.h"
#include "zypp/ui/PatchContents.h"
#include "zypp/ResPoolProxy.h"
@@ -93,59 +96,6 @@
/////////////////////////////////////////////////////////////////
} // namespace zypp
///////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////
-
-template<class _Res>
-Selectable::Ptr getSel( const std::string & name_r )
-{
- ResPoolProxy uipool( getZYpp()->poolProxy() );
- for_(it, uipool.byKindBegin<_Res>(), uipool.byKindEnd<_Res>() )
- {
- if ( (*it)->name() == name_r )
- return (*it);
- }
- return 0;
-}
-
-template<class _Res>
-PoolItem getPi( const std::string & name_r, const Edition & ed_r, const Arch & arch_r )
-{
- PoolItem ret;
- ResPool pool( getZYpp()->pool() );
- for_(it, pool.byNameBegin(name_r), pool.byNameEnd(name_r) )
- {
- if ( !ret && isKind<_Res>( (*it).resolvable() )
- && ( ed_r == Edition() || ed_r == (*it)->edition() )
- && ( arch_r == Arch() || arch_r == (*it)->arch() ) )
- {
- ret = (*it);
- MIL << " ->" << *it << endl;
- }
- else
- {
- DBG << " ?" << *it << endl;
- }
- }
- return ret;
-}
-template<class _Res>
-PoolItem getPi( const std::string & name_r )
-{
- return getPi<_Res>( name_r, Edition(), Arch() );
-}
-template<class _Res>
-PoolItem getPi( const std::string & name_r, const Edition & ed_r )
-{
- return getPi<_Res>( name_r, ed_r, Arch() );
-}
-template<class _Res>
-PoolItem getPi( const std::string & name_r, const Arch & arch_r )
-{
- return getPi<_Res>( name_r, Edition(), arch_r );
-}
-
-
-
void dbgDu( Selectable::Ptr sel )
{
@@ -494,63 +444,11 @@
DigestReceive foo;
KeyRingSignalsReceive baa;
- DiskUsageCounter::MountPointSet fakePart;
- fakePart.insert( DiskUsageCounter::MountPoint( "/", 1024, 10240, 5120, 0LL, false ) );
-// fakePart.insert( DiskUsageCounter::MountPoint( "/usr", 1024, 10240, 5120, 0LL, false ) );
- fakePart.insert( DiskUsageCounter::MountPoint( "/usr/lib", 1024, 10240, 5120, 0LL, false ) );
- fakePart.insert( DiskUsageCounter::MountPoint( "/usr/bin", 1024, 10240, 5120, 0LL, false ) );
- getZYpp()->setPartitions( fakePart );
-
- ResPool pool( getZYpp()->pool() );
- vdumpPoolStats( USR << "Initial pool:" << endl,
- pool.begin(),
- pool.end() ) << endl;
-
-#if 0
RepoManager repoManager( makeRepoManager( "/Local/ROOT" ) );
RepoInfoList repos = repoManager.knownRepositories();
SEC << "/Local/ROOT " << repos << endl;
-
- RepoManager oldrepoManager( makeRepoManager( "/Local/ROOT/mnt" ) );
-
- RepoInfoList oldrepos = oldrepoManager.knownRepositories();
- SEC << "/Local/ROOT/mnt " << oldrepos << endl;
-
- for_( it, oldrepos.begin(), oldrepos.end() )
- {
- std::string oldalias( it->alias() );
- oldrepoManager.modifyRepository( oldalias, it->setEnabled( false ).setAlias( "foo" ) );
- }
-
- oldrepos = oldrepoManager.knownRepositories();
- SEC << "/Local/ROOT/mnt " << oldrepos << endl;
-
-
- INT << "===[END]============================================" << endl << endl;
- zypp::base::LogControl::instance().logNothing();
- return 0;
-
- if ( repos.empty() )
- {
- RepoInfo nrepo;
- nrepo
- .setAlias( "factorytest" )
- .setName( "Test Repo for factory." )
- .setEnabled( true )
- .setAutorefresh( false )
- .addBaseUrl( Url("http://dist.suse.de/install/stable-x86/") );
-
- repoManager.addRepository( nrepo );
- SEC << "refreshMetadat" << endl;
- repoManager.refreshMetadata( nrepo );
- SEC << "buildCache" << endl;
- repoManager.buildCache( nrepo );
- SEC << "------" << endl;
- repos = repoManager.knownRepositories();
- }
-
for ( RepoInfoList::iterator it = repos.begin(); it != repos.end(); ++it )
{
RepoInfo & nrepo( *it );
@@ -580,10 +478,11 @@
getZYpp()->addResolvables( store );
}
+ ResPool pool( getZYpp()->pool() );
USR << "pool: " << pool << endl;
SEC << pool.knownRepositoriesSize() << endl;
-#endif
- if ( 1 )
+
+ if ( 0 )
{
{
zypp::base::LogControl::TmpLineWriter shutUp;
@@ -593,14 +492,29 @@
MIL << "Added target: " << pool << endl;
}
- cerr << getZYpp()->getRequestedLocales() << endl;
//std::for_each( pool.begin(), pool.end(), Xprint() );
- //PoolItem pi = getPi<Package>( "update-test-affects-package-manager", Edition("99-99") );
- //USR << pi << endl;
- //pi.status().setTransact( true, ResStatus::USER );
+ PoolItem pi = getPi<Patch>( "fetchmsttfonts.sh" );
+ USR << pi << endl;
+
+ pi = getPi<Script>( "fetchmsttfonts.sh-4347-patch-fetchmsttfonts.sh-2" );
+ USR << pi << endl;
+ if ( pi )
+ {
+ Script::constPtr script_r( asKind<Script>( pi.resolvable() ) );
+ MIL << script_r << endl;
+ if ( script_r )
+ {
+ repo::RepoMediaAccess access_r;
+ repo::ScriptProvider prov( access_r );
+ ManagedFile localfile = prov.provideScript( script_r, true );
+ MIL << localfile << endl;
+ }
+ }
+
+ //pi.status().setTransact( true, ResStatus::USER );
//install();
///////////////////////////////////////////////////////////////////
Modified: branches/tmp/ma/jump_sat/libzypp/tests/zypp/CMakeLists.txt
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/tests/zypp/CMakeLists.txt?rev=8258&r1=8257&r2=8258&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/tests/zypp/CMakeLists.txt (original)
+++ branches/tmp/ma/jump_sat/libzypp/tests/zypp/CMakeLists.txt Thu Jan 10 17:56:09 2008
@@ -1,3 +1,10 @@
+FOREACH( loop_var ResKind)
+ ADD_EXECUTABLE( ${loop_var}_test ${loop_var}_test.cc )
+ TARGET_LINK_LIBRARIES( ${loop_var}_test zypp boost_unit_test_framework )
+ ADD_TEST( ${loop_var}_test ${CMAKE_CURRENT_BINARY_DIR}/${loop_var}_test)
+ENDFOREACH( loop_var )
+
+
ADD_EXECUTABLE(Arch Arch.cc)
TARGET_LINK_LIBRARIES(Arch zypp boost_unit_test_framework )
Added: branches/tmp/ma/jump_sat/libzypp/tests/zypp/ResKind_test.cc
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/tests/zypp/ResKind_test.cc?rev=8258&view=auto
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/tests/zypp/ResKind_test.cc (added)
+++ branches/tmp/ma/jump_sat/libzypp/tests/zypp/ResKind_test.cc Thu Jan 10 17:56:09 2008
@@ -0,0 +1,36 @@
+#include
+#include "zypp/base/Logger.h"
+#include "zypp/ResKind.h"
+
+using boost::unit_test::test_suite;
+using boost::unit_test::test_case;
+using namespace std;
+using namespace zypp;
+
+void dotest()
+{
+ // Default construced is empty ""
+ BOOST_CHECK_EQUAL( ResKind(), "" );
+ // boolean context
+ BOOST_CHECK( ! ResKind() );
+ BOOST_CHECK( ! ResKind(0) ); // id NULL
+ BOOST_CHECK( ! ResKind(1) ); // id ""
+ BOOST_CHECK( ! ResKind("") ); // ""
+ BOOST_CHECK( ResKind(2) );
+ BOOST_CHECK( ResKind("FOO") );
+ // Internal representation is lowercased
+ BOOST_CHECK_EQUAL( ResKind("FOO").asString(), "foo" );
+ // Caseinsensitive comparison
+ BOOST_CHECK_EQUAL( ResKind("FOO"), ResKind("foo") );
+ BOOST_CHECK_EQUAL( ResKind("FOO"), string("foo") );
+ BOOST_CHECK_EQUAL( ResKind("FOO"), "foo" );
+ BOOST_CHECK_EQUAL( string("foo"), ResKind("FOO") );
+ BOOST_CHECK_EQUAL( "foo", ResKind("FOO") );
+
+}
+test_suite * init_unit_test_suite( int, char * [] )
+{
+ test_suite * test= BOOST_TEST_SUITE( "ResKind_test" );
+ test->add( BOOST_TEST_CASE( &dotest ), 0 /* expected zero error */ );
+ return test;
+}
Modified: branches/tmp/ma/jump_sat/libzypp/zypp/@DOXYGEN/DOXYGEN.h
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/%40DOXYGEN/DOXYGEN.h?rev=8258&r1=8257&r2=8258&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/@DOXYGEN/DOXYGEN.h (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/@DOXYGEN/DOXYGEN.h Thu Jan 10 17:56:09 2008
@@ -34,6 +34,11 @@
* \verbinclude g_RAII
*/
////////////////////////////////////////////////////////////////////////////////
+/*! \defgroup g_CRTP CRTP solutions
+ * \see http://en.wikipedia.org/wiki/Curiously_Recurring_Template_Pattern
+ * \verbinclude g_CRTP
+*/
+////////////////////////////////////////////////////////////////////////////////
/*! \defgroup g_BackenSpecific Backend Specific
* \verbinclude g_BackenSpecific
*/
Modified: branches/tmp/ma/jump_sat/libzypp/zypp/CMakeLists.txt
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/CMakeLists.txt?rev=8258&r1=8257&r2=8258&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/CMakeLists.txt (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/CMakeLists.txt Thu Jan 10 17:56:09 2008
@@ -31,7 +31,6 @@
ResObject.cc
SystemResObject.cc
Resolvable.cc
- ResTraits.cc
ResStatus.cc
ResStore.cc
PoolItem.cc
@@ -83,6 +82,7 @@
RepoManager.cc
MediaProducts.cc
Locks.cc
+ ResKind.cc
ZConfig.cc
Arch.cc
LanguageCode.cc
@@ -148,6 +148,7 @@
Range.h
Rel.h
RelCompare.h
+ ResKind.h
ResFilters.h
ResObject.h
ResPool.h
Added: branches/tmp/ma/jump_sat/libzypp/zypp/ResKind.cc
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/ResKind.cc?rev=8258&view=auto
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/ResKind.cc (added)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/ResKind.cc Thu Jan 10 17:56:09 2008
@@ -0,0 +1,60 @@
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/ResKind.cc
+ *
+*/
+#include <iostream>
+
+#include "zypp/ResKind.h"
+#include "zypp/ResTraits.h"
+
+using std::endl;
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+
+ const ResKind ResKind::atom ( "atom" );
+ const ResKind ResKind::language ( "language" );
+ const ResKind ResKind::message ( "message" );
+ const ResKind ResKind::package ( "package" );
+ const ResKind ResKind::patch ( "patch" );
+ const ResKind ResKind::pattern ( "pattern" );
+ const ResKind ResKind::product ( "product" );
+ const ResKind ResKind::script ( "script" );
+ const ResKind ResKind::selection ( "selection" );
+ const ResKind ResKind::srcpackage( "srcpackage" );
+ const ResKind ResKind::system ( "system" );
+
+ template<>
+ const ResKind ResTraits<Atom> ::kind( ResKind::atom );
+ template<>
+ const ResKind ResTraits<Language> ::kind( ResKind::language );
+ template<>
+ const ResKind ResTraits<Message> ::kind( ResKind::message );
+ template<>
+ const ResKind ResTraits<Package> ::kind( ResKind::package );
+ template<>
+ const ResKind ResTraits<Patch> ::kind( ResKind::patch );
+ template<>
+ const ResKind ResTraits<Pattern> ::kind( ResKind::pattern );
+ template<>
+ const ResKind ResTraits<Product> ::kind( ResKind::product );
+ template<>
+ const ResKind ResTraits<Script> ::kind( ResKind::script );
+ template<>
+ const ResKind ResTraits<Selection> ::kind( ResKind::selection );
+ template<>
+ const ResKind ResTraits<SrcPackage>::kind( ResKind::srcpackage );
+ template<>
+ const ResKind ResTraits<SystemResObject>::kind( ResKind::system );
+
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
Added: branches/tmp/ma/jump_sat/libzypp/zypp/ResKind.h
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/ResKind.h?rev=8258&view=auto
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/ResKind.h (added)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/ResKind.h Thu Jan 10 17:56:09 2008
@@ -0,0 +1,71 @@
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/ResKind.h
+ *
+*/
+#ifndef ZYPP_RESKIND_H
+#define ZYPP_RESKIND_H
+
+#include <iosfwd>
+#include <string>
+
+#include "zypp/base/String.h"
+#include "zypp/sat/IdStrType.h"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : ResKind
+ //
+ /** Resolvable kinds.
+ * A \b lowercased string and used as identification.
+ * Comparison against string values is always case
+ * insensitive.
+ */
+ class ResKind : public sat::IdStrType<ResKind>
+ {
+ public:
+ /** \name Some builtin ResKind constants. */
+ //@{
+ static const ResKind atom;
+ static const ResKind language;
+ static const ResKind message;
+ static const ResKind package;
+ static const ResKind patch;
+ static const ResKind pattern;
+ static const ResKind product;
+ static const ResKind script;
+ static const ResKind selection;
+ static const ResKind srcpackage;
+ static const ResKind system;
+ //@}
+
+ public:
+ ResKind() {}
+ explicit ResKind( sat::detail::IdType id_r ) : _str( str::toLower(sat::IdStr(id_r).c_str()) ) {}
+ explicit ResKind( const sat::IdStr & idstr_r ) : _str( str::toLower(idstr_r.c_str()) ) {}
+ explicit ResKind( const char * cstr_r ) : _str( str::toLower(cstr_r) ) {}
+ explicit ResKind( const std::string & str_r ) : _str( str::toLower(str_r) ) {}
+
+ private:
+ int _doDompareC( const char * rhs ) const
+ { return str::compareCI( _str.c_str(), rhs ); }
+
+ private:
+ friend class sat::IdStrType<ResKind>;
+ sat::IdStr _str;
+ };
+
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_RESKIND_H
Modified: branches/tmp/ma/jump_sat/libzypp/zypp/ResTraits.h
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/ResTraits.h?rev=8258&r1=8257&r2=8258&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/ResTraits.h (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/ResTraits.h Thu Jan 10 17:56:09 2008
@@ -14,6 +14,7 @@
#include "zypp/base/PtrTypes.h"
#include "zypp/base/KindOf.h"
+#include "zypp/ResKind.h"
///////////////////////////////////////////////////////////////////
namespace zypp
@@ -63,10 +64,7 @@
DEFINE_PTR_TYPE( SystemResObject );
//@}
- /** The Resolvables Kind type. */
- typedef KindOf<Resolvable> ResKind;
-
- /** ResTraits. Defines common types and the Kind value. */
+ /** ResTraits. Defines common types and the ResKind value. */
template<typename _Res>
struct ResTraits
{
Modified: branches/tmp/ma/jump_sat/libzypp/zypp/base/LogTools.h
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/base/LogTools.h?rev=8258&r1=8257&r2=8258&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/base/LogTools.h (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/base/LogTools.h Thu Jan 10 17:56:09 2008
@@ -349,6 +349,30 @@
return str << ret;
}
+ ///////////////////////////////////////////////////////////////////
+ // iomanipulator: str << dump(val) << ...
+ // calls: std::ostream & dumpOn( std::ostream & str, const Type & obj )
+ ///////////////////////////////////////////////////////////////////
+
+ namespace detail
+ {
+ template<class _Tp>
+ struct Dump
+ {
+ Dump( const _Tp & obj_r ) : _obj( obj_r ) {}
+ const _Tp & _obj;
+ };
+
+ template<class _Tp>
+ std::ostream & operator<<( std::ostream & str, const Dump<_Tp> & obj )
+ { return dumpOn( str, obj._obj ); }
+ }
+
+ template<class _Tp>
+ detail::Dump<_Tp> dump( const _Tp & obj_r )
+ { return detail::Dump<_Tp>(obj_r); }
+
+
/////////////////////////////////////////////////////////////////
} // namespace zypp
///////////////////////////////////////////////////////////////////
Modified: branches/tmp/ma/jump_sat/libzypp/zypp/pool/Res2Sat.cc
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/pool/Res2Sat.cc?rev=8258&r1=8257&r2=8258&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/pool/Res2Sat.cc (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/pool/Res2Sat.cc Thu Jan 10 17:56:09 2008
@@ -50,8 +50,8 @@
{
enum SatIsRreq {
ISRREQ_NORMAL = 0,
- ISRREQ_REQUIRES = 1,
- ISRREQ_PREREQUIRES = 2
+ ISRREQ_REQUIRES = -sat::detail::solvablePrereqMarker,
+ ISRREQ_PREREQUIRES = sat::detail::solvablePrereqMarker
};
const CapSet & caps( dep_r[which_r] );
if ( caps.empty() )
Modified: branches/tmp/ma/jump_sat/libzypp/zypp/sat/Capability.cc
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/sat/Capability.cc?rev=8258&r1=8257&r2=8258&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/sat/Capability.cc (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/sat/Capability.cc Thu Jan 10 17:56:09 2008
@@ -37,8 +37,7 @@
detail::IdType relFromStr( ::_Pool * pool_r, const std::string & name_r, Rel op_r, const Edition & ed_r, const ResKind & kind_r )
{
detail::IdType nid( detail::noId );
-#warning Add or not kind package
- if ( kind_r.empty() || isKind<Package>( kind_r ) )
+ if ( ! kind_r || kind_r == ResKind::package )
{
nid = IdStr( name_r ).id();
}
Modified: branches/tmp/ma/jump_sat/libzypp/zypp/sat/Capability.h
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/sat/Capability.h?rev=8258&r1=8257&r2=8258&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/sat/Capability.h (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/sat/Capability.h Thu Jan 10 17:56:09 2008
@@ -38,6 +38,18 @@
// CLASS NAME : Capability
//
/** A sat capability.
+ *
+ * If a certain \ref ResKind is specified upon construction, the
+ * capabilities name part is prefixed accordingly:
+ * \code
+ * Capability( "foo" ) ==> 'foo'
+ * Capability( "foo", ResKind::package ) ==> 'foo'
+ * Capability( "foo", ResKind::pattern ) ==> 'pattern:foo'
+ * Capability( "pattern:foo" ) ==> 'pattern:foo'
+ * // avoid this:
+ * Capability( "pattern:foo", ResKind::pattern ) ==> 'pattern:pattern:foo'
+ * \endcode
+ *
*/
class Capability: protected detail::PoolMember,
private base::SafeBool<Capability>
@@ -49,20 +61,14 @@
/** Ctor from id. */
explicit Capability( detail::IdType id_r ) : _id( id_r ) {}
- /** Ctor from string.
- * If no \c kind_r is provided, the \ref Capability refers to a \c package.
- */
- explicit Capability( const char * str_r, const ResKind & kind_r = ResKind() );
-
- /** Ctor from string.
- * If no \c kind_r is provided, the \ref Capability refers to a \c package.
- */
- explicit Capability( const std::string & str_r, const ResKind & kind_r = ResKind() );
-
- /** Ctor from <tt>name op edition</tt>.
- * If no \c kind_r is provided, the \ref Capability refers to a \c package.
- */
- Capability( const std::string & name_r, Rel op_r, const Edition & ed_r, const ResKind & kind_r = ResKind() );
+ /** Ctor from string. */
+ explicit Capability( const char * str_r, const ResKind & prefix_r = ResKind() );
+
+ /** Ctor from string. */
+ explicit Capability( const std::string & str_r, const ResKind & prefix_r = ResKind() );
+
+ /** Ctor from <tt>name op edition</tt>. */
+ Capability( const std::string & name_r, Rel op_r, const Edition & ed_r, const ResKind & prefix_r = ResKind() );
/** Evaluate in a boolean context (\c != \c Null). */
using base::SafeBool<Capability>::operator bool_type;
Modified: branches/tmp/ma/jump_sat/libzypp/zypp/sat/IdStr.cc
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/sat/IdStr.cc?rev=8258&r1=8257&r2=8258&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/sat/IdStr.cc (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/sat/IdStr.cc Thu Jan 10 17:56:09 2008
@@ -10,7 +10,7 @@
*
*/
#include <iostream>
-//#include "zypp/base/Logger.h"
+#include
#include "zypp/sat/detail/PoolImpl.h"
#include "zypp/sat/IdStr.h"
@@ -25,7 +25,12 @@
namespace sat
{ /////////////////////////////////////////////////////////////////
- const IdStr IdStr::Null( STRID_NULL );
+ // MPL checks for satlib constants we explicity use in
+ // the header file.
+ BOOST_MPL_ASSERT_RELATION( 0, ==, STRID_NULL );
+ BOOST_MPL_ASSERT_RELATION( 1, ==, STRID_EMPTY );
+
+ const IdStr IdStr::Null ( STRID_NULL );
const IdStr IdStr::Empty( STRID_EMPTY );
/////////////////////////////////////////////////////////////////
@@ -42,18 +47,13 @@
{ return ::strlen( c_str() ); }
const char * IdStr::c_str() const
- { return ::id2str( myPool().getPool(), _id ); }
-
- std::string IdStr::string() const
- { return ::id2str( myPool().getPool(), _id ); }
+ { return _id ? ::id2str( myPool().getPool(), _id ) : ""; }
int IdStr::compare( const IdStr & rhs ) const
{
if ( _id == rhs._id )
return 0;
- // Explicitly handle IdStr::Null because
- // it's string representation is "<NULL>"
- // and not something less than "".
+ // Explicitly handle IdStr::Null < ""
if ( ! _id )
return -1;
if ( ! rhs._id )
Modified: branches/tmp/ma/jump_sat/libzypp/zypp/sat/IdStr.h
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/sat/IdStr.h?rev=8258&r1=8257&r2=8258&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/sat/IdStr.h (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/sat/IdStr.h Thu Jan 10 17:56:09 2008
@@ -31,42 +31,61 @@
// CLASS NAME : IdStr
//
/** Access to the sat-pools string space.
+ *
* Construction from string will place a copy of the string in the
* string space, if it is not already present.
+ *
+ * While comparison differs between \ref IdStr::Null and \ref IdStr::Empty
+ * ( \c NULL and \c "" ), both are represented by an empty string \c "".
*/
class IdStr: protected detail::PoolMember,
private base::SafeBool<IdStr>
{
public:
/** Default ctor, empty string. */
- IdStr() : _id( Empty.id() ) {}
+ IdStr() : _id( 1 ) {}
+
/** Ctor from id. */
explicit IdStr( detail::IdType id_r ) : _id( id_r ) {}
+
/** Ctor from string. */
explicit IdStr( const char * str_r );
+
/** Ctor from string. */
explicit IdStr( const std::string & str_r );
- /** Evaluate in a boolean context <tt>( != \c Null )</tt>. */
- using base::SafeBool<IdStr>::operator bool_type;
+
public:
/** No or Null string ( Id \c 0 ). */
static const IdStr Null;
+
/** Empty string. */
static const IdStr Empty;
+
public:
- /** Whether string is empty. */
+ /** Evaluate in a boolean context <tt>( != \c Null )</tt>. */
+ using base::SafeBool<IdStr>::operator bool_type;
+
+ /** Whether the string is empty.
+ * This is true for \ref Null and \ref Empty.
+ */
bool empty() const
- { return( _id == Empty.id() ); }
- /** the strings size. */
+ { return( _id == 1 || _id == 0 ); }
+
+ /** The strings size. */
unsigned size() const;
+
public:
/** Conversion to <tt>const char *</tt> */
const char * c_str() const;
+
/** Conversion to <tt>std::string</tt> */
- std::string string() const;
+ std::string string() const
+ { return c_str(); }
+
/** \overload */
std::string asString() const
- { return string(); }
+ { return c_str(); }
+
public:
/** Fast compare equal. */
bool compareEQ( const IdStr & rhs ) const
@@ -74,27 +93,14 @@
/** Compare IdStr returning <tt>-1,0,1</tt>. */
int compare( const IdStr & rhs ) const;
+
/** \overload */
int compare( const char * rhs ) const;
+
/** \overload */
int compare( const std::string & rhs ) const
{ return compare( rhs.c_str() ); }
- /** Compare IdStr returning <tt>-1,0,1</tt>. */
- static int compare( const IdStr & lhs, const IdStr & rhs )
- { return lhs.compare( rhs ); }
- /** \overload */
- static int compare( const IdStr & lhs, const char * rhs )
- { return lhs.compare( rhs ); }
- /** \overload */
- static int compare( const IdStr & lhs, const std::string & rhs )
- { return lhs.compare( rhs ); }
- /** \overload */
- static int compare( const char * lhs, const IdStr & rhs )
- { return -rhs.compare( lhs ); }
- /** \overload */
- static int compare( const std::string & lhs, const IdStr & rhs )
- { return -rhs.compare( lhs ); }
public:
/** Expert backdoor. */
detail::IdType id() const
@@ -115,96 +121,96 @@
{ return lhs.compareEQ( rhs ); }
/** \overload */
inline bool operator==( const IdStr & lhs, const char * rhs )
- { return IdStr::compare( lhs, rhs ) == 0; }
+ { return lhs.compare( rhs ) == 0; }
/** \overload */
inline bool operator==( const IdStr & lhs, const std::string & rhs )
- { return IdStr::compare( lhs, rhs ) == 0; }
+ { return lhs.compare( rhs ) == 0; }
/** \overload */
inline bool operator==( const char * lhs, const IdStr & rhs )
- { return IdStr::compare( lhs, rhs ) == 0; }
+ { return rhs.compare( lhs ) == 0; }
/** \overload */
inline bool operator==( const std::string & lhs, const IdStr & rhs )
- { return IdStr::compare( lhs, rhs ) == 0; }
+ { return rhs.compare( lhs ) == 0; }
/** \relates IdStr NotEqual */
inline bool operator!=( const IdStr & lhs, const IdStr & rhs )
{ return ! lhs.compareEQ( rhs ); }
/** \overload */
inline bool operator!=( const IdStr & lhs, const char * rhs )
- { return IdStr::compare( lhs, rhs ) != 0; }
+ { return lhs.compare( rhs ) != 0; }
/** \overload */
inline bool operator!=( const IdStr & lhs, const std::string & rhs )
- { return IdStr::compare( lhs, rhs ) != 0; }
+ { return lhs.compare( rhs ) != 0; }
/** \overload */
inline bool operator!=( const char * lhs, const IdStr & rhs )
- { return IdStr::compare( lhs, rhs ) != 0; }
+ { return rhs.compare( lhs ) != 0; }
/** \overload */
inline bool operator!=( const std::string & lhs, const IdStr & rhs )
- { return IdStr::compare( lhs, rhs ) != 0; }
+ { return rhs.compare( lhs ) != 0; }
/** \relates IdStr Less */
inline bool operator<( const IdStr & lhs, const IdStr & rhs )
- { return IdStr::compare( lhs, rhs ) < 0; }
+ { return lhs.compare( rhs ) < 0; }
/** \overload */
inline bool operator<( const IdStr & lhs, const char * rhs )
- { return IdStr::compare( lhs, rhs ) < 0; }
+ { return lhs.compare( rhs ) < 0; }
/** \overload */
inline bool operator<( const IdStr & lhs, const std::string & rhs )
- { return IdStr::compare( lhs, rhs ) < 0; }
+ { return lhs.compare( rhs ) < 0; }
/** \overload */
inline bool operator<( const char * lhs, const IdStr & rhs )
- { return IdStr::compare( lhs, rhs ) < 0; }
+ { return rhs.compare( lhs ) >= 0; }
/** \overload */
inline bool operator<( const std::string & lhs, const IdStr & rhs )
- { return IdStr::compare( lhs, rhs ) < 0; }
+ { return rhs.compare( lhs ) >= 0; }
/** \relates IdStr LessEqual*/
inline bool operator<=( const IdStr & lhs, const IdStr & rhs )
- { return IdStr::compare( lhs, rhs ) <= 0; }
+ { return lhs.compare( rhs ) <= 0; }
/** \overload */
inline bool operator<=( const IdStr & lhs, const char * rhs )
- { return IdStr::compare( lhs, rhs ) <= 0; }
+ { return lhs.compare( rhs ) <= 0; }
/** \overload */
inline bool operator<=( const IdStr & lhs, const std::string & rhs )
- { return IdStr::compare( lhs, rhs ) <= 0; }
+ { return lhs.compare( rhs ) <= 0; }
/** \overload */
inline bool operator<=( const char * lhs, const IdStr & rhs )
- { return IdStr::compare( lhs, rhs ) <= 0; }
+ { return rhs.compare( lhs ) > 0; }
/** \overload */
inline bool operator<=( const std::string & lhs, const IdStr & rhs )
- { return IdStr::compare( lhs, rhs ) <= 0; }
+ { return rhs.compare( lhs ) > 0; }
/** \relates IdStr Greater */
inline bool operator>( const IdStr & lhs, const IdStr & rhs )
- { return IdStr::compare( lhs, rhs ) > 0; }
+ { return lhs.compare( rhs ) > 0; }
/** \overload */
inline bool operator>( const IdStr & lhs, const char * rhs )
- { return IdStr::compare( lhs, rhs ) > 0; }
+ { return lhs.compare( rhs ) > 0; }
/** \overload */
inline bool operator>( const IdStr & lhs, const std::string & rhs )
- { return IdStr::compare( lhs, rhs ) > 0; }
+ { return lhs.compare( rhs ) > 0; }
/** \overload */
inline bool operator>( const char * lhs, const IdStr & rhs )
- { return IdStr::compare( lhs, rhs ) > 0; }
+ { return rhs.compare( lhs ) <= 0; }
/** \overload */
inline bool operator>( const std::string & lhs, const IdStr & rhs )
- { return IdStr::compare( lhs, rhs ) > 0; }
+ { return rhs.compare( lhs ) <= 0; }
- /** \relates IdStr GreaterEqual*/
+ /** \relates IdStr GreaterEqual */
inline bool operator>=( const IdStr & lhs, const IdStr & rhs )
- { return IdStr::compare( lhs, rhs ) >= 0; }
+ { return lhs.compare( rhs ) >= 0; }
/** \overload */
inline bool operator>=( const IdStr & lhs, const char * rhs )
- { return IdStr::compare( lhs, rhs ) >= 0; }
+ { return lhs.compare( rhs ) >= 0; }
/** \overload */
inline bool operator>=( const IdStr & lhs, const std::string & rhs )
- { return IdStr::compare( lhs, rhs ) >= 0; }
+ { return lhs.compare( rhs ) >= 0; }
/** \overload */
inline bool operator>=( const char * lhs, const IdStr & rhs )
- { return IdStr::compare( lhs, rhs ) >= 0; }
+ { return rhs.compare( lhs ) < 0; }
/** \overload */
inline bool operator>=( const std::string & lhs, const IdStr & rhs )
- { return IdStr::compare( lhs, rhs ) >= 0; }
+ { return rhs.compare( lhs ) < 0; }
/////////////////////////////////////////////////////////////////
} // namespace sat
Added: branches/tmp/ma/jump_sat/libzypp/zypp/sat/IdStrType.h
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/sat/IdStrType.h?rev=8258&view=auto
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/sat/IdStrType.h (added)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/sat/IdStrType.h Thu Jan 10 17:56:09 2008
@@ -0,0 +1,301 @@
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/sat/IdStrType.h
+ *
+*/
+#ifndef ZYPP_SAT_IDSTRTYPE_H
+#define ZYPP_SAT_IDSTRTYPE_H
+
+#include "zypp/sat/IdStr.h"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////
+ namespace sat
+ { /////////////////////////////////////////////////////////////////
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : IdStrType<Derived>
+ //
+ /** Base class for creating \ref IdStr based types.
+ *
+ * Just by deriving from \ref IdStrType a class provides all
+ * the operations an \ref IdStr does. (incl. conversion to string types,
+ * comparison with string types and stream output).
+ *
+ * To disable any comparison, declare (but do not define) \ref _doDompareC
+ * in your class. If you need a different than the default lexicographical
+ * order, write your own \ref _doDompareC. If you can provide optimized
+ * comparison against IdStr or your class itself, \b additionally provide
+ * _doDompareI, and/or _doDompareD.
+ *
+ * \code
+ * class CaseCmp : public sat::IdStrType<CaseCmp>
+ * {
+ * public:
+ * CaseCmp() {}
+ * explicit CaseCmp( const char * cstr_r ) : _str( cstr_r ) {}
+ * private:
+ * friend class sat::IdStrType<CaseCmp>;
+ * sat::IdStr _str;
+ * };
+ *
+ * class NoCaseCmp : public sat::IdStrType<NoCaseCmp>
+ * {
+ * public:
+ * NoCaseCmp() {}
+ * explicit NoCaseCmp( const char * cstr_r ) : _str( cstr_r ) {}
+ * private:
+ * int _doDompareC( const char * rhs ) const
+ * { return ::strcasecmp( _str.c_str(), rhs ); }
+ * private:
+ * friend class sat::IdStrType<NoCaseCmp>;
+ * sat::IdStr _str;
+ * };
+ *
+ * CaseCmp ca( "a" );
+ * NoCaseCmp na( "a" );
+ * DBG << "ca == a ? " << (ca == "a") << endl; // ca == a ? 1
+ * DBG << "ca == A ? " << (ca == "A") << endl; // ca == A ? 0
+ * DBG << "na == a ? " << (na == "a") << endl; // na == a ? 1
+ * DBG << "na == A ? " << (na == "A") << endl; // na == A ? 1
+ * \endcode
+ * \ingroup g_CRTP
+ */
+ template <class Derived>
+ class IdStrType : private base::SafeBool<Derived>
+ {
+ typedef typename base::SafeBool<Derived>::bool_type bool_type;
+
+ protected:
+ IdStrType() {}
+ IdStrType(const IdStrType &) {}
+ void operator=(const IdStrType &) {}
+
+ private:
+ const Derived & self() const { return *static_cast( this ); }
+
+ public:
+ const IdStr & idStr() const { return self()._str; }
+
+ bool empty() const { return idStr().empty(); }
+ unsigned size() const { return idStr().size(); }
+ const char * c_str() const { return idStr().c_str(); }
+ std::string string() const { return idStr().string(); }
+ std::string asString() const { return idStr().asString(); }
+
+ public:
+ /** Evaluate in a boolean context <tt>( ! empty() )</tt>. */
+ using base::SafeBool<Derived>::operator bool_type;
+
+ public:
+ int compare( const Derived & rhs ) const { return self()._doDompareD( rhs ); }
+ int compare( const IdStrType & rhs ) const { return self()._doDompareD( rhs.self() ); }
+ int compare( const IdStr & rhs ) const { return self()._doDompareI( rhs ); }
+ int compare( const char * rhs ) const { return self()._doDompareC( rhs ); }
+ int compare( const std::string & rhs ) const { return self()._doDompareC( rhs.c_str() ); }
+
+ private:
+ int _doDompareD( const Derived & rhs ) const { return self()._doDompareI( rhs.idStr() ); }
+ int _doDompareI( const IdStr & rhs ) const { return idStr().compareEQ( rhs ) ? true : self()._doDompareC( rhs.c_str() ); }
+ int _doDompareC( const char * rhs ) const { return idStr().compare( rhs ); }
+
+ friend base::SafeBool<Derived>::operator bool_type() const;
+ bool boolTest() const { return ! empty(); }
+ };
+ ///////////////////////////////////////////////////////////////////
+
+ /** \relates IdStrType Stream output */
+ template <class Derived>
+ inline std::ostream & operator<<( std::ostream & str, const IdStrType<Derived> & obj )
+ { return str << obj.c_str(); }
+
+ /** \relates IdStrType Equal */
+ template <class Derived>
+ inline bool operator==( const IdStrType<Derived> & lhs, const IdStrType<Derived> & rhs )
+ { return lhs.idStr().compareEQ( rhs.idStr() ); }
+ /** \overload */
+ template <class Derived>
+ inline bool operator==( const IdStrType<Derived> & lhs, const IdStr & rhs )
+ { return lhs.compare( rhs ) == 0; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator==( const IdStrType<Derived> & lhs, const char * rhs )
+ { return lhs.compare( rhs ) == 0; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator==( const IdStrType<Derived> & lhs, const std::string & rhs )
+ { return lhs.compare( rhs ) == 0; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator==( const IdStr & lhs, const IdStrType<Derived> & rhs )
+ { return rhs.compare( lhs ) == 0; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator==( const char * lhs, const IdStrType<Derived> & rhs )
+ { return rhs.compare( lhs ) == 0; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator==( const std::string & lhs, const IdStrType<Derived> & rhs )
+ { return rhs.compare( lhs ) == 0; }
+
+ /** \relates IdStrType NotEqual */
+ template <class Derived>
+ inline bool operator!=( const IdStrType<Derived> & lhs, const IdStrType<Derived> & rhs )
+ { return lhs.idStr().compareEQ( rhs.idStr() ); }
+ /** \overload */
+ template <class Derived>
+ inline bool operator!=( const IdStrType<Derived> & lhs, const IdStr & rhs )
+ { return lhs.compare( rhs ) != 0; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator!=( const IdStrType<Derived> & lhs, const char * rhs )
+ { return lhs.compare( rhs ) != 0; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator!=( const IdStrType<Derived> & lhs, const std::string & rhs )
+ { return lhs.compare( rhs ) != 0; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator!=( const IdStr & lhs, const IdStrType<Derived> & rhs )
+ { return rhs.compare( lhs ) != 0; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator!=( const char * lhs, const IdStrType<Derived> & rhs )
+ { return rhs.compare( lhs ) != 0; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator!=( const std::string & lhs, const IdStrType<Derived> & rhs )
+ { return rhs.compare( lhs ) != 0; }
+
+ /** \relates IdStrType Less */
+ template <class Derived>
+ inline bool operator<( const IdStrType<Derived> & lhs, const IdStrType<Derived> & rhs )
+ { return lhs.compare( rhs ) < 0; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator<( const IdStrType<Derived> & lhs, const IdStr & rhs )
+ { return lhs.compare( rhs ) < 0; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator<( const IdStrType<Derived> & lhs, const char * rhs )
+ { return lhs.compare( rhs ) < 0; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator<( const IdStrType<Derived> & lhs, const std::string & rhs )
+ { return lhs.compare( rhs ) < 0; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator<( const IdStr & lhs, const IdStrType<Derived> & rhs )
+ { return rhs.compare( lhs ) >= 0; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator<( const char * lhs, const IdStrType<Derived> & rhs )
+ { return rhs.compare( lhs ) >= 0; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator<( const std::string & lhs, const IdStrType<Derived> & rhs )
+ { return rhs.compare( lhs ) >= 0; }
+
+ /** \relates IdStrType LessEqual */
+ template <class Derived>
+ inline bool operator<=( const IdStrType<Derived> & lhs, const IdStrType<Derived> & rhs )
+ { return lhs.compare( rhs ) <= 0; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator<=( const IdStrType<Derived> & lhs, const IdStr & rhs )
+ { return lhs.compare( rhs ) <= 0; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator<=( const IdStrType<Derived> & lhs, const char * rhs )
+ { return lhs.compare( rhs ) <= 0; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator<=( const IdStrType<Derived> & lhs, const std::string & rhs )
+ { return lhs.compare( rhs ) <= 0; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator<=( const IdStr & lhs, const IdStrType<Derived> & rhs )
+ { return rhs.compare( lhs ) > 0; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator<=( const char * lhs, const IdStrType<Derived> & rhs )
+ { return rhs.compare( lhs ) > 0; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator<=( const std::string & lhs, const IdStrType<Derived> & rhs )
+ { return rhs.compare( lhs ) > 0; }
+
+ /** \relates IdStrType Greater */
+ template <class Derived>
+ inline bool operator>( const IdStrType<Derived> & lhs, const IdStrType<Derived> & rhs )
+ { return lhs.compare( rhs ) > 0; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator>( const IdStrType<Derived> & lhs, const IdStr & rhs )
+ { return lhs.compare( rhs ) > 0; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator>( const IdStrType<Derived> & lhs, const char * rhs )
+ { return lhs.compare( rhs ) > 0; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator>( const IdStrType<Derived> & lhs, const std::string & rhs )
+ { return lhs.compare( rhs ) > 0; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator>( const IdStr & lhs, const IdStrType<Derived> & rhs )
+ { return rhs.compare( lhs ) <= 0; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator>( const char * lhs, const IdStrType<Derived> & rhs )
+ { return rhs.compare( lhs ) <= 0; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator>( const std::string & lhs, const IdStrType<Derived> & rhs )
+ { return rhs.compare( lhs ) <= 0; }
+
+ /** \relates IdStrType GreaterEqual */
+ template <class Derived>
+ inline bool operator>=( const IdStrType<Derived> & lhs, const IdStrType<Derived> & rhs )
+ { return lhs.compare( rhs ) >= 0; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator>=( const IdStrType<Derived> & lhs, const IdStr & rhs )
+ { return lhs.compare( rhs ) >= 0; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator>=( const IdStrType<Derived> & lhs, const char * rhs )
+ { return lhs.compare( rhs ) >= 0; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator>=( const IdStrType<Derived> & lhs, const std::string & rhs )
+ { return lhs.compare( rhs ) >= 0; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator>=( const IdStr & lhs, const IdStrType<Derived> & rhs )
+ { return rhs.compare( lhs ) < 0; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator>=( const char * lhs, const IdStrType<Derived> & rhs )
+ { return rhs.compare( lhs ) < 0; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator>=( const std::string & lhs, const IdStrType<Derived> & rhs )
+ { return rhs.compare( lhs ) < 0; }
+
+ /////////////////////////////////////////////////////////////////
+ } // namespace sat
+ ///////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_SAT_IDSTRTYPE_H
Modified: branches/tmp/ma/jump_sat/libzypp/zypp/sat/Pool.cc
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/sat/Pool.cc?rev=8258&r1=8257&r2=8258&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/sat/Pool.cc (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/sat/Pool.cc Thu Jan 10 17:56:09 2008
@@ -22,7 +22,6 @@
#include "zypp/base/Gettext.h"
#include "zypp/base/Exception.h"
-#include "zypp/Pathname.h"
#include "zypp/AutoDispose.h"
#include "zypp/sat/detail/PoolImpl.h"
@@ -142,7 +141,7 @@
{
return str << "sat::pool(" << obj.serial() << "){"
<< obj.reposSize() << "repos|"
- << obj.solvablesSize() << "slov}" << "whatprovides *"<< obj.get()->whatprovides;
+ << obj.solvablesSize() << "slov}";
}
/////////////////////////////////////////////////////////////////
Modified: branches/tmp/ma/jump_sat/libzypp/zypp/sat/Pool.h
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/sat/Pool.h?rev=8258&r1=8257&r2=8258&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/sat/Pool.h (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/sat/Pool.h Thu Jan 10 17:56:09 2008
@@ -14,6 +14,8 @@
#include <iosfwd>
+#include "zypp/Pathname.h"
+
#include "zypp/sat/detail/PoolMember.h"
#include "zypp/sat/Repo.h"
@@ -21,7 +23,6 @@
namespace zypp
{ /////////////////////////////////////////////////////////////////
- class Pathname;
class SerialNumber;
///////////////////////////////////////////////////////////////////
Modified: branches/tmp/ma/jump_sat/libzypp/zypp/sat/Solvable.cc
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/sat/Solvable.cc?rev=8258&r1=8257&r2=8258&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/sat/Solvable.cc (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/sat/Solvable.cc Thu Jan 10 17:56:09 2008
@@ -75,28 +75,54 @@
ResKind Solvable::kind() const
{
NO_SOLVABLE_RETURN( ResKind() );
- if ( _kind.empty() )
+ // detect srcpackages by 'arch'
+ switch ( _solvable->arch )
{
- switch ( _solvable->arch )
+ case ARCH_SRC:
+ case ARCH_NOSRC:
+ return ResKind::srcpackage;
+ break;
+ }
+
+ const char * ident = IdStr( _solvable->name ).c_str();
+ const char * sep = ::strchr( ident, ':' );
+
+ // no ':' in package names (hopefully)
+ if ( ! sep )
+ return ResKind::package;
+
+ // quick check for well known kinds
+ if ( sep-ident >= 4 )
+ {
+ switch ( ident[3] )
{
- case ARCH_SRC:
- case ARCH_NOSRC:
- _kind = resKind<SrcPackage>();
- break;
-
- default:
-#warning FIX KindId calc or index
- break;
+#define OUTS(K,S) if ( ::strncmp( ident, ResKind::K.c_str(), S ) ) return ResKind::K
+ // ----v
+ case 'c': OUTS( patch, 5 ); break;
+ case 'd': OUTS( product, 7 ); break;
+ case 'e': OUTS( selection, 9 ); break;
+ case 'g': OUTS( language, 8 ); break;
+ case 'i': OUTS( script, 6 ); break;
+ case 'k': OUTS( package, 7 ); break;
+ case 'm': OUTS( atom, 4 ); break;
+ case 'p': OUTS( srcpackage, 10 ); break;
+ case 's': OUTS( message, 7 ); break;
+ case 't': OUTS( pattern, 7 );
+ OUTS( system, 6 ); break;
+#undef OUTS
}
}
- return _kind;
+
+ // an unknown kind
+ return ResKind( std::string( ident, sep-ident ) );
}
std::string Solvable::name() const
{
-#warning FIX Name skip kind or own Id
NO_SOLVABLE_RETURN( std::string() );
- return ident().string();
+ const char * ident = IdStr( _solvable->name ).c_str();
+ const char * sep = ::strchr( ident, ':' );
+ return( sep ? sep+1 : ident );
}
EvrId Solvable::edition() const
@@ -164,7 +190,7 @@
return str << "sat::solvable()";
return str << "sat::solvable(" << obj.id() << "|"
- << obj.ident() << '-' << obj.edition() << '.' << obj.arch() << "){"
+ << obj.kind() << ':' << obj.name() << '-' << obj.edition() << '.' << obj.arch() << "){"
<< obj.repo().name() << "}";
}
Modified: branches/tmp/ma/jump_sat/libzypp/zypp/sat/Solvable.h
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/sat/Solvable.h?rev=8258&r1=8257&r2=8258&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/sat/Solvable.h (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/sat/Solvable.h Thu Jan 10 17:56:09 2008
@@ -47,6 +47,8 @@
* \ref Solvable will hide this inconsistency by treating source
* packages as an own kind of solvable and map their arch to
* \ref Arch_noarch.
+ *
+ *
*/
class Solvable : protected detail::PoolMember,
private base::SafeBool<Solvable>
@@ -74,12 +76,12 @@
Repo repo() const;
public:
- IdStr ident() const;
- ResKind kind() const;
- std::string name() const;
- EvrId edition() const;
- ArchId arch() const;
- VendorId vendor() const;
+ IdStr ident() const;
+ ResKind kind() const;
+ std::string name() const;
+ EvrId edition() const;
+ ArchId arch() const;
+ VendorId vendor() const;
public:
@@ -102,7 +104,6 @@
Capabilities prerequires() const;
//@}
-
public:
/** Return next Solvable in \ref Pool (or \ref nosolvable). */
Solvable nextInPool() const;
@@ -119,7 +120,6 @@
bool boolTest() const { return get(); }
private:
detail::SolvableIdType _id;
- mutable ResKind _kind; // lazy init
};
///////////////////////////////////////////////////////////////////
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org