mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 13:06:59 -04:00
26562e03e3
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@837 0fc631ac-6414-0410-93d0-97cfa31319b6
64 lines
2.1 KiB
C++
64 lines
2.1 KiB
C++
//+----------------------------------------------------------------------------+
|
|
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
|
|
//| Copyright: (C) 2001 - 2008 Twan van Laarhoven and "coppro" |
|
|
//| License: GNU General Public License 2 or later (see file COPYING) |
|
|
//+----------------------------------------------------------------------------+
|
|
|
|
#ifndef HEADER_UTIL_AGE
|
|
#define HEADER_UTIL_AGE
|
|
|
|
// ----------------------------------------------------------------------------- : Includes
|
|
|
|
#include <util/prec.hpp>
|
|
#include <util/dynamic_arg.hpp>
|
|
#include <util/atomic.hpp>
|
|
|
|
// ----------------------------------------------------------------------------- : Age
|
|
|
|
/// Represents the age of a value, higher values are newer
|
|
/** Age is counted using a global variable */
|
|
class Age {
|
|
public:
|
|
/// Construct a new age value
|
|
Age() {
|
|
update();
|
|
}
|
|
/// Create a special age
|
|
/** 0: dummy value, used for other purposes
|
|
* 1: before 'beginning of time', the age conceptually just before program start
|
|
* 2..: normal ages
|
|
*/
|
|
Age(AtomicIntEquiv age) : age(age) {}
|
|
|
|
/// Update the age to become the newest one
|
|
inline void update() {
|
|
age = ++new_age;
|
|
}
|
|
|
|
/// Compare two ages, smaller means earlier
|
|
inline bool operator < (Age a) const { return age < a.age; }
|
|
/// Compare two ages
|
|
inline bool operator == (Age a) const { return age == a.age; }
|
|
|
|
/// A number corresponding to the age
|
|
inline AtomicIntEquiv get() const { return age; }
|
|
|
|
private:
|
|
/// This age
|
|
AtomicIntEquiv age;
|
|
/// Global age counter, value of the last age created
|
|
static AtomicInt new_age;
|
|
};
|
|
|
|
|
|
/// Age the object currently being processed was last updated
|
|
/** NOTE:
|
|
* image generating functions have two modes
|
|
* if last_update_age > 0 they return whether the image is still up to date
|
|
* if last_update_age == 0 they generate the image
|
|
*/
|
|
DECLARE_DYNAMIC_ARG (AtomicIntEquiv, last_update_age);
|
|
|
|
// ----------------------------------------------------------------------------- : EOF
|
|
#endif
|