Mailinglist Archive: zypp-commit (266 mails)

< Previous Next >
[zypp-commit] r11747 - in /trunk/libzypp/zypp: CMakeLists.txt Repository.h sat/LookupAttr.cc sat/LookupAttr.h sat/LookupAttrTools.h
  • From: mlandres@xxxxxxxxxxxxxxxx
  • Date: Thu, 20 Nov 2008 15:00:52 -0000
  • Message-id: <20081120150053.17EADDF72F@xxxxxxxxxxxxxxxx>
Author: mlandres
Date: Thu Nov 20 16:00:52 2008
New Revision: 11747

URL: http://svn.opensuse.org/viewcvs/zypp?rev=11747&view=rev
Log:
fix cyclic includes

Added:
trunk/libzypp/zypp/sat/LookupAttrTools.h
Modified:
trunk/libzypp/zypp/CMakeLists.txt
trunk/libzypp/zypp/Repository.h
trunk/libzypp/zypp/sat/LookupAttr.cc
trunk/libzypp/zypp/sat/LookupAttr.h

Modified: trunk/libzypp/zypp/CMakeLists.txt
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/CMakeLists.txt?rev=11747&r1=11746&r2=11747&view=diff
==============================================================================
--- trunk/libzypp/zypp/CMakeLists.txt (original)
+++ trunk/libzypp/zypp/CMakeLists.txt Thu Nov 20 16:00:52 2008
@@ -510,6 +510,7 @@
sat/WhatObsoletes.h
sat/LocaleSupport.h
sat/LookupAttr.h
+ sat/LookupAttrTools.h
sat/SolvAttr.h
)


Modified: trunk/libzypp/zypp/Repository.h
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/Repository.h?rev=11747&r1=11746&r2=11747&view=diff
==============================================================================
--- trunk/libzypp/zypp/Repository.h (original)
+++ trunk/libzypp/zypp/Repository.h Thu Nov 20 16:00:52 2008
@@ -16,8 +16,8 @@
#include "zypp/base/SafeBool.h"
#include "zypp/Pathname.h"
#include "zypp/sat/detail/PoolMember.h"
+#include "zypp/sat/LookupAttr.h" // LookupAttrTools.h included at EOF
#include "zypp/sat/Solvable.h"
-#include "zypp/sat/SolvAttr.h"
#include "zypp/RepoInfo.h"
#include "zypp/Date.h"

