libzypp 17.37.10

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

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

`#include <zypp/base/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.
| SetTracker (set_type initial_r)
| Ctor taking an initial set.
Tracking API
bool | setInitial ()
| (Re-)Start tracking the current set (discards previously tracked changes).
bool | setInitial (set_type new_r)
| Start tracking a new set (discards previously tracked changes).
bool | set (set_type new_r)
| Set a new_r set and track changes.
bool | add (const value_type &val_r)
| Add an element to the set and track changes.
bool | remove (const value_type &val_r)
| Remove an element from the set and track changes.
Query and retrieval
bool | contains (const key_type &key_r) const
| Whether val_r is in the set.
bool | wasAdded (const key_type &key_r) const
| Whether val_r is tracked as added.
bool | wasRemoved (const key_type &key_r) const
| Whether val_r is tracked as removed.
const set_type & | current () const
| Return the current set.
const set_type & | added () const
| Return the set of added items.
const set_type & | removed () const
| Return the set of removed items.

## Related Symbols
(Note that these are not member symbols.)
template<class TSet>
std::ostream & | operator<< (std::ostream &str, const SetTracker< TSet > &obj)
| Stream output.

## Direct manipulation
set_type | _current
set_type | _added
set_type | _removed
set_type & | current ()
| Return the current set.
set_type & | added ()
| Return the set of added items.
set_type & | removed ()
| Return the set of removed items.
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)

## 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>

bool zypp::base::SetTracker< TSet >::find | ( | const set_type & | set_r,
|  | const key_type & | key_r )
| inline static private

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>

void zypp::base::SetTracker< TSet >::setDifference | ( | const TORDERED_SET & | lhs,
|  | const TORDERED_SET & | rhs,
|  | TORDERED_SET & | result_r )
| inline static private

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>

void zypp::base::SetTracker< TSet >::setDifference | ( | const TUNORDERED_SET & | lhs,
|  | const TUNORDERED_SET & | rhs,
|  | TUNORDERED_SET & | result_r )
| inline static private

Definition at line 175 of file SetTracker.h.

## Friends And Related Symbol 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:

- zypp/base/SetTracker.h