I've got a question about the Architecture of SingletonHolder...
Is there a real good reason that the constuctor is private and not protected ???
I ask that because i prefere declaring my singleton with inheritance like that :
class TestClass : public Loki::SingletonHolder<TestClass>
for me it's really better... but the only probleme is with that method
the constructor of TestClass must access the constructor of SingletonHolder.
So why, in that case, is that constructor private ?
And would it be a good idea to put it protected and if not, why ???
If yes we could use some Macro to put some needed code (like friend class and an Instance method that access the SingletonHolder<TestClass>::Instance()
and if someone would want to use the method with the typedef, it'll work too... (like that everyone would be happy to use Loki::Singleton)
Sorry for my poor english... it's late...
Thanks for answering me
ps.:Also... is there another way to do what i want to do... wihtout having an useless class. (TestClass comes useless for me when i need to use a typedef....)
Why can't you use the typedef?
The constructor is private to forbid the creation of a new instance, which
would be possible by inheritance if we make the constructor protected.
I hadn't thought about the fact that if 2 classes inherit from the same SingletonHolder<BASECLASS> there would be 2 call to that constructor...
(if i understand well).
But my another problem (maybe i haven't well understood how to use Loki) is that my class definition MUST HAVE is constructor public....
unless the Creating Policy would be his friend.
And for me, there is a probleme if i let one class with a public constructor : Someone could use it without using the typedef singleton
and breaking the architecture.. no ?
My first need is that NO ONE can use the class without calling the singletonholder interface !!
(but maybe i'm missing something)