@@ -25,12 +25,6 @@
namespace zypp
{ /////////////////////////////////////////////////////////////////

- namespace sat
- {
- template<class _ResultT, class _AttrT>
- class ArrayAttr;
- }
-
namespace detail
{
struct ByRepository;
@@ -165,7 +159,7 @@
SolvableIterator solvablesEnd() const;

public:
-#if 0
+
/** Query class for Repository */
class ProductInfoIterator;

@@ -196,7 +190,7 @@
* \see Repository::ProductInfoIterator
*/
ProductInfoIterator updatesProductEnd() const;
-#endif
+
public:
/** Return any associated \ref RepoInfo. */
RepoInfo info() const;
@@ -282,6 +276,67 @@
inline bool operator<( const Repository & lhs, const Repository & rhs )
{ return lhs.get() < rhs.get(); }

+
+ /**
+ * Query class for Repository related products
+ *
+ * The iterator does not provide a dereference
+ * operator so you can do * on it, but you can
+ * access the attributes of each related product
+ * directly from the iterator.
+ *
+ * \code
+ * for ( Repository::ProductInfoIterator it =
repo->compatibleWithProductBegin();
+ * it != repo->compatibleWithProductEnd();
+ * ++it )
+ * {
+ * cout << it.cpeid() << endl;
+ * }
+ * \endcode
+ *
+ */
+ class Repository::ProductInfoIterator : public boost::iterator_adaptor<
+ Repository::ProductInfoIterator // Derived
+ , sat::LookupAttr::iterator // Base
+ , int // Value
+ , boost::forward_traversal_tag // CategoryOrTraversal
+ , int
+ >
+ {
+ public:
+ ProductInfoIterator() {}
+ explicit ProductInfoIterator( const sat::SolvAttr & arrayid );
+
+ /**
+ * Product label
+ */
+ std::string label() const;
+
+ /**
+ * The Common Platform Enumeration name
+ * for this product.
+ *
+ * See http://cpe.mitre.org
+ */
+ std::string cpeid() const;
+
+ private:
+ friend class boost::iterator_core_access;
+ int dereference() const { return 0; }
+ };
+
+ inline Repository::ProductInfoIterator
Repository::compatibleWithProductBegin() const
+ { return ProductInfoIterator( sat::SolvAttr::repositoryDistros ); }
+
+ inline Repository::ProductInfoIterator
Repository::compatibleWithProductEnd() const
+ { return ProductInfoIterator(); }
+
+ inline Repository::ProductInfoIterator Repository::updatesProductBegin()
const
+ { return ProductInfoIterator( sat::SolvAttr::repositoryUpdates ); }
+
+ inline Repository::ProductInfoIterator Repository::updatesProductEnd()
const
+ { return ProductInfoIterator(); }
+
///////////////////////////////////////////////////////////////////
//
// CLASS NAME : Repository::EraseFromPool
@@ -318,6 +373,7 @@
{ repository_r.eraseFromPool(); }
};
///////////////////////////////////////////////////////////////////
+
///////////////////////////////////////////////////////////////////
namespace detail
{ /////////////////////////////////////////////////////////////////
@@ -326,128 +382,57 @@
// CLASS NAME : RepositoryIterator
//
/** */
- class RepositoryIterator : public boost::iterator_adaptor<
+ class RepositoryIterator : public boost::iterator_adaptor<
RepositoryIterator // Derived
, ::_Repo ** // Base
- , Repository // Value
+ , Repository // Value
, boost::forward_traversal_tag // CategoryOrTraversal
, Repository // Reference
>
- {
+ {
public:
- RepositoryIterator()
- : RepositoryIterator::iterator_adaptor_( 0 )
- {}
-
- explicit RepositoryIterator( ::_Repo ** p )
- : RepositoryIterator::iterator_adaptor_( p )
- {}
+ RepositoryIterator()
+ : RepositoryIterator::iterator_adaptor_( 0 )
+ {}
+
+ explicit RepositoryIterator( ::_Repo ** p )
+ : RepositoryIterator::iterator_adaptor_( p )
+ {}

private:
- friend class boost::iterator_core_access;
+ friend class boost::iterator_core_access;

- Repository dereference() const
- { return Repository( *base() ); }
- };
- ///////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : ByRepository
- //
- /** Functor filtering \ref Solvable by \ref Repository.*/
- struct ByRepository
- {
+ Repository dereference() const
+ { return Repository( *base() ); }
+ };
+ ///////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : ByRepository
+ //
+ /** Functor filtering \ref Solvable by \ref Repository.*/
+ struct ByRepository
+ {
public:
- ByRepository( const Repository & repository_r ) : _repository(
repository_r ) {}
- ByRepository( sat::detail::RepoIdType id_r ) : _repository( id_r )
{}
- ByRepository() {}
+ ByRepository( const Repository & repository_r ) : _repository(
repository_r ) {}
+ ByRepository( sat::detail::RepoIdType id_r ) : _repository( id_r ) {}
+ ByRepository() {}

- bool operator()( const sat::Solvable & slv_r ) const
- { return slv_r.repository() == _repository; }
+ bool operator()( const sat::Solvable & slv_r ) const
+ { return slv_r.repository() == _repository; }

private:
- Repository _repository;
- };
- ///////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////
+ Repository _repository;
+ };
+ ///////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////
} // namespace detail
///////////////////////////////////////////////////////////////////
-
- /////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////
} // namespace zypp
///////////////////////////////////////////////////////////////////

