Centralizable configured compile-time class instantiation
Kagamin
spam at here.lot
Tue Jul 12 08:33:31 PDT 2011
shd Wrote:
> Actually, project structure looks like that:
> * project/
> * bin/
> * work/
> * docs/
> * iface/
> * ae
> * ge
> * pe
> (...)
> * impl/
> * glfw
> * ge.window
> * io.hid.keyboard
> * io.hid.mouse
> (you can add other window toolkits, or just separate OpenGL
> context creation code and user-input handling from different
> libraries)
> * h3d
> * ge.renderer
> (...)
> (you can add any other renderers or parts of game engines if
> they let you to do that)
> * project_name
> * <package.interfaces implemented by me>
> * pe
> * bullet
> * ode
> * newton
> (code is opensource and publicly accessible but excuse me i don't
> quote anything because it's currently ugly and unprofessional so i'm
> not proud of it yet, although i figured it out it's best way to do my
> way, it just needs time and work to be proud)
>
> So, i could easily change libraries, someone might use parts of my
> code by implementing bounding interfaces and as side effect i could
> easily benchmark how different implementations act in my project (like
> with C++ PAL).
>
> So, if i'll handle task of abstracting all this out, and get
> reasonable performance that's the other topic, but i believe it's
> worth a try. All i need is to have a tool that lets me choose
> implementation at compile time without interface file modification.
> Any clues?
You want an IOC container like Unity?
And you want the interface-to-class mapping to be configurable externally rather than version out these classes directly in source?
like
version(UseGL)
{
static import wrappers.gl;
alias wrappers.gl.WindowImpl Window;
}
else version(UseWhat)
{
static import wrappers.what;
alias wrappers.what.WindowImpl Window;
}
container.register!(IWindow,Window)();
client:
IWindow myWindow=container.resolve!(IWindow)();
More information about the Digitalmars-d-learn
mailing list