
To provide a time stamp, which records (with the accuracy of 1 second) the time and date, when the object was created or modified.
In C++, the time stamp is not automatically initialized when creating a new object, unless you place macro ZZ_INIT() or call function setTime() in all constructors. For example:
class myObj { // first variantD int i,k; ZZ_EXT_myObj public: myObj(){this->setID();} myObj(int ii, int kk){this->setID("myObj",1); i=ii; k=kk;} }; ZZ_HYPER_TIME_STAMP(myObj);class myObj { // second variant, covers two initializations int i,k; ZZ_EXT_myObj public: myObj(){ZZ_INIT(myObj);} myObj(int ii, int kk){ZZ_INIT(myObj); i=ii; k=kk;} }; ZZ_HYPER_TIME_STAMP(myObj); ZZ_HYPER_SELF_ID(myObj);
TIME_STAMP is one of the special hard-wired organizations that can have only one instance on any given object. Though it is declared as
ZZ_HYPER_TIME_STAMP(objType);
it does not create a hyper object. Functions manipulating this organization are associated with the object itself, and not with a general id.
Internally, the stamp is packed into 4 bytes. For a convenient comparison of two time stamps, the special function cmpTime() is available.
getTime() returns the time stamp unpacked in 6 bytes, each representing one number (year, month, day, hour, minute, second).
Note that the time stamp is kept only on specified object types (those for which ZZ_HYPER_TIME_STAMP() have been declared).
| // TYPE is the type of the given object ZZ_HYPER_TIME_STAMP(TYPE); char ts[6]; void TYPE::setTime(void); |
sets the time stamp on the given object to the current time. |
| void TYPE::getTime(ts); | returns time stamp of the given object [YMDHMS] in ts. For example, June 18, 1989 17:30:11 is represented as [89 6 18 17 30 11]. |
| int TYPE::cmpTime(TYPE *obj2); | compares two objects and returns int i<0 when obj1 is older, i=0 when both objects have the same age, i>0 when obj2 is older. Example of use: i=obj1->cmpTime(obj2). |
You don't have to worry about the year 2000 and up. The time stamp can be set only to the current date.
Examples:
| Next Section 11.12 Dynamic Array and Binary
Heap |