-#include "zypp/sat/LookupAttr.h"
-
-#if 0
-
-namespace zypp
-{
- /**
- * Query class for Repository related products
- *
- * The iterator does not provide a dereference
- * operator so you can do * on it, but you can
- * access the attributes of each related product
- * directly from the iterator.
- *
- * \code
- * for ( Repository::ProductInfoIterator it =
repo->compatibleWithProductBegin();
- * it != repo->compatibleWithProductEnd();
- * ++it )
- * {
- * cout << it.cpeid() << endl;
- * }
- * \endcode
- *
- */
- class Repository::ProductInfoIterator : public boost::iterator_adaptor<
- Repository::ProductInfoIterator // Derived
- , sat::LookupAttr::iterator // Base
- , int // Value
- , boost::forward_traversal_tag // CategoryOrTraversal
- , int
- >
- {
- public:
- ProductInfoIterator() {}
- explicit ProductInfoIterator( const sat::Solvable & val_r,
- const sat::SolvAttr & arrayid );
-
- /**
- * Product label
- */
- std::string label() const;
-
- /**
- * The Common Platform Enumeration name
- * for this product.
- *
- * See http://cpe.mitre.org
- */
- std::string cpeid() const;
-
- private:
- friend class boost::iterator_core_access;
- int dereference() const { return 0; }
- };
-
- inline Repository::ProductInfoIterator
Repository::compatibleWithProductBegin() const
- { return ProductInfoIterator(satSolvable(),
sat::SolvAttr::repositoryDistros); }
-
- inline Repository::ProductInfoIterator
Repository::compatibleWithProductEnd() const
- { return ProductInfoIterator(); }
-
- inline Repository::ProductInfoIterator Repository::updatesProductBegin()
const
- { return ProductInfoIterator(satSolvable(), ,
sat::SolvAttr::repositoryUpdates); }
-
- inline Repository::ProductInfoIterator Repository::updatesProductEnd() const
- { return ProductInfoIterator(); }
-
-
-}
-#endif
+// Late include as sat::ArrayAttr requires Repository.h
+#include "zypp/sat/LookupAttrTools.h"

#endif // ZYPP_SAT_REPOSITORY_H
-
-

Modified: trunk/libzypp/zypp/sat/LookupAttr.cc
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/sat/LookupAttr.cc?rev=11747&r1=11746&r2=11747&view=diff
==============================================================================
--- trunk/libzypp/zypp/sat/LookupAttr.cc (original)
+++ trunk/libzypp/zypp/sat/LookupAttr.cc Thu Nov 20 16:00:52 2008
@@ -19,6 +19,7 @@

#include "zypp/sat/LookupAttr.h"
#include "zypp/CheckSum.h"
+#include "zypp/sat/Pool.h"

using std::endl;

