return nkp.availableBegin()->status().setTransact( true, ResStatus::USER );
}
+ struct PrintX
+ {
+ PrintX( map<NVRA,string> & nvrmap )
+ : m(nvrmap)
+ {}
+ void operator()( const NVRA & i ) const
+ {
+ INT << i << ": " << m[i] << endl;
+ }
+ map<NVRA,string> & m;
+ };
+
/******************************************************************
**
** FUNCTION NAME : main
//zypp::base::LogControl::instance().logfile( "xxx" );
INT << "===[START]==========================================" << endl;
+ map<NVRA,string> nvrmap;
+
+ NVRA a( "foo", Edition(""), Arch_noarch );
+ NVRA b( "baa", Edition(""), Arch_i386 );
+ NVRA c( "kaa", Edition(""), Arch_i486 );
+ NVRA d( "daa", Edition(""), Arch_ppc );
+
+ nvrmap[a] = "A";
+ nvrmap[b] = "B";
+ nvrmap[c] = "C";
+ nvrmap[d] = "D";
+
+ INT << nvrmap.size() << endl;
+ std::for_each( make_map_key_begin( nvrmap ), make_map_key_end( nvrmap ),
+ PrintOn<NVRA>(INT) );
+ std::for_each( make_map_key_begin( nvrmap ), make_map_key_end( nvrmap ),
+ PrintX(nvrmap) );
+
+ INT << nvrmap[NVRA( "kaa", Edition(""), Arch_i386 )] << endl;
+
+ return 0;
+
ResPool pool( getZYpp()->pool() );
- getZYpp()->initTarget( sysRoot );
- getZYpp()->addResolvables( getZYpp()->target()->resolvables(), true );
- INT << "Added target: " << pool << endl;
+ if ( 0 )
+ {
+ getZYpp()->initTarget( sysRoot );
+ getZYpp()->addResolvables( getZYpp()->target()->resolvables(), true );
+ INT << "Added target: " << pool << endl;
+ }
+
+ Url myUrl( "dir:/mounts/machcd2/CDs/SLES-10-CD-i386-Beta10/CD1" );
+ Source_Ref src1;
+ USR << src1 << endl;
+ try
+ {
+ src1 = SourceFactory().createFrom( myUrl, "/", Date::now().asSeconds() );
+ }
+ catch ( const Exception & )
+ {
+ ;
+ }
+ USR << src1 << endl;
+#if 0
Source_Ref src1( createSource( "dir:/mounts/machcd2/CDs/SLES-10-CD-i386-Beta10/CD1" ) );
Source_Ref src2( createSource( "dir:/mounts/machcd2/kukuk/sles10-sp-i386/CD1" ) );
getZYpp()->addResolvables( src1.resolvables() );
ZYppCommitResult res( getZYpp()->commit( policy ) );
}
}
-
+#endif
INT << "===[END]============================================" << endl << endl;
return 0;
}
///////////////////////////////////////////////////////////////////
-struct DebugStats
+struct DebugStats : public std::unary_function<ResObject::constPtr, bool>
{
bool operator()( const ResObject::constPtr & ptr )
{
Source_Ref::NumericId srcid = ptr->source().numericId();
- unsigned mediaid = mediaId( ptr )
+ unsigned mediaid = mediaId( ptr );
USR << "S" << srcid
<< "/M" << mediaid
<< " " << ptr
return true;
}
- unsigned mediaId( const ResObject::constPtr ptr & ptr ) const
+ unsigned mediaId( const ResObject::constPtr & ptr ) const
{
Package::constPtr pkg( asKind<Package>(ptr) );
return pkg ? pkg->mediaId() : 0;
KindMap _perKind;
};
+inline std::ostream & operator<<( std::ostream & str, const DebugStats & obj )
+{ return str; }
template <class _Iterator>
std::ostream & vdumpPoolStats( std::ostream & str,
{
DebugStats stats;
std::for_each( begin_r, end_r,
-
- functor::chain( setTrue_c(PrintPoolItem()),
- setTrue_c(functor::functorRef<void,ResObject::constPtr>(stats)) )
-
- );
+ functor::functorRef<bool,ResObject::constPtr>(stats) );
return str << stats;
}
return nkp.availableBegin()->status().setTransact( true, ResStatus::USER );
}
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+#if 0
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : EnumerationClass<_Derived>
+ //
+ /** EnumerationClass.
+ */
+ template<class _Derived>
+ class EnumerationClass
+ {
+ public:
+ /** The enum */
+ typedef _Derived::for_use_in_switch for_use_in_switch;
+
+ /** String representation of enumarator. */
+ const std::string & asString() const;
+
+ /** Enumarator provided for use in \c switch statement. */
+ for_use_in_switch inSwitch() const
+ { return _op };
+
+ protected:
+ /** Ctor */
+ EnumerationClass( for_use_in_switch op_r )
+ : _op( op_r )
+ {}
+ private:
+ /** The enum value. */
+ for_use_in_switch _op;
+ };
+ ///////////////////////////////////////////////////////////////////
+
+ /** \relates EnumerationClass Stream output. */
+ template<class _Derived>
+ inline std::ostream & operator<<( std::ostream & str, const EnumerationClass<_Derived> & obj )
+ { return str << obj.asString(); }
+
+ /** \relates EnumerationClass Stream output. */
+ template<class _Derived>
+ inline bool operator==( const EnumerationClass<_Derived> & lhs, const EnumerationClass<_Derived> & rhs )
+ { return lhs.inSwitch() == rhs.inSwitch(); }
+
+ /** \relates PatchCategory */
+ template<class _Derived>
+ inline bool operator!=( const EnumerationClass<_Derived> & lhs, const EnumerationClass<_Derived> & rhs )
+ { return ! ( lhs == rhs ); }
+#endif
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
/******************************************************************
**
//zypp::base::LogControl::instance().logfile( "xxx" );
INT << "===[START]==========================================" << endl;
+ enum for_use_in_switch { a, b, c };
+
+ struct Edef
+ {
+ for_use_in_switch _val;
+ const char * _tostr;
+ const char * _fromstr[];
+ };
+
+ const char * fromstr[] = { "a", "A" };
+
+ Edef x[] = { a, "a", "A" };
+
+ return 0;
+ INT << "===[END]============================================" << endl << endl;
ResPool pool( getZYpp()->pool() );
if ( 0 )