Advertisement Jump to content
Sign in to follow this  

Iterate through objects in Context ?

This topic is 1422 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts



Is it possible to iterate through the objects created in a particular context via the c++ interface?  I would like to be able to do this, as on a script completion, I have the situation that some objects have not been destroyed. 


My specific situation is that i am writing a scripting layer onto our UI library.  This will allow creation of UI widgets and attaching them to the window's widget-tree.  However, in our UI lib, attaching them to the widget tree also retains them.  Therefore, they still exist when the script exits.  This is desired in some cases, but I would like in some cases to be able to detach any widgets created from the script on script exit (without the script-writer needing to care about it)


I couldnt see a way to do this in the docs, so I guess its not possible but thought id ask anyway (and at least make a feature request from it).


Also, a question about strings: So far I have registered strings as a value type, is it possible to register them as a object type?



Share this post

Link to post
Share on other sites
What GUI lib are you using? In fltk (the one I use) you can access child widgets directly from the parent. So maybe you could store a pointer to the parent widget of the hierarchy tree (the main window) in the app and after the script finishes you can just access any left over widget from there.

Share this post

Link to post
Share on other sites

There is no built-in way of knowing which context created which object. But you could make a way of keeping track of this by storing the active context when the factory behavior is called to create the object.


Object *Object_factory()
  Object *obj = new Object();
  // Keep track of which context created the object so it can later be found
  // (tracker is a fictional class, obviously)
  tracker.Insert(asGetActiveContext(), obj);
  return obj;


Yes, it is possible to register strings as reference types. Though you'll have to implement your own string class for this.


In my regression test suite I have one possible implementation:

Share this post

Link to post
Share on other sites

Thanks for the info.


Both solutions make sense and I had already considered them, i just wondered if there was a direct way to get the created objects from the context itself.


FYI following a redesign, it will be no longer be an issue anyway.  Instead of passing the window to the script, the app will now rather call a script function requesting the script to create a tree of widgets, which the app will then attach to the window.  Something like UI_Object @ OnCreateObject().  So the app now just needs to release that one object when no longer needed.


@ Tzarls: its a custom UI library.


Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!