[Libaps-general] Idea for attributes -- Comparing / Calculating difference
Brought to you by:
brianpirie,
tranter
From: Jeff B. <kl...@ma...> - 2000-04-28 21:09:13
|
From: "Jeff Brown" <jef...@co...> Subject: Idea for attributes -- Comparing / Calculating difference Date: Tuesday, March 07, 2000 1:35 am Hello, I was just thinking that it would be useful to be able to perform a few special operations on Job attributes to increase efficiency and perhaps improve functionality as well. Things of this nature could be useful for doing things like selective updating, or marking settings which differ from defaults in a UI, or assist in logging or debugging by indicating explicitely what has changed from one run to another. Brian: Since this is your baby, what do you think? [Loosly C-style pseudo-code] /* Compare a setting between attr1 and attr2 */ Aps_Result Aps_AttrCompare(Aps_JobAttrHandle attr1, Aps_JobAttrHandle attr2, const char *attributeID, int *equal) { if ((attr1 has attributeID) && (attr2 has attributeID)) { *equal = (attr1.attributeID == attr2.attributeID); return APS_SUCCESS; } else { *equal = FALSE; return APS_NOT_FOUND; } } /* Report settings in attr1 that are not in attr2 or different from those in attr2 */ /* ie. attr2 is reference copy and attr1 is local storage */ /* N.B. target not created if no diffs... */ Aps_Result Aps_AttrDiffAll(Aps_JobAttrHandle attr1, Aps_JobAttrHandle attr2, Apr_JobAttrHandle *target) { foreach(attributeID in attr1) { int equal; if (APS_NOT_FOUND == Aps_AttrCompare(attr1, attr2, attributeID, & equal) || (equal)) { if (! *target) *target = new Aps_JobAttrHandle; Aps_AttrSetSetting(*targer, attributeID, attr1); } } return APS_SUCCESS; } /* Update settings which differ from attr1 to attr2 into attr2 */ /* ie. attr2 is reference copy and attr1 is local storage */ Aps_Result Aps_AttrUpdateAll(Aps_JobAttrHandle attr1, Aps_JobAttrHandle attr2) { return Aps_AttrDiffAll(attr1, attr2, attr2); } /* Enumerate attributes through a callback */ Aps_Result Aps_AttrEnumerate(Aps_JobAttrHandle attr, int (*enumfunc)(Aps_JobAttrHandle, const char *attributeID)) { foreach(attributeID in attr) { if (enumfunc(attr, attributeID)) break; } return APS_SUCCESS; } |