moc files overwrites



  • Hi all,
    I encountered difficulties with build program.
    I have directory architecture like this:

    -Category                
    -project.pro
    --v1.0                         
    ----Manager.h
    ----Manager.cpp
    --v2.0                        
    ----Manager.h
    ----Manager.cpp
    --v3.0                         
    ----Manager.h
    ----Manager.cpp
    

    All this classes have a such structure:

    namespace Category
    {
       namespace Version_{N}
       {
          class Manager : public QObject
          ...
       }
    }
    

    but when I compile my program, moc files overwrites each other because are created in root dir next to pro file
    Is there any way to solve this problem?


  • Moderators

    @sailor.steve To be honest this is a strange way to support several versions of source code. Why don't you simply use a source control system like Subversion or Git and use branches for different versions?



  • @jsulm said in moc files overwrites:

    @sailor.steve To be honest this is a strange way to support several versions of source code. Why don't you simply use a source control system like Subversion or Git and use branches for different versions?

    it customer requirement, needs to supported various of versions databases in same server.
    earlier this server supported only one database version but customer requested that server supported older versions.


  • Lifetime Qt Champion

    Hi,

    What is so different about these versions that they require different classes with almost the same name ?



  • You should split the project into 3 subprojects using the subdirs template. Then create a .pro file for each version where you can use MOC_DIR to specify a different directory for moc files



  • @SGaist said in moc files overwrites:

    Hi,

    What is so different about these versions that they require different classes with almost the same name ?

    These classes for work with database.
    From version to version a struct of database has been changing
    These classes contains sql queries, designed to concrete version of database
    Presently desktop clients connect to the server wich can work only with concrete version of database
    For each version of desktop program is running appropriate server.
    Customer requires support various of versions databases in same server.


  • Moderators

    @sailor.steve You could change names of all these classes so they reflect the db version they support (like DbInterface01) and then add a version independent class which decides which of these classes to use (based on version) and uses it. All these version dependant classes should have a common base class.

    class DbInterface {};
    class DbInterface01 : public DbInterface {};
    ...
    class DbInterface0N : public DbInterface {};
    
    class DbManager
    {
    public:
        DbManager()
        {
            // Just example code
            if (dbVersion == 1)
                dbInterface = new DbInterface01();
        }
    private:
        DbInterface *dbInterface;
    };
    

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.