Casting pointers

Henning Hasemann hhasemann at web.de
Sat Jul 7 09:24:31 PDT 2007


> So you've managed to sidestep the whole point, in a way. Although I'm
> not really sure what the point was, and why one would need a pointer
> to an interface.

Well the point is a lengthy, boring story (at least *why* I wanted it
like this) but I already found a nice and clean way to do it without,
so no problem.

FYI the construct was something like this (note that I'm too lazy to
work out the correct casting again, I'll just show the basic idea):

class MainLoop {
  IRenderable*[] renderables;
  // render the renderables in a method
}

class UserInterface : IRenderable {
}

class Scene : IRenderable {
}

UserInterface globalUserInterface;
Scene currentScene;

MainLoop mainLoop;
mainLoop.renderables ~= &globalUserInterface;
mainLoop.renderables ~= &currentScene;

// some time later:
currentScene = someOtherScene;
// and/or:
globalUserInterface = specialUserInterfaceForMiniGame;
 

MainLoop was not able to import the userInterface and Scene modules so
it had no direct access to these variables. But I could break some
import cycles so that is no problem anymore and mainLoop now directly
refers to them (so not even the interface would not be necessary for
that part)

Henning

-- 
GPG Public Key:
http://keyserver.ganneff.de:11371/pks/lookup?op=get&search=0xDDD6D36D41911851
Fingerprint: 344F 4072 F038 BB9E B35D  E6AB DDD6 D36D 4191 1851



More information about the Digitalmars-d mailing list