libzypp  13.10.6
zypp::SerialNumberWatcher Class Reference

Simple serial number watcher. More...

#include <SerialNumber.h>

Public Member Functions

 SerialNumberWatcher (unsigned serial_r=(unsigned)-1)
 Ctor taking an initial serial value. More...
 
 SerialNumberWatcher (const SerialNumber &serial_r)
 Ctor taking an initial serial value. More...
 
virtual ~SerialNumberWatcher ()
 Dtor. More...
 
bool isDirty (unsigned serial_r) const
 Return whether serial_r differs. More...
 
bool isDirty (const SerialNumber &serial_r) const
 
bool isClean (unsigned serial_r) const
 Return whether serial_r is still unchanged. More...
 
bool isClean (const SerialNumber &serial_r) const
 
bool remember (unsigned serial_r) const
 Return isDirty, storing serial_r as new value. More...
 
bool remember (const SerialNumber &serial_r) const
 

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)
 

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 or a const SerialNumber & as argument.

* SerialNumber sno;
*
* 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."
*

Definition at line 122 of file SerialNumber.h.

Constructor & Destructor Documentation

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.

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

Ctor taking an initial serial value.

Definition at line 77 of file SerialNumber.cc.

zypp::SerialNumberWatcher::~SerialNumberWatcher ( )
virtual

Dtor.

Definition at line 86 of file SerialNumber.cc.

Member Function Documentation

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

Return whether serial_r differs.

Definition at line 145 of file SerialNumber.h.

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.

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

Return whether serial_r is still unchanged.

Definition at line 152 of file SerialNumber.h.

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.

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.

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

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

Definition at line 94 of file SerialNumber.cc.

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

Stream output

Definition at line 94 of file SerialNumber.cc.

Member Data Documentation

unsigned zypp::SerialNumberWatcher::_serial
mutableprivate

Definition at line 174 of file SerialNumber.h.


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