QxFaxtoryX parameters

Forum for posting problems using QxOrm library

QxFaxtoryX parameters

Postby caseybasichis » Sat Mar 10, 2012 2:36 am

Hi,

So boost is still compiling, I've been going over all the tutorials and the doxygen bit. It seems QxFactoryX may be a way to implment and dependency injection approach I was considering. I am new to this and I am not sure if I am on the wrong track.

I have to make a dependency injection chain that is swapped out with a completely different chain every few seconds.

Code: Select all
0001(0002,0003)
0003(0004,0005)

ID      Class       Parent  Param#
0005    Thimbal     0003    2
0004    Needle      0003    1
0003    SewingKit   0001    2
0002    Soap        0001    1
0001    SuitCase    root    0


I'm trying to create a setup where I could create 0001 and have it automatically create 0002-0005 as in the above example.

I would probably have an A/B buffer for each object graph so that the second can be built while the first is still active, and then destory the first when the second graph is in use.

Is this approach sensible? I need all of my objects and parameters stored in a database so that I can quickly access any data from any of the graphs. I was going to try and manually create a factory to do this using a factory pattern tutorial, but it looks like QxFactoryX is more or less already doing that.

When the boost build finishes compiling I'm going to test all of the examples to make sure everything is working. The tutorials really helped open the scope of what this can do.

Thanks,
Casey
caseybasichis
 

Re: QxFaxtoryX parameters

Postby QxOrm admin » Sat Mar 10, 2012 9:45 am

qx::QxFactoryX class is a part of introspection engine of QxOrm library and a kind of implementation of factory pattern.
Each class registered into QxOrm context can be instantiate using its name (and without knowing its C++ type) :
Code: Select all
boost::shared_ptr<T> ptr = qx::create("my_class");


If you decide to have a base class (for example QObject) for all your classes registered into QxOrm context, you can write something like this :
Code: Select all
boost::shared_ptr<QObject> ptr = qx::create("my_class");


The factory pattern is done automatically using QxOrm library, you don't have to write anything else to use it.
QxOrm admin
 


Return to QxOrm - Help

Who is online

Users browsing this forum: No registered users and 5 guests

cron