Conditional compilation: managing set of modules
Login to reply to this topic.
Thu, 2004-08-26 08:52
Joined: 2003-10-15
Forum posts: 78
I need to develop an application with lots of version variations.
In fact it is not even an application, but rather a framwork to create other apps by selecting modules to use.

Hence, I need to be able to include/exclude modules to/from compilation. This is no big deal, I can use compiler #defines. However, I cannot find a way to somehow register included set of modules. I.e. I want a list of included modules to be accessible via some library class.

On desktop I would write in modules source files static section something like:
Code:
CLibrary::GetInstance()->RegisterModule(CSpecificModule::GetInstance());
However, I can't use static code in Symbian.

Could you advice any other way of registering included modules?

P.S.
ECom is not available


Tue, 2004-08-31 17:18
Joined: 2003-10-15
Forum posts: 78
Tue, 2004-08-31 18:10
Joined: 2003-01-14
Forum posts: 2133
why do not use "dynamically loaded" DLLs and define your own protocol to register your modules ?

This is a "pre-ECOM" solution that works well on Symbian OS 6.1.

Eric

Eric Bustarret
NewLC Founder & CEO / Professional Symbian OS Consultant

Tue, 2004-08-31 19:42
Joined: 2003-10-15
Forum posts: 78
Quote from: eric
why do not use "dynamically loaded" DLLs and define your own protocol to register your modules ?

This is a "pre-ECOM" solution that works well on Symbian OS 6.1.

Hmm... Because size requirements are very tight. This is for production testing and we are likely to include only subset of Symbian, just to test the hardware and/or drivers. Therefore I would like to use Symbian services as little as possible.

Thank you for opinion, I will reconcider DLL option

Tue, 2004-08-31 21:21
Joined: 2004-05-24
Forum posts: 982
You can use singletons as bridges to your modules and your code will look like
#ifdef __SOMETHING
//create bridge singleton
#endif
#ifdef __SOMTHINGELSE
//create other singleton
#endif

In singleton you can obtain the entry point to you modules and in the code simply check if there is already an instance of the singleton. If yes....use the module if not drop it

Lucian

pirosl

Tue, 2004-08-31 22:11
Joined: 2003-10-15
Forum posts: 78
Lucian, currently I am also coming to this decision.
Unfortunately it has drawbacks also..

The whole ifdef script has to be in some central library file and I'll have to modify it whenever I develop a new module. And the nature of the project is such, that different modules are likely to be developed by different people in a long period of time..

I am thinking if I can allow this. Unfortunately I can't see any better solution now.

P.S.
Actually Eric's solution also required that central module new of all the possible DLLs. If I understood him correctly

Tue, 2004-08-31 22:17
Joined: 2003-01-14
Forum posts: 2133
Quote
Actually Eric's solution also required that central module new of all the possible DLLs. If I understood him correctly

No, you can lookup all the *.dll files in a specified directory and then dynamically load each DLL you find using RLibrary::Load() method.

Eric

Eric Bustarret
NewLC Founder & CEO / Professional Symbian OS Consultant

Wed, 2004-09-01 08:55
Joined: 2004-05-24
Forum posts: 982
Quote from: doctor
Lucian, currently I am also coming to this decision.
Unfortunately it has drawbacks also..

The whole ifdef script has to be in some central library file and I'll have to modify it whenever I develop a new module. And the nature of the project is such, that different modules are likely to be developed by different people in a long period of time..

I am thinking if I can allow this. Unfortunately I can't see any better solution now.

P.S.
Actually Eric's solution also required that central module new of all the possible DLLs. If I understood him correctly

If you don't want to change the central library you can store the configurations in a config file.
Something like: LIB1_EXIST = TRUE|FALSE a.s.o. You'll read the file at start up and instead of using ifdef construction use
if (lib1_exist_read_fromfile)
   //create singleton bridge

You'll can virtually change through this file the libraries that you are using and don't have to change/recompile the central module

Lucian

pirosl


copyright 2003-2009 NewLC SARL