From lechner@cs.uml.edu Tue Dec 7 03:21:13 2004 From: Bob Lechner Subject: $PH/COOL-LCP/pr_set_keyNotes041207.txt - RJL041207 To: 04f522 RJLRef: $PH/COOL-LCP/lcp04s/AISetStateNotes.txt AISetStateNotes041207.txt [Revised 050926: MLauzier showed in her 045522 project that pr_set_fkey could not be defined without a switch on table-type index, because this is the only way to generate the special cases that each table requires, due to its different fkey data members, one of which must be identified from a macro argument. This project was never completed. The current state STid field of each AI row remains a non-key field (c8, with is_key = 0). I cannot vouch for the same pr_set_key function in pr_accessors.c from 04f522 genv13 project. If this exists, it may have the same problem (failure to update the XXid_pp and XXid_fcp pointers when XXid is updated). For details, see $CASE/04s522/lcp04s/ajlopez/lcp/olc/AISetStateNotes.txt (revised 050926) ($PH/COOL-LCP/lcp04s hyperlinks to $CASE/04s522/lcp04s/.) ] --------------------------------------------- $PH/COOL-LCP/lcp04s/ $CASE/04s522/ajlopez/lcp/olc/AISetStateNotes.txt and $PH/COOL-LCP/pr_set_keyNotes041207.txt are identical notes on the differences between lcp/olc and lcp/pr_util forms of field updating. pr_util's pr_set_field does logging, and is more complex. olc's TableSetField does no logging, but it should. TableSetField is easier to generate and hence maintain. Olc's author August Reinig and chgen's authors Craig and Stephen Smith made different assumptions about how ASCII fields are stored in table rows. pr_set_keyNotes041207.txt also covers this subject. This note is suggested to become part of the 04f522 project to produce a valid pr_set_key macro. It suggests that a new function (with logging), called as AISetSTid(AIcurr, TRcurr->STid2) would be a valid alternative way to set a new fkey STid in table AI. Logging and pr_link/unlink actions still need to be added when fkeys are updated. The special case AISetSTid should be generated by updating Reinig's SETROUTINE macro. Later, every XXSetFieldname function can be generated from the .msdat metadata file, by looping over all of its tables and fields to pick up the required parameters. E.g.,new function AISetSTid can be generated by this macro call: GENSET(hcg_key,AI,STid,hcg_key); then called as AISetSTid(AIcurr, value). Currently this macro is defined in olc3common; here, I expanded the FUNCTION2(..) macro which is obsolete, and changed it so XXcurr is used not XXid: ----------------------------------- #define SETROUTINE(field_type, object_name, object_abbrev, field, value_type) \ void P(object_name,Set,field)(hcg_key P(object_abbrev,curr),value_type value) { \ pr_find(object_abbrev, P(object_abbrev,id), P(object_abbrev,id)); \ //pr_find checks XXcurr->XXid before searching for XXid - RJL041207\ if (P(object_abbrev,curr)!= 0) { \ P(object_abbrev,curr)->field = (field_type)value; \ else P(object_abbrev,curr)->field = (field_type)AINULL;//null value \ } ------------------------------------ The above definition should be modified and renamed GENSET. In GENSET, object-abbrev AI replaces object_name ActiveInstance, so the GENSET macro can eliminate object_name arg2 in SETROUTINE Invoking the new macro as GENSET(hcg_key, AI,STid,hcg_key); should expand to this new AISetSTid function : ------------------- void AISetSTid(hcg_key AIid, hcg_key value) { pr_find(AI, AIid, AIid); //checks AIcurr->AIid before searching if (AIcurr!= 0) { AIcurr->STid = (hcg_key)value; //TBD: add pr_unlink nd pr_link actions here else { AIcurr->STid = (hcg_key) AINULL; //customized? (e.g AI-row #0) //TBD: issue warning or error message here; } //TBD: Add logging output here (from pr_util's pr_set_key macro) } ---------------- With gencpp, either the AIcurr object pointer or an implicit argument 'this' can apply to class-based Set and Get methods. Perhaps these become two over-loaded varieties of AI::AISetSTid? -------------------------------------