libzypp 17.31.23
zypp::SerialNumberWatcher Class Reference

Simple serial number watcher. More...

#include <base/SerialNumber.h>

Public Member Functions

 SerialNumberWatcher (unsigned serial_r=(unsigned) -1)
 Ctor taking an initial serial value.
 
 SerialNumberWatcher (const SerialNumber &serial_r)
 Ctor taking an initial serial value.
 
virtual ~SerialNumberWatcher ()
 Dtor.
 
bool isDirty (unsigned serial_r) const
 Return whether serial_r differs.
 
bool isDirty (const SerialNumber &serial_r) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
bool isClean (unsigned serial_r) const
 Return whether serial_r is still unchanged.
 
bool isClean (const SerialNumber &serial_r) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
bool remember (unsigned serial_r) const
 Return isDirty, storing serial_r as new value.
 
bool remember (const SerialNumber &serial_r) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 

Private Attributes

unsigned _serial
 

Friends

std::ostream & operator<< (std::ostream &str, const SerialNumberWatcher &obj)
 

Related Functions

(Note that these are not member functions.)

std::ostream & operator<< (std::ostream &str, const SerialNumberWatcher &obj)
 Stream output.
 

Detailed Description

Simple serial number watcher.

SerialNumberWatcher remembers a serial number and tells whenever new numbers you feed change.

All methods are overloaded to take an \unsigned or a const SerialNumber & as argument.

void check()
{
static SerialNumberWatcher watcher( sno );
if ( watcher.remember( sno ) )
{
cout << "Serial number changed." << endl;
}
}
int main()
{
check(); // This call would trigger, if check used a
// default constructed SerialNumberWatcher.
check(); //
sno.dirty();
check(); // "Serial number changed."
check(); //
sno.dirty();
check(); // "Serial number changed."
Simple serial number watcher.
Definition: SerialNumber.h:123
Simple serial number provider.
Definition: SerialNumber.h:45
bool dirty() const
Definition: SerialNumber.h:59

Definition at line 122 of file SerialNumber.h.

Constructor & Destructor Documentation

◆ SerialNumberWatcher() [1/2]

zypp::SerialNumberWatcher::SerialNumberWatcher ( unsigned  serial_r = (unsigned)-1)

Ctor taking an initial serial value.

A default constructed SerialNumberWatcher remembers the serial number (unsigned)-1. So it is most likely the the 1st call to remember returns isDirty.

Vice versa, initializing the SerialNumberWatcher with the current SerialNumber, most likely prevents the 1st to remember to return isDirty.

Definition at line 68 of file SerialNumber.cc.

◆ SerialNumberWatcher() [2/2]

zypp::SerialNumberWatcher::SerialNumberWatcher ( const SerialNumber serial_r)

Ctor taking an initial serial value.

Definition at line 77 of file SerialNumber.cc.

◆ ~SerialNumberWatcher()

zypp::SerialNumberWatcher::~SerialNumberWatcher ( )
virtual

Dtor.

Definition at line 86 of file SerialNumber.cc.

Member Function Documentation

◆ isDirty() [1/2]

bool zypp::SerialNumberWatcher::isDirty ( unsigned  serial_r) const
inline

Return whether serial_r differs.

Definition at line 145 of file SerialNumber.h.

◆ isDirty() [2/2]

bool zypp::SerialNumberWatcher::isDirty ( const SerialNumber serial_r) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 148 of file SerialNumber.h.

◆ isClean() [1/2]

bool zypp::SerialNumberWatcher::isClean ( unsigned  serial_r) const
inline

Return whether serial_r is still unchanged.

Definition at line 152 of file SerialNumber.h.

◆ isClean() [2/2]

bool zypp::SerialNumberWatcher::isClean ( const SerialNumber serial_r) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 155 of file SerialNumber.h.

◆ remember() [1/2]

bool zypp::SerialNumberWatcher::remember ( unsigned  serial_r) const
inline

Return isDirty, storing serial_r as new value.

Definition at line 160 of file SerialNumber.h.

◆ remember() [2/2]

bool zypp::SerialNumberWatcher::remember ( const SerialNumber serial_r) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 170 of file SerialNumber.h.

Friends And Related Function Documentation

◆ operator<< [1/2]

std::ostream & operator<< ( std::ostream &  str,
const SerialNumberWatcher obj 
)
friend

Definition at line 94 of file SerialNumber.cc.

◆ operator<<() [2/2]

std::ostream & operator<< ( std::ostream &  str,
const SerialNumberWatcher obj 
)
related

Stream output.

Definition at line 94 of file SerialNumber.cc.

Member Data Documentation

◆ _serial

unsigned zypp::SerialNumberWatcher::_serial
mutableprivate

Definition at line 174 of file SerialNumber.h.


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