Hi all, i have a macro that i use to speed up the implementation of Factory classes.
For example, to build a Factory for a CameraGenerator i use the macro this way:
1 2 3
|
GENERATOR_BUILD_FACTORY_START(CameraGenerator)
... do some stuff ...
GENERATOR_BUILD_FACTORY_END(CameraGenerator)
|
This build AND ALSO INSTANTIATE a class named CameraGeneratorFactory. All this is done into the .cpp file, not in the .h, so that the particural instance of the Factory become a global variable but the particular factory definition is not available outside of this file. All factories inherits from a base Factory class.
The problem comes when in another .cpp i need to define and instantiate another particular Factory, say FileGeneratorFactory, so i do
1 2 3
|
GENERATOR_BUILD_FACTORY_START(FileGenerator)
... do some other stuff ...
GENERATOR_BUILD_FACTORY_END(FileGenerator)
|
when compiled in DEBUG, the second use of this macro executes again the "CameraGenerator" Factory constructor, not the correct "FileGenerator" Factory one, like if once the macro had been preprocessed, compiled and linked into the first .cpp, it is always executed with the same argument. I repeat,
the issue is only when compiled in debug mode.
Does anyone know something about this behaviour?
thanks in previous