How to know when attribute processing is done, even with no attributes specified

Apr 18, 2012 at 2:01pm

How to know when attribute processing is done, even with no attributes specified

Hi all,

In the C API there is the attr_args_process function that I call to process the attributes entered in an object box. In Java this happens automatically, from what I can see sometime after the constructor of the object has completed.

I would however like to know when the processing of attributes is complete, so that I can take action if an attribute has -not- been specified. Is there a function that can notify me when this has been done?

Many thanks,
Mattijs

#63059
Apr 18, 2012 at 8:35pm

Off the top of my head, I would be inclined to initialize _all_ values at the beginning of the new() method (before attribute processing happens), then let the attribute processing handle any overrides specified by @attribute parameters in the object initialization.

Yeah, so some attibutes may be set up twice (first to the default and then by the user override with an @attribute). Are you in that much of a hurry to worry about it?-)

Or am I missing something?

#227537
Apr 19, 2012 at 9:55am

Hi Peter!

Thanks for your reply. In this case initializing the attributes twice is exactly what I want to try to prevent. I’m working on my networking objects and depending on the attribute a server socket is initialized. Preferably I wouldn’t do that twice.

Btw I found a workaround for now: setting a Qelem at the end of the constructor to call my init method. It looks like the attribute setting has been done once the queue reaches it.

Best,
Mattijs

#227538
Apr 19, 2012 at 8:43pm

Hi Mattijs,

there is another way- probably more reliable:

declare the attribute with a custom getter and setter methods. When the object is instantiated the setter will be called with the right right attribute value.

Jan

#227539
Apr 20, 2012 at 9:02am

Hi Jan,

Thanks for your reply, although I think you misunderstood the problem; I do have custom getters and setters, but I need to know when they are called during the initialization sequence..

Thanks,
Mattijs

#227540

You must be logged in to reply to this topic.