Re: NewEra: Using class library functions
Posted in 1996
Keith Morrell <keithm@wave.co.nz> wrote: >Is there a definitive guide to how to use the class libraries >within NewEra? > >eg if I want to use the "before row" function in a supertable >(in this case using uHdrSuperTable/AFCL), how should I know that >I have to add a call to doBeforeRow to preserve the navigation >logic in the supertable (this mentioned under uNavSuperTable)? > >What would be useful is some information about what functions >can be used directly, or if not, what bits need to be called to >preserve any system functions. > >Anyone else out there come across this issue? You will come across this issue anytime you'll want to add functionality to (or customize) an existing class. There are two ways you can accomplish this: 1. Override a member function in a sub-class. 2. Handle a particular event. To override a member function is straight-forward, and to handle a particular event is the easiest thing for the "last" user of the class, but what happens when you are not the "last" user of the class? Let's say you handle event E of class C using the handler H. If a user of your class A wants to handle the event E but still preserve the execution of code in handler H, he/she would have to write code similar to: handle object.E with C.myHandler ... handler C::myHandler() ... handle E with C.H call E() handle E with C.myHandler ... end handler The above code will effectively chain a handler to another. As a user of the class C, you must remember to always add the "chain" lines to your handler. While an OK/working solution, it is not at all generic. One way to simplify the above and to make it generic, is to create a (new) member function C::doE() which performs the work of the handler H. The handler H just has to call doE(). The caveat is the the user must remember to call doE() in their own handler; however, this is a standard that you can easily remember. This method helps in sub-sub-classes as their just override the doE() function. Most of the AFCL works as described. All of this comes from the fact that while events can be dynamically bound at run-time, they cannot be "overridden" and handlers cannot be invoked (call/post) directly (you must call/post the event that is handled by the handler). HTH, Catalin ======================================= http://www.tecsys.com ========= Catalin Badea _/_/_/ _/_/_/ _/_/_/ _/_/_/ _/ _/ _/_/_/ _/ _/ _/ _/ _/_/ _/ Senior Technical Architect _/ _/_/ _/ _/_/_/ _/ _/_/_/ _/ _/ _/ _/ _/ _/ Tecsys Inc. _/ _/_/_/ _/_/_/ _/_/_/ _/ _/_/_/ ===== cat@tecsys.com =========== include system "disclaimer.4gh" =====