Use libsolv includes and adjust documentation
[platform/upstream/libzypp.git] / zypp / sat / Queue.h
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file       zypp/sat/Queue.h
10  */
11 #ifndef ZYPP_SAT_QUEUE_H
12 #define ZYPP_SAT_QUEUE_H
13
14 extern "C"
15 {
16   struct _Queue;
17 }
18 #include <iosfwd>
19
20 #include "zypp/base/NonCopyable.h"
21 #include "zypp/sat/detail/PoolMember.h"
22
23 ///////////////////////////////////////////////////////////////////
24 namespace zypp
25 { /////////////////////////////////////////////////////////////////
26   ///////////////////////////////////////////////////////////////////
27   namespace sat
28   { /////////////////////////////////////////////////////////////////
29
30     /** Libsolv Id queue wrapper.
31      */
32     class Queue : private base::NonCopyable
33     {
34       public:
35         typedef unsigned size_type;
36         typedef detail::IdType value_type;
37         typedef const value_type* const_iterator;
38
39       public:
40         /** Default ctor: empty Queue. */
41         Queue();
42
43         /** Dtor */
44         ~Queue();
45
46         bool empty() const;
47         size_type size() const;
48         const_iterator begin() const;
49         const_iterator end() const;
50
51         /** Return iterator to the 1st occurance of \a val_r or \ref end. */
52         const_iterator find( value_type val_r ) const;
53
54         /** Return whether the Queue contais at lest one element with value \a val_r. */
55         bool contains( value_type val_r ) const
56         { return( find( val_r ) != end() ); }
57
58         /** Return the 1st Id in the queue or \c 0 if empty. */
59         value_type first() const;
60
61         /** Return the last Id in the queue or \c 0 if empty. */
62         value_type last() const;
63
64         /** Clear the queue. */
65         void clear();
66
67         /** Remove all occurances of \a val_r from the queue. */
68         void remove( value_type val_r );
69
70         /** Push a value to the end off the Queue. */
71         void push( value_type val_r );
72         /** \overload */
73         void push_back( value_type val_r )
74         { push( val_r ); }
75
76         /** Pop and return the last Id from the queue or \c 0 if empty. */
77         value_type pop();
78         /** \overload */
79         value_type pop_back()
80         { return pop(); }
81
82         /** Push a value to the beginning off the Queue. */
83         void push_front( value_type val_r );
84
85         /** Pop and return the 1st Id from the queue or \c 0 if empty. */
86         value_type pop_front();
87
88      public:
89         /** Backdoor */
90         operator struct ::_Queue *()
91         { return _pimpl; }
92         /** Backdoor */
93         operator const struct ::_Queue *() const
94         { return _pimpl; }
95
96       private:
97         /** Pointer to implementation */
98         struct ::_Queue * _pimpl;
99     };
100
101     /** \relates Queue Stream output */
102     std::ostream & operator<<( std::ostream & str, const Queue & obj );
103
104     /** \relates Queue Verbose stream output */
105     std::ostream & dumpOn( std::ostream & str, const Queue & obj );
106
107     /////////////////////////////////////////////////////////////////
108   } // namespace sat
109   ///////////////////////////////////////////////////////////////////
110   /////////////////////////////////////////////////////////////////
111 } // namespace zypp
112 ///////////////////////////////////////////////////////////////////
113 #endif // ZYPP_SAT_QUEUE_H