#undef OUTS
}
-
/******************************************************************
**
** FUNCTION NAME : main
INT << "===[START]==========================================" << endl;
ZConfig::instance();
- Edition a("4.21.3-2");
- DBG << a << endl;
- DBG << (a == a) << endl;
- DBG << (a.match(a)) << endl;
- ///////////////////////////////////////////////////////////////////
- INT << "===[END]============================================" << endl << endl;
- zypp::base::LogControl::instance().logNothing();
- return 0;
-
-
#if 0
RepoManager repoManager( makeRepoManager( sysRoot ) );
}
- //////////////////////////////////////////////////////////////////
+ PoolItem pi ( getPi<Package>("amarok") );
+ MIL << pi << endl;
+ MIL << pi->as<Package>() << endl;
+ MIL << pi->as<Product>() << endl;
+ if ( pi->isKind<Package>() )
+ SEC << pi->as<Package>() << endl;
+
+ //////////////////////////////////////////////////////////////////
INT << "===[END]============================================" << endl << endl;
zypp::base::LogControl::instance().logNothing();
return 0;
typedef TraitsType::constPtrType constPtr;
public:
+
+ /** Convert \c this into a Ptr of a certain Kind.
+ * This is a convenience to access type specific
+ * attributes.
+ * \return \c NULL if \c this is not of the specified kind.
+ * \code
+ * PoolItem pi;
+ * Package::constPtr pkg = pi->as<Package>();
+ *
+ * if ( pi->isKind<Package>() )
+ * DBG << pi->as<Package>()->keywords() << endl;
+ * \endcode
+ */
+ template<class _Res>
+ inline typename ResTraits<_Res>::constPtrType as() const;
+
+ template<class _Res>
+ inline typename ResTraits<_Res>::PtrType as();
+
+ public:
/** \name Locale support.
* \see \ref sat::Solvable
- */
+ */
//@{
/** \see \ref sat::Solvable::supportsLocales */
bool supportsLocales() const
inline typename ResTraits<_Res>::constPtrType asKind( const ResObject::constPtr & p )
{ return dynamic_pointer_cast<const _Res>(p); }
+ template<class _Res>
+ inline typename ResTraits<_Res>::constPtrType ResObject::as() const
+ { return make<_Res>( *this ); }
+
+ template<class _Res>
+ inline typename ResTraits<_Res>::PtrType ResObject::as()
+ { return make<_Res>( *this ); }
+
/////////////////////////////////////////////////////////////////
} // namespace zypp
///////////////////////////////////////////////////////////////////
bool isKind( const ResKind & kind_r ) const
{ return sat::Solvable::isKind( kind_r ); }
+ template<class _Res>
+ bool isKind() const
+ { return sat::Solvable::isKind<_Res>(); }
+
std::string name() const
{ return sat::Solvable::name(); }
ResKind kind() const;
/** Test whether a Solvable is of a certain \ref ResKind. */
bool isKind( const ResKind & kind_r ) const;
+ /** \overload */
+ template<class _Res>
+ bool isKind() const
+ { return isKind( resKind<_Res>() ); }
std::string name() const;
Edition edition() const;