Page object: deprecated _GetClass() call still needed?

10 posts / 0 new
Last post
whose
whose's picture
Offline
Last seen: 4 years 10 months ago
Joined: 2011-08-09 02:25
Page object: deprecated _GetClass() call still needed?
Topic says most: I tried to use the page gadget and it seems to be a bit troublesome, using the recommended way of opening ReAction classes. There is no documentation about how to use it using a class pointer like it is recommended now (using the OpenClass() call, which is so far for disk based classes only!). Did I miss something, or is it to be used by GetClass()ing the class pointer until further notice?
thomas
thomas's picture
Offline
Last seen: 3 weeks 3 days ago
Joined: 2011-05-16 14:23
Wherever you formerly used
Wherever you formerly used NewObject(xy_GetClass(),NULL,...,TAG_END) you now use NewObject(xyClassPtr,NULL,...,TAG_END); Are there other places where xy_GetClass() was used? If yes, just replace them all by the class pointer. If you used reaction/reactionmacros.h before, either don't use it any more or make your own reactionmacros.h which uses class pointers instead of GetClass calls.
salass00
salass00's picture
Offline
Last seen: 2 months 2 days ago
Joined: 2011-02-03 11:27
@whose As you may have noted
@whose As you may have noted the layout.gadget exports two classes (layout.gadget and page.gadget). Using IIntuition->OpenClass() you will only be able to obtain access to the layout.gadget class. If you need access to page gadget I suggest you simply obtain the "main" interface using IExec->GetInterface() and call the ILayout->PAGE_GetClass() at the beginning of your program storing the result in a variable called PageClass instead of calling it for each and every page.gadget object you create. If you're going to be using page.gadget in your program then you probably need access to the "main" interface anyway for ILayout->SetPageGadgetAttrs() so it won't be much extra work.
whose
whose's picture
Offline
Last seen: 4 years 10 months ago
Joined: 2011-08-09 02:25
@thomas: Hehe, no, no, this
@thomas: Hehe, no, no, this was a misunderstanding, I suppose :-) I already used the OpenClass() way of obtaining class pointers. But this doesnt work for page.gadget, which is part of layout.gadget. OpenClass() opens disc based classes only, so if theres no SYS:Classes/gadgets/page.gadget (which is the case actually), one wont get a class pointer to use with NewObject(). This was the initial problem, and it seems that I have to use the "good olĀ“ ways" of using the page.gadget library base and interface to obtain the class pointer using _GetClass(), as salass00 mentioned. @salass Thanks for the clarification :-)
Coder Insane-Software www.insane-software.de
salass00
salass00's picture
Offline
Last seen: 2 months 2 days ago
Joined: 2011-02-03 11:27
@whose There is also the
@whose There is also the method of using the public class ID but it has more overhead since intuition has to do a string search of all the public classes in the system so I wouldn't recommend it:
  1. IIntuition->NewObject(NULL, "page.gadget", ..., TAG_END)
whose
whose's picture
Offline
Last seen: 4 years 10 months ago
Joined: 2011-08-09 02:25
Yeah, its mentioned in the
Yeah, its mentioned in the layout.gadget autodocs that the dev should use the public class ID in order to get access to page.gadget. I never liked it for the same reason, too much overhead because of the class list traversal. I prefer the way you suggested, using PAGE_GetClass() and caching the class pointer. A bit more work in the beginning, but much better if someone has to use lots of pages in a clicktab layout (but I dont have to, just 4 pages for my layout). I wondered because the recommended way to obtain class pointers actually doesnt work for page.gadget, thats all. It would have been possible that I have missed something in the autodocs regarding the class pointer of page.gadget. Some "special" info is often buried in the depths of the SDK. Deep enough to miss it. But obviously I didnt ;-) Edit: bad spelling...
Coder Insane-Software www.insane-software.de
thomas
thomas's picture
Offline
Last seen: 3 weeks 3 days ago
Joined: 2011-05-16 14:23
Hehe, no, no, this was a
Hehe, no, no, this was a misunderstanding, I suppose :-)
Yes, I wasn't aware that page.gadget is a part of layout.gadget.
ssolie
ssolie's picture
Offline
Last seen: 8 years 11 months ago
Joined: 2011-02-03 06:55
Call OpenClass() on
Call OpenClass() on layout.gadget and then use the page.gadget class name string to create page.gadget objects using NewObject(). The technique is analogous to using the BOOPSI objects contained in intuition.library. Regarding performance, if it can be shown that string look ups are a system bottleneck we can introduce hashing and similar methods to speed that up.
whose
whose's picture
Offline
Last seen: 4 years 10 months ago
Joined: 2011-08-09 02:25
Hm, I dont think that string
Hm, I dont think that string lookup is a bottleneck, regarding the CPU power available. But its an ugly way, when all other GUI classes are openend the same way, except page.gadget. Just split page.gadget from layout.gadget and all things are fine. There is no reason to integrate page.gadget into layout.gadget. Make them dependend, thats it. The old standard PAGE_GetClass() way is much more consistent than using the public class name when doing a NewObject() call. There are very few programs out there, using the public name of a non-OS3.x GUI class. But its still ugly, when all other classes can be opened using OpenClass()...
Coder Insane-Software www.insane-software.de
salass00
salass00's picture
Offline
Last seen: 2 months 2 days ago
Joined: 2011-02-03 11:27
@ssolie The biggest problem
@ssolie The biggest problem IMO with using public IDs with disk-loaded classes is that your program will compile and may even appear to work even if it's completely broken because you forgot to call OpenLibrary() for all your needed classes because some other program may have already used them so that they are already loaded in memory.
Log in or register to post comments