2 Replies - 1531 Views - Last Post: 10 April 2007 - 05:43 AM

#1 taraj  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 09-April 07

Software Design 2 applications into 1 source code

Posted 09 April 2007 - 11:50 PM


I'm after a few ideas for the following software that I am developing.

Background: Using Linux OS and Qt for software development. I have 1 application and copied that and developed another as a test and it worked, now I wish to merge them together to have 1 source code but 2 different products when running the applications.

I have 2 separate applications that have a very common code base but have different user interfaces and each has 1 additional/different process that is not required in the other application. I want to combine the 2 applications into 1 source code but still be able to maintain the separate applications, so require something that will allow the application (most likely at run-time?) to decide that it is application A or application B and run as that application. The 2 applications do not run on the same machine and the machine name can be used to identify the application that should be running on that machine.
There are many files in the source code that are different (software code directory structure is the same) but often it is only 1 or 2 lines, I don't really want to go through and use something #ifdef #define and put it around all occurrences of differences between the 2 applications.

So I'm after some ideas on how I might approach this problem, either at run-time or at compile-time, all ideas are welcome


Is This A Good Question/Topic? 0
  • +

Replies To: Software Design 2 applications into 1 source code

#2 NickDMax  Icon User is offline

  • Can grep dead trees!
  • member icon

Reputation: 2255
  • View blog
  • Posts: 9,245
  • Joined: 18-February 07

Re: Software Design 2 applications into 1 source code

Posted 10 April 2007 - 12:36 AM

I used to do this sort of thing a good deal back in my early dos days. I generally used a command line option to choose. There was a default behavior (say application A) and then there was a switch to add to make it into application B. And yet another switch ( /? ) to get it to display a help line.

Incidenty this is how screen savers work on Windows, they are launched in different modes depending on which command line option you give. No options loads the sreeen saver, then you can make it come up in config mode, or preview mode.

The technique is basicly just a big if (option==1) {run as application A} else {run as application B}
Was This Post Helpful? 0
  • +
  • -

#3 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 250
  • View blog
  • Posts: 13,507
  • Joined: 12-July 02

Re: Software Design 2 applications into 1 source code

Posted 10 April 2007 - 05:43 AM

If the machine name can be used as an identifier, I'd suggest simply changing the way in which the merged application boots up to take that machine name into account. One of the easiest ways is to run a batch file or equivalent on application start - the machine name can be detected, and the proper application run.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1