#ifndef ZYPP_RESOBJECT_H
#define ZYPP_RESOBJECT_H
-#include "zypp/base/Deprecated.h"
+#include "zypp/APIConfig.h"
#include "zypp/Resolvable.h"
-#include "zypp/NeedAType.h"
-#include "zypp/Date.h"
-#include "zypp/ByteCount.h"
-#include "zypp/DiskUsage.h"
-#include "zypp/TranslatedText.h"
-#include "zypp/OnMediaLocation.h"
-#include "zypp/Repository.h"
+#include "zypp/Vendor.h"
+
+#include "zypp/sat/LookupAttr.h"
+#include "zypp/sat/SolvableSet.h"
///////////////////////////////////////////////////////////////////
namespace zypp
-{ /////////////////////////////////////////////////////////////////
-
+{
+ ///////////////////////////////////////////////////////////////////
+ /// \class ResObject
+ /// \brief Base for resolvable objects
+ ///
+ /// \note \ref Resolvable is a SolvableType, which provides direct
+ /// access to many of the underlying sat::Solvables properties.
+ /// Don't add common properties here, but in \ref sat::Solvable
+ /// and extend \ref sat::SolvableType.
+ ///
+ /// \see \ref makeResObject for how to construct ResObjects.
+ /// \todo Merge with Resolvable
///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : ResObject
- //
- /**
- * Interface base for resolvable objects (common data).
- * That is, all data not needed for solving, but common
- * across all Resolvable kinds.
- *
- * \see \ref makeResObject for how to construct ResObjects.
- */
class ResObject : public Resolvable
{
public:
typedef TraitsType::constPtrType constPtr;
public:
- /** \name Locale support.
- * \see \ref sat::Solvable
- */
- //@{
- /** \see \ref sat::Solvable::supportsLocales */
- using sat::Solvable::supportsLocales;
- /** \see \ref sat::Solvable::supportsLocale */
- using sat::Solvable::supportsLocale;
- /** \see \ref sat::Solvable::supportsRequestedLocales */
- using sat::Solvable::supportsRequestedLocales;
- /** \see \ref sat::Solvable::getSupportedLocales */
- using sat::Solvable::getSupportedLocales;
- //@}
-
- public:
-
- /**
- * \short Short text describing the resolvable.
- * This attribute is usually displayed in columns.
- */
- Text summary() const;
-
- /**
- * \short Long text describing the resolvable.
- */
- Text description() const;
-
- /**
- * \short Installation Notification
+ /** 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->asKind<Package>();
*
- * This text can be used to tell the user some notes
- * When he selects the resovable for installation.
+ * if ( pi->isKind<Package>() )
+ * DBG << pi->asKind<Package>()->keywords() << endl;
+ * \endcode
*/
- Text insnotify() const;
+ template<class TRes>
+ inline typename ResTraits<TRes>::constPtrType asKind() const;
- /**
- * \short De-Installation Notification
- *
- * This text can be used to tell the user some notes
- * When he selects the resovable for deinstall.
- */
- Text delnotify() const;
-
- /**
- * \short License or agreement to accept
- *
- * Agreement, warning or license the user should
- * accept before installing the resolvable.
- */
- Text licenseToConfirm() const;
+ template<class TRes>
+ inline typename ResTraits<TRes>::PtrType asKind();
+ public:
/**
* \short Vendor
- *
- * For Example "Novell Inc."
+ * \deprecated Though typedef'ed to std::string, Vendor is actually an \ref IdString.
*/
Vendor vendor() const
{ return Resolvable::vendor().asString(); }
- /** Installed size. */
- ByteCount size() const;
-
- /** Size of the rpm package. */
- ByteCount downloadSize() const;
-
- /** \see \ref sat::Solvable::repository */
- using sat::Solvable::repository;
-
- /** \ref RepoInfo associated with the repository
- * providing this resolvable.
- */
- RepoInfo repoInfo() const
- { return repository().info(); }
-
- /**
- * Media number where the resolvable is located
- * 0 if no media access is required.
- */
- unsigned mediaNr() const;
-
- /**
- * \TODO FIXME what is this?
- * Flag in the metadata indicating this should be
- * installed unsing '-i' (not -U).
- */
- bool installOnly() const;
-
- /**
- * \short build time of the resolvable
- */
- Date buildtime() const;
-
- /**
- * \short Installation time
- * 0 if the resolvable is not installed.
- */
- Date installtime() const;
-
- /**
- * \short Disk usage per directory
- * A common attribute, although mostly packages require
- * noticeable disk space. An e.g product could try to reserve
- * a certain ammount of diskspace by providing DiskUsage data.
- */
- const DiskUsage & diskusage() const;
-
protected:
+ friend ResObject::Ptr makeResObject( const sat::Solvable & solvable_r );
/** Ctor */
ResObject( const sat::Solvable & solvable_r );
/** Dtor */
virtual ~ResObject();
/** Helper for stream output */
virtual std::ostream & dumpOn( std::ostream & str ) const;
+ /** This is a \ref sat::SolvableType (allow implicit conversion in derived classes). */
+ operator sat::Solvable() const
+ { return satSolvable(); }
};
///////////////////////////////////////////////////////////////////
* ResObject::Ptr q( make<ResObject>( s ) );
* Package::Ptr pkg( make<Package>( s ) );
* \endcode
+ * \todo make<> was a poor choice (AFAIR because gcc had some trouble with
+ * asKind<>(sat::Solvable)). Remove it in favour of asKind<>(sat::Solvable)
*/
- template<class _Res>
- inline typename ResTraits<_Res>::PtrType make( const sat::Solvable & solvable_r )
- { return( isKind<_Res>( solvable_r ) ? new _Res( solvable_r ) : 0 ); }
+ template<class TRes>
+ inline typename ResTraits<TRes>::PtrType make( const sat::Solvable & solvable_r )
+ { return( isKind<TRes>( solvable_r ) ? new TRes( solvable_r ) : 0 ); }
/** \overload Specialisation for ResObject autodetecting the kind of resolvable. */
template<>
inline ResObject::Ptr make<ResObject>( const sat::Solvable & solvable_r )
{ return makeResObject( solvable_r ); }
+ /** Directly create a certain kind of ResObject from \ref sat::Solvable. */
+ template<class TRes>
+ inline typename ResTraits<TRes>::PtrType asKind( const sat::Solvable & solvable_r )
+ { return make<TRes>( solvable_r ); }
+
/** Convert ResObject::Ptr into Ptr of a certain Kind.
* \return \c NULL iff \a p is \c NULL or points to a Resolvable
* not of the specified Kind.
* asKind<Package>(resPtr);
* \endcode
*/
- template<class _Res>
- inline typename ResTraits<_Res>::PtrType asKind( const ResObject::Ptr & p )
- { return dynamic_pointer_cast<_Res>(p); }
+ template<class TRes>
+ inline typename ResTraits<TRes>::PtrType asKind( const ResObject::Ptr & p )
+ { return dynamic_pointer_cast<TRes>(p); }
+
+ template<class TRes>
+ inline typename ResTraits<TRes>::constPtrType asKind( const ResObject::constPtr & p )
+ { return dynamic_pointer_cast<const TRes>(p); }
+
+ template<class TRes>
+ inline typename ResTraits<TRes>::constPtrType ResObject::asKind() const
+ { return dynamic_cast<const TRes *>( this ); }
- template<class _Res>
- inline typename ResTraits<_Res>::constPtrType asKind( const ResObject::constPtr & p )
- { return dynamic_pointer_cast<const _Res>(p); }
+ template<class TRes>
+ inline typename ResTraits<TRes>::PtrType ResObject::asKind()
+ { return dynamic_cast<TRes *>( this ); }
- /////////////////////////////////////////////////////////////////
} // namespace zypp
///////////////////////////////////////////////////////////////////
#endif // ZYPP_RESOBJECT_H