@@ -29,38 +30,162 @@
namespace sat
{ /////////////////////////////////////////////////////////////////

- LookupAttr::iterator LookupAttr::begin() const
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : LookupAttr::Impl
+ //
+ ///////////////////////////////////////////////////////////////////
+
+ class LookupAttr::Impl
{
- if ( _attr == SolvAttr::noAttr )
- return iterator();
+ public:
+ Impl()
+ {}
+ Impl( SolvAttr attr_r )
+ : _attr( attr_r )
+ {}
+ Impl( SolvAttr attr_r, Repository repo_r )
+ : _attr( attr_r ), _repo( repo_r )
+ {}
+ Impl( SolvAttr attr_r, Solvable solv_r )
+ : _attr( attr_r ), _solv( solv_r )
+ {}
+
+ public:
+ SolvAttr attr() const
+ { return _attr; }
+
+ void setAttr( SolvAttr attr_r )
+ { _attr = attr_r; }
+
+ public:
+ bool pool() const
+ { return ! (_repo || _solv); }
+
+ void setPool()
+ {
+ _repo = Repository::noRepository;
+ _solv = Solvable::noSolvable;
+ }
+
+ Repository repo() const
+ { return _repo; }
+
+ void setRepo( Repository repo_r )
+ {
+ _repo = repo_r;
+ _solv = Solvable::noSolvable;
+ }
+
+ Solvable solvable() const
+ { return _solv; }
+
+ void setSolvable( Solvable solv_r )
+ {
+ _repo = Repository::noRepository;
+ _solv = solv_r;
+ }
+
+ LookupAttr::iterator begin() const
+ {
+ if ( _attr == SolvAttr::noAttr )
+ return end();

#warning Need to call dataiterator_free, use Autodispose instead of scoped_ptr
- scoped_ptr< ::_Dataiterator> dip( new ::Dataiterator );
- // needed while LookupAttr::iterator::dip_equal does ::memcmp:
- ::memset( dip.get(), 0, sizeof(::_Dataiterator) );
+ scoped_ptr< ::_Dataiterator> dip( new ::Dataiterator );
+ // needed while LookupAttr::iterator::dip_equal does ::memcmp:
+ ::memset( dip.get(), 0, sizeof(::_Dataiterator) );
+
+ if ( _solv )
+ {
+ ::dataiterator_init( dip.get(), sat::Pool::instance().get(),
_solv.repository().id(), _solv.id(), _attr.id(), 0, 0 );
+ }
+ else if ( _repo )
+ {
+ ::dataiterator_init( dip.get(), sat::Pool::instance().get(),
_repo.id(), 0, _attr.id(), 0, 0 );
+ }
+ else if ( ! sat::Pool::instance().reposEmpty() )
+ {
+ ::dataiterator_init( dip.get(), sat::Pool::instance().get(),
0, 0, _attr.id(), 0, 0 );
+ }
+ else
+ return end();

- if ( _solv )
- {
- ::dataiterator_init( dip.get(), sat::Pool::instance().get(),
_solv.repository().id(), _solv.id(), _attr.id(), 0, 0 );
- }
- else if ( _repo )
- {
- ::dataiterator_init( dip.get(), sat::Pool::instance().get(),
_repo.id(), 0, _attr.id(), 0, 0 );
- }
- else if ( ! sat::Pool::instance().reposEmpty() )
- {
- ::dataiterator_init( dip.get(), sat::Pool::instance().get(),
0, 0, _attr.id(), 0, 0 );
- }
- else
- return iterator();
+ return iterator( dip ); // iterator takes over ownership!
+ }

- return iterator( dip ); // iterator takes over ownership!
- }
+ LookupAttr::iterator end() const
+ { return iterator(); }
+
+ private:
+ SolvAttr _attr;
+ Repository _repo;
+ Solvable _solv;
+
+ private:
+ friend Impl * rwcowClone<Impl>( const Impl * rhs );
+ /** clone for RWCOW_pointer */
+ Impl * clone() const
+ { return new Impl( *this ); }
+ };
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : LookupAttr
+ //
+ ///////////////////////////////////////////////////////////////////
+
+ LookupAttr::LookupAttr()
+ : _pimpl( new Impl )
+ {}
+
+ LookupAttr::LookupAttr( SolvAttr attr_r )
+ : _pimpl( new Impl( attr_r ) )
+ {}
+
+ LookupAttr::LookupAttr( SolvAttr attr_r, Repository repo_r )
+ : _pimpl( new Impl( attr_r, repo_r ) )
+ {}
+
+ LookupAttr::LookupAttr( SolvAttr attr_r, Solvable solv_r )
+ : _pimpl( new Impl( attr_r, solv_r ) )
+ {}
+
+ ///////////////////////////////////////////////////////////////////
+
+ SolvAttr LookupAttr::attr() const
+ { return _pimpl->attr(); }
+
+ void LookupAttr::setAttr( SolvAttr attr_r )
+ { _pimpl->setAttr( attr_r ); }
+
+ ///////////////////////////////////////////////////////////////////
+
+ bool LookupAttr::pool() const
+ { return _pimpl->pool(); }
+
+ void LookupAttr::setPool()
+ { _pimpl->setPool(); }
+
+ Repository LookupAttr::repo() const
+ { return _pimpl->repo(); }
+
+ void LookupAttr::setRepo( Repository repo_r )
+ { _pimpl->setRepo( repo_r ); }
+
+ Solvable LookupAttr::solvable() const
+ { return _pimpl->solvable(); }
+
+ void LookupAttr::setSolvable( Solvable solv_r )
+ { _pimpl->setSolvable( solv_r ); }
+
+ ///////////////////////////////////////////////////////////////////
+
+ LookupAttr::iterator LookupAttr::begin() const
+ { return _pimpl->begin(); }

LookupAttr::iterator LookupAttr::end() const
- {
- return iterator();
- }
+ { return _pimpl->end(); }

bool LookupAttr::empty() const
{ return begin() == end(); }
@@ -73,6 +198,8 @@
return c;
}

+ ///////////////////////////////////////////////////////////////////
+
std::ostream & operator<<( std::ostream & str, const LookupAttr & obj )
{
if ( obj.attr() == SolvAttr::noAttr )

Modified: trunk/libzypp/zypp/sat/LookupAttr.h
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/sat/LookupAttr.h?rev=11747&r1=11746&r2=11747&view=diff
==============================================================================
--- trunk/libzypp/zypp/sat/LookupAttr.h (original)
+++ trunk/libzypp/zypp/sat/LookupAttr.h Thu Nov 20 16:00:52 2008
@@ -21,11 +21,15 @@
#include "zypp/base/PtrTypes.h"
#include "zypp/base/DefaultIntegral.h"

-#include "zypp/sat/Pool.h"
+#include "zypp/sat/detail/PoolMember.h"
+#include "zypp/sat/SolvAttr.h"

///////////////////////////////////////////////////////////////////
namespace zypp
{ /////////////////////////////////////////////////////////////////
+
+ class CheckSum;
+
///////////////////////////////////////////////////////////////////
namespace sat
{ /////////////////////////////////////////////////////////////////
@@ -75,22 +79,16 @@

public:
/** Default ctor finds nothing. */
- LookupAttr()
- {}
+ LookupAttr();
+
/** Lookup \ref SolvAttr in \ref Pool (all repositories). */
- explicit
- LookupAttr( SolvAttr attr_r )
- : _attr( attr_r )
- {}
+ explicit LookupAttr( SolvAttr attr_r );
+
/** Lookup \ref SolvAttr in one\ref Repository. */
- explicit
- LookupAttr( SolvAttr attr_r, Repository repo_r )
- : _attr( attr_r ), _repo( repo_r )
- {}
+ explicit LookupAttr( SolvAttr attr_r, Repository repo_r );
+
/** Lookup \ref SolvAttr in one \ref Solvable. */
- LookupAttr( SolvAttr attr_r, Solvable solv_r )
- : _attr( attr_r ), _solv( solv_r )
- {}
+ LookupAttr( SolvAttr attr_r, Solvable solv_r );

public:
/** \name Search result. */
@@ -120,55 +118,37 @@
/** \name What to search. */
//@{
/** The \ref SolvAttr to search. */
- SolvAttr attr() const
- { return _attr; }
+ SolvAttr attr() const;

/** Set the \ref SolvAttr to search. */
- void setAttr( SolvAttr attr_r )
- { _attr = attr_r; }
+ void setAttr( SolvAttr attr_r );
//@}

public:
/** \name Where to search. */
//@{
/** Wheter to search in \ref Pool. */
- bool pool() const
- { return ! (_repo || _solv); }
+ bool pool() const;

/** Set search in \ref Pool (all repositories). */
- void setPool()
- {
- _repo = Repository::noRepository;
- _solv = Solvable::noSolvable;
- }
+ void setPool();

/** Wheter to search in one \ref Repository. */
- Repository repo() const
- { return _repo; }
+ Repository repo() const;

/** Set search in one \ref Repository. */
- void setRepo( Repository repo_r )
- {
- _repo = repo_r;
- _solv = Solvable::noSolvable;
- }
+ void setRepo( Repository repo_r );

/** Wheter to search in one \ref Solvable. */
- Solvable solvable() const
- { return _solv; }
+ Solvable solvable() const;

/** Set search in one \ref Solvable. */
- void setSolvable( Solvable solv_r )
- {
- _repo = Repository::noRepository;
- _solv = solv_r;
- }
+ void setSolvable( Solvable solv_r );
//@}

private:
- SolvAttr _attr;
- Repository _repo;
- Solvable _solv;
+ class Impl;
+ RWCOW_pointer<Impl> _pimpl;
};
///////////////////////////////////////////////////////////////////

@@ -391,6 +371,10 @@
/** \relates LookupAttr::iterator Stream output. */
std::ostream & operator<<( std::ostream & str, const LookupAttr::iterator
& obj );

+ ///////////////////////////////////////////////////////////////////
+
+ /** \name Helpers and forward declarations from LookupAttrTools.h */
+ //@{
template<> inline int LookupAttr::iterator::asType<int>()
const { return asInt(); }
template<> inline unsigned LookupAttr::iterator::asType<unsigned>()
const { return asUnsigned(); }
template<> inline bool LookupAttr::iterator::asType<bool>()
const { return asBool(); }
@@ -398,182 +382,9 @@
template<> inline std::string LookupAttr::iterator::asType<std::string>()
const { return asString(); }
template<> inline IdString LookupAttr::iterator::asType<IdString>()
const { return idStr(); }

- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : LookupAttr::transformIterator
- //
- /** TransformIterator returning an \ref iterator value of type \c _ResultT.
- *
- * The underlying LookupAttr::iterators value is retrieved \ref
asType<_AttrT>
- * and the returned \ref ResultT is constructed fron that value.
- *
- * \code
- * class Keywords
- * {
- * public:
- * Keywords( sat::Solvable solv_r )
- * : _q( sat::SolvAttr::keywords, solv_r )
- * {}
- *
- * public:
- * typedef
sat::LookupAttr::transformIterator<PackageKeyword,IdString> iterator;
- *
- * iterator begin() const { return iterator( _q.begin() ); }
- * iterator end() const { return iterator( _q.end() ); }
- *
- * private:
- * sat::LookupAttr _q;
- * };
- * \endcode
- *
- * \see \ref ArrayAttr.
- */
- template<class _ResultT, class _AttrT>
- class LookupAttr::transformIterator : public boost::iterator_adaptor<
- transformIterator<_ResultT,_AttrT> // Derived
- , LookupAttr::iterator // Base
- , _ResultT // Value
- , boost::forward_traversal_tag // CategoryOrTraversal
- , _ResultT // Reference
- >
- {
- public:
- transformIterator()
- {}
-
- explicit
- transformIterator( const LookupAttr::iterator & val_r )
- { this->base_reference() = val_r; }
-
- public:
-
- /** \name Moving fast forward. */
- //@{
- /** On the next call to \ref operator++ advance to the next \ref
SolvAttr. */
- void nextSkipSolvAttr()
- { this->base_reference().nextSkipSolvAttr(); }
-
- /** On the next call to \ref operator++ advance to the next \ref
Solvable. */
- void nextSkipSolvable()
- { this->base_reference().nextSkipSolvable(); }
-
- /** On the next call to \ref operator++ advance to the next \ref
Repository. */
- void nextSkipRepo()
- { this->base_reference().nextSkipRepo(); }
-
- /** Immediately advance to the next \ref SolvAttr. */
- void skipSolvAttr()
- { this->base_reference().skipSolvAttr(); }
-
- /** Immediately advance to the next \ref Solvable. */
- void skipSolvable()
- { this->base_reference().skipSolvable(); }
-
- /** Immediately advance to the next \ref Repository. */
- void skipRepo()
- { this->base_reference().skipRepo(); }
- //@}
-
- /** \name Current position info. */
- //@{
- /** The current \ref Repository. */
- Repository inRepo() const
- { return this->base_reference().inRepo(); }
-
- /** The current \ref Solvabele. */
- Solvable inSolvable() const
- { return this->base_reference().inSolvable(); }
-
- /** The current \ref SolvAttr. */
- SolvAttr inSolvAttr() const
- { return this->base_reference().inSolvAttr(); }
- //@}
-
- private:
- friend class boost::iterator_core_access;
-
- _ResultT dereference() const
- {
- const LookupAttr::iterator lit( this->base_reference() );
- return _ResultT( lit.asType<_AttrT>() );
- }
- };
- ///////////////////////////////////////////////////////////////////
-
template<class _ResultT, class _AttrT>
class ArrayAttr;
-
- template<class _ResultT, class _AttrT>
- std::ostream & operator<<( std::ostream & str, const
ArrayAttr<_ResultT,_AttrT> & obj );
-
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : ArrayAttr
- //
- /** \ref LookupAttr::transformIterator based container to retrieve list
attributes.
- *
- * \code
- * typedef ArrayAttr<PackageKeyword,IdString> Keywords;
- * Keywords k( sat::SolvAttr::keywords );
- * dumpRange( MIL << "All Keywords: ", k.begin(), k.end() ) << endl;
- * \endcode
- *
- * \todo Maybe add some way to unify the result.
- */
- template<class _ResultT, class _AttrT>
- class ArrayAttr
- {
- friend std::ostream & operator<< <_ResultT,_AttrT>( std::ostream & str,
const ArrayAttr<_ResultT,_AttrT> & obj );
-
- public:
- ArrayAttr()
- {}
-
- ArrayAttr( SolvAttr attr_r )
- : _q( attr_r )
- {}
-
- ArrayAttr( SolvAttr attr_r, Repository repo_r )
- : _q( attr_r, repo_r )
- {}
-
- ArrayAttr( SolvAttr attr_r, Solvable solv_r )
- : _q( attr_r, solv_r )
- {}
-
- public:
- typedef sat::LookupAttr::transformIterator<_ResultT,_AttrT> iterator;
-
- iterator begin() const
- { return iterator( _q.begin() ); }
-
- iterator end() const
- { return iterator( _q.end() ); }
-
- bool empty() const
- { return _q.empty(); }
-
- public:
-
- iterator find( const _ResultT & key_r ) const
- {
- for_( it, begin(), end() )
- {
- if ( *it == key_r )
- return it;
- }
- return end();
- }
-
- private:
- sat::LookupAttr _q;
- };
- ///////////////////////////////////////////////////////////////////
-
- /** \relates LookupAttr::iterator Stream output. */
- template<class _ResultT, class _AttrT>
- inline std::ostream & operator<<( std::ostream & str, const
ArrayAttr<_ResultT,_AttrT> & obj )
- { return dumpOn( str, obj._q); }
+ //@}

/////////////////////////////////////////////////////////////////
} // namespace sat

Added: trunk/libzypp/zypp/sat/LookupAttrTools.h
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/sat/LookupAttrTools.h?rev=11747&view=auto
==============================================================================
--- trunk/libzypp/zypp/sat/LookupAttrTools.h (added)
+++ trunk/libzypp/zypp/sat/LookupAttrTools.h Thu Nov 20 16:00:52 2008
@@ -0,0 +1,208 @@
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/sat/LookupAttrTools.h
+ *
+*/
+#ifndef ZYPP_SAT_LOOKUPATTRTOOLS_H
+#define ZYPP_SAT_LOOKUPATTRTOOLS_H
+
+#include "zypp/sat/LookupAttr.h"
+#include "zypp/Repository.h"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////
+ namespace sat
+ { /////////////////////////////////////////////////////////////////
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : LookupAttr::transformIterator
+ //
+ /** TransformIterator returning an \ref iterator value of type \c _ResultT.
+ *
+ * The underlying LookupAttr::iterators value is retrieved \ref
asType<_AttrT>
+ * and the returned \ref ResultT is constructed fron that value.
+ *
+ * \code
+ * class Keywords
+ * {
+ * public:
+ * Keywords( sat::Solvable solv_r )
+ * : _q( sat::SolvAttr::keywords, solv_r )
+ * {}
+ *
+ * public:
+ * typedef
sat::LookupAttr::transformIterator<PackageKeyword,IdString> iterator;
+ *
+ * iterator begin() const { return iterator( _q.begin() ); }
+ * iterator end() const { return iterator( _q.end() ); }
+ *
+ * private:
+ * sat::LookupAttr _q;
+ * };
+ * \endcode
+ *
+ * \see \ref ArrayAttr.
+ */
+ template<class _ResultT, class _AttrT>
+ class LookupAttr::transformIterator : public boost::iterator_adaptor<
+ transformIterator<_ResultT,_AttrT> // Derived
+ , LookupAttr::iterator // Base
+ , _ResultT // Value
+ , boost::forward_traversal_tag // CategoryOrTraversal
+ , _ResultT // Reference
+ >
+ {
+ public:
+ transformIterator()
+ {}
+
+ explicit
+ transformIterator( const LookupAttr::iterator & val_r )
+ { this->base_reference() = val_r; }
+
+ public:
+
+ /** \name Moving fast forward. */
+ //@{
+ /** On the next call to \ref operator++ advance to the next \ref
SolvAttr. */
+ void nextSkipSolvAttr()
+ { this->base_reference().nextSkipSolvAttr(); }
+
+ /** On the next call to \ref operator++ advance to the next \ref
Solvable. */
+ void nextSkipSolvable()
+ { this->base_reference().nextSkipSolvable(); }
+
+ /** On the next call to \ref operator++ advance to the next \ref
Repository. */
+ void nextSkipRepo()
+ { this->base_reference().nextSkipRepo(); }
+
+ /** Immediately advance to the next \ref SolvAttr. */
+ void skipSolvAttr()
+ { this->base_reference().skipSolvAttr(); }
+
+ /** Immediately advance to the next \ref Solvable. */
+ void skipSolvable()
+ { this->base_reference().skipSolvable(); }
+
+ /** Immediately advance to the next \ref Repository. */
+ void skipRepo()
+ { this->base_reference().skipRepo(); }
+ //@}
+
+ /** \name Current position info. */
+ //@{
+ /** The current \ref Repository. */
+ Repository inRepo() const
+ { return this->base_reference().inRepo(); }
+
+ /** The current \ref Solvabele. */
+ Solvable inSolvable() const
+ { return this->base_reference().inSolvable(); }
+
+ /** The current \ref SolvAttr. */
+ SolvAttr inSolvAttr() const
+ { return this->base_reference().inSolvAttr(); }
+ //@}
+
+ private:
+ friend class boost::iterator_core_access;
+
+ _ResultT dereference() const
+ {
+ const LookupAttr::iterator lit( this->base_reference() );
+ return _ResultT( lit.asType<_AttrT>() );
+ }
+ };
+ ///////////////////////////////////////////////////////////////////
+
+ template<class _ResultT, class _AttrT>
+ class ArrayAttr;
+
+ template<class _ResultT, class _AttrT>
+ std::ostream & operator<<( std::ostream & str, const
ArrayAttr<_ResultT,_AttrT> & obj );
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : ArrayAttr
+ //
+ /** \ref LookupAttr::transformIterator based container to retrieve list
attributes.
+ *
+ * \code
+ * typedef ArrayAttr<PackageKeyword,IdString> Keywords;
+ * Keywords k( sat::SolvAttr::keywords );
+ * dumpRange( MIL << "All Keywords: ", k.begin(), k.end() ) << endl;
+ * \endcode
+ *
+ * \todo Maybe add some way to unify the result.
+ */
+ template<class _ResultT, class _AttrT>
+ class ArrayAttr
+ {
+ friend std::ostream & operator<< <_ResultT,_AttrT>( std::ostream & str,
const ArrayAttr<_ResultT,_AttrT> & obj );
+
+ public:
+ ArrayAttr()
+ {}
+
+ ArrayAttr( SolvAttr attr_r )
+ : _q( attr_r )
+ {}
+
+ ArrayAttr( SolvAttr attr_r, Repository repo_r )
+ : _q( attr_r, repo_r )
+ {}
+
+ ArrayAttr( SolvAttr attr_r, Solvable solv_r )
+ : _q( attr_r, solv_r )
+ {}
+
+ public:
+ typedef sat::LookupAttr::transformIterator<_ResultT,_AttrT> iterator;
+
+ iterator begin() const
+ { return iterator( _q.begin() ); }
+
+ iterator end() const
+ { return iterator( _q.end() ); }
+
+ bool empty() const
+ { return _q.empty(); }
+
+ public:
+
+ iterator find( const _ResultT & key_r ) const
+ {
+ for_( it, begin(), end() )
+ {
+ if ( *it == key_r )
+ return it;
+ }
+ return end();
+ }
+
+ private:
+ sat::LookupAttr _q;
+ };
+ ///////////////////////////////////////////////////////////////////
+
+ /** \relates LookupAttr::iterator Stream output. */
+ template<class _ResultT, class _AttrT>
+ inline std::ostream & operator<<( std::ostream & str, const
ArrayAttr<_ResultT,_AttrT> & obj )
+ { return dumpOn( str, obj._q ); }
+
+ /////////////////////////////////////////////////////////////////
+ } // namespace sat
+ ///////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_SAT_LOOKUPATTRTOOLS_H

--
To unsubscribe, e-mail: zypp-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: zypp-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages