libzypp  17.14.0
zypp::base::SetTracker< TSet > Class Template Reference

Track added/removed set items based on an initial set. More...

#include <SetTracker.h>

Public Types

typedef TSet set_type
 
typedef TSet::key_type key_type
 
typedef TSet::value_type value_type
 

Public Member Functions

 SetTracker ()
 Default Ctor: empty set. More...
 
 SetTracker (set_type initial_r)
 Ctor taking an initial set. More...
 
Tracking API
bool setInitial ()
 (Re-)Start tracking the current set (discards previously tracked changes). More...
 
bool setInitial (set_type new_r)
 Start tracking a new set (discards previously tracked changes). More...
 
bool set (set_type new_r)
 Set a new_r set and track changes. More...
 
bool add (const value_type &val_r)
 Add an element to the set and track changes. More...
 
bool remove (const value_type &val_r)
 Remove an element from the set and track changes. More...
 
Query and retrieval
bool contains (const key_type &key_r) const
 Whether val_r is in the set. More...
 
bool wasAdded (const key_type &key_r) const
 Whether val_r is tracked as added. More...
 
bool wasRemoved (const key_type &key_r) const
 Whether val_r is tracked as removed. More...
 
const set_typecurrent () const
 Return the current set. More...
 
const set_typeadded () const
 Return the set of added items. More...
 
const set_typeremoved () const
 Return the set of removed items. More...
 
Direct manipulation
set_typecurrent ()
 Return the current set. More...
 
set_typeadded ()
 Return the set of added items. More...
 
set_typeremoved ()
 Return the set of removed items. More...
 

Static Private Member Functions

static bool find (const set_type &set_r, const key_type &key_r)
 
template<class TORDERED_SET , typename enable_if = typename TORDERED_SET::key_compare>
static void setDifference (const TORDERED_SET &lhs, const TORDERED_SET &rhs, TORDERED_SET &result_r)
 
template<class TUNORDERED_SET , typename enable_if = typename TUNORDERED_SET::hasher, typename = void>
static void setDifference (const TUNORDERED_SET &lhs, const TUNORDERED_SET &rhs, TUNORDERED_SET &result_r)
 

Private Attributes

set_type _current
 
set_type _added
 
set_type _removed
 

Related Functions

(Note that these are not member functions.)

template<class TSet >
std::ostream & operator<< (std::ostream &str, const SetTracker< TSet > &obj)
 

Detailed Description

template<class TSet>
class zypp::base::SetTracker< TSet >

Track added/removed set items based on an initial set.

The class maintains the current set of items and also records the changes compared to the initial set (added and removed items) if you use the tracking API.

It is also possible to directly manipulate the three sets.

Note
The tracking API expects the template arg to have set semantic.

Definition at line 37 of file SetTracker.h.

Member Typedef Documentation

◆ set_type

template<class TSet>
typedef TSet zypp::base::SetTracker< TSet >::set_type

Definition at line 39 of file SetTracker.h.

◆ key_type

template<class TSet>
typedef TSet::key_type zypp::base::SetTracker< TSet >::key_type

Definition at line 40 of file SetTracker.h.

◆ value_type

template<class TSet>
typedef TSet::value_type zypp::base::SetTracker< TSet >::value_type

Definition at line 41 of file SetTracker.h.

Constructor & Destructor Documentation

◆ SetTracker() [1/2]

template<class TSet>
zypp::base::SetTracker< TSet >::SetTracker ( )
inline

Default Ctor: empty set.

Definition at line 44 of file SetTracker.h.

◆ SetTracker() [2/2]

template<class TSet>
zypp::base::SetTracker< TSet >::SetTracker ( set_type  initial_r)
inline

Ctor taking an initial set.

Definition at line 48 of file SetTracker.h.

Member Function Documentation

◆ setInitial() [1/2]

template<class TSet>
bool zypp::base::SetTracker< TSet >::setInitial ( )
inline

(Re-)Start tracking the current set (discards previously tracked changes).

Returns
False (set did not change)

Definition at line 57 of file SetTracker.h.

◆ setInitial() [2/2]

template<class TSet>
bool zypp::base::SetTracker< TSet >::setInitial ( set_type  new_r)
inline

Start tracking a new set (discards previously tracked changes).

Returns
Whether the set did change (new!=current)

Definition at line 63 of file SetTracker.h.

◆ set()

template<class TSet>
bool zypp::base::SetTracker< TSet >::set ( set_type  new_r)
inline

Set a new_r set and track changes.

Returns
Whether the set has changed

Definition at line 78 of file SetTracker.h.

◆ add()

template<class TSet>
bool zypp::base::SetTracker< TSet >::add ( const value_type val_r)
inline

Add an element to the set and track changes.

Returns
Whether the set has changed

Definition at line 100 of file SetTracker.h.

◆ remove()

template<class TSet>
bool zypp::base::SetTracker< TSet >::remove ( const value_type val_r)
inline

Remove an element from the set and track changes.

Returns
Whether the set has changed

Definition at line 114 of file SetTracker.h.

◆ contains()

template<class TSet>
bool zypp::base::SetTracker< TSet >::contains ( const key_type key_r) const
inline

Whether val_r is in the set.

Definition at line 129 of file SetTracker.h.

◆ wasAdded()

template<class TSet>
bool zypp::base::SetTracker< TSet >::wasAdded ( const key_type key_r) const
inline

Whether val_r is tracked as added.

Definition at line 132 of file SetTracker.h.

◆ wasRemoved()

template<class TSet>
bool zypp::base::SetTracker< TSet >::wasRemoved ( const key_type key_r) const
inline

Whether val_r is tracked as removed.

Definition at line 135 of file SetTracker.h.

◆ current() [1/2]

template<class TSet>
const set_type& zypp::base::SetTracker< TSet >::current ( ) const
inline

Return the current set.

Definition at line 139 of file SetTracker.h.

◆ added() [1/2]

template<class TSet>
const set_type& zypp::base::SetTracker< TSet >::added ( ) const
inline

Return the set of added items.

Definition at line 142 of file SetTracker.h.

◆ removed() [1/2]

template<class TSet>
const set_type& zypp::base::SetTracker< TSet >::removed ( ) const
inline

Return the set of removed items.

Definition at line 145 of file SetTracker.h.

◆ current() [2/2]

template<class TSet>
set_type& zypp::base::SetTracker< TSet >::current ( )
inline

Return the current set.

Definition at line 151 of file SetTracker.h.

◆ added() [2/2]

template<class TSet>
set_type& zypp::base::SetTracker< TSet >::added ( )
inline

Return the set of added items.

Definition at line 154 of file SetTracker.h.

◆ removed() [2/2]

template<class TSet>
set_type& zypp::base::SetTracker< TSet >::removed ( )
inline

Return the set of removed items.

Definition at line 157 of file SetTracker.h.

◆ find()

template<class TSet>
static bool zypp::base::SetTracker< TSet >::find ( const set_type set_r,
const key_type key_r 
)
inlinestaticprivate

Definition at line 162 of file SetTracker.h.

◆ setDifference() [1/2]

template<class TSet>
template<class TORDERED_SET , typename enable_if = typename TORDERED_SET::key_compare>
static void zypp::base::SetTracker< TSet >::setDifference ( const TORDERED_SET &  lhs,
const TORDERED_SET &  rhs,
TORDERED_SET &  result_r 
)
inlinestaticprivate

Definition at line 166 of file SetTracker.h.

◆ setDifference() [2/2]

template<class TSet>
template<class TUNORDERED_SET , typename enable_if = typename TUNORDERED_SET::hasher, typename = void>
static void zypp::base::SetTracker< TSet >::setDifference ( const TUNORDERED_SET &  lhs,
const TUNORDERED_SET &  rhs,
TUNORDERED_SET &  result_r 
)
inlinestaticprivate

Definition at line 175 of file SetTracker.h.

Friends And Related Function Documentation

◆ operator<<()

template<class TSet >
std::ostream & operator<< ( std::ostream &  str,
const SetTracker< TSet > &  obj 
)
related

Stream output

Definition at line 190 of file SetTracker.h.

Member Data Documentation

◆ _current

template<class TSet>
set_type zypp::base::SetTracker< TSet >::_current
private

Definition at line 183 of file SetTracker.h.

◆ _added

template<class TSet>
set_type zypp::base::SetTracker< TSet >::_added
private

Definition at line 184 of file SetTracker.h.

◆ _removed

template<class TSet>
set_type zypp::base::SetTracker< TSet >::_removed
private

Definition at line 185 of file SetTracker.h.


The documentation for this class was generated from the following file: