Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Can QPlugins safely be used in a static/shared library project?

Can QPlugins safely be used in a static/shared library project?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    RolandWinklmeier
    wrote on last edited by
    #1

    Hi all,

    first of all some background:

    I'm developing a voice library in C++. It should be cross platform and support different codecs (Opus, Speex, etc) as well as different sound drivers (DirectSound, PulseAudio, CoreAudio etc).

    I started with the typical approach by designing an abstract interface, lets say ICodec. This interface is pure virtual.

    Now I have the typical problem as many other projects, how do I register the different codecs to my managing class.
    The easiest way is to hard code the available codes in a enum and pass this to the create method

    @
    enum ECodecs{ SPEEX = 1,
    OPUS,
    [...] };

    ICodec *CCodecFactory::create (ECodecs codec)
    {
    ICodec *codecObj;
    switch (codec)
    {
    case SPEEX:
    codecObj = createSpeexCodec();
    break;

        case OPUS:
             codecObj = createOpusCodec();
        break;
        [....]
    
       return codecObj;
    

    }
    @

    But this is a pain if you want to add new codecs later.
    An also very common approach is to use a factory object, which registers itself to the manager in its constructor. To make this work, you need a static global object, otherwise the constructor gets never called.

    @
    CSpeexCreator g_speexCreator;

    [...]

    CSpeexCreator::CSpeexCreator(const QString &name)
    {
    CCodecManger::register(name, this);
    }
    @

    but this is highly nonstandard and you never can be sure, what happens, so I don't really like this approach.

    Now to my question:
    From my point of view, the Qt plugin framework would fit perfectly. The implementations could be done in plugins. Codecs could be removed and added via plugins without the need to rebuild the whole library.

    But is it safe to use Qt plugin in a library project or should not use it? The library I'm developing is not a application but only a library providing voice client implementations.
    Are there any objections?

    1 Reply Last reply
    0
    • R Offline
      R Offline
      RolandWinklmeier
      wrote on last edited by
      #2

      Does nobody have an answer? The design can't be that unconventional ;)

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        No it's not, if you look through Qt's sources you'll see it's what they use for example with QtMultimedia (thinking of the backends)

        Nothing forbids you to do it :)

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved