[PATCH] KPlayObject fixes for asynchronous generation + patch for kaboodle

Martijn Klingens klingens at kde.org
Tue Sep 3 09:59:54 BST 2002


On Monday 02 September 2002 19:42, Matthias Welwarsky wrote:
> Is there any possibility to versionate symbols in a C++ class library?

You can trick a bit with some preprocessor magic and a variant of the proxy 
(IIRC) pattern by doing stuff like

----
namespace KDE_3_0
{
  class Foo
  {
    class FooImpl;
    methodA() { m_instance->methodA(); }
    methodB() { m_instance->methodB(); }
    FooImpl *m_instance;
  };
}

#define KDE_CURRENT KDE_3_0
----

in the public API, and the private API defining FooImpl without having to 
worry about BC issues.

In the next version you can then have

----
namespace KDE_3_1
{
  class Foo
  {
    methodA( someArg ) { m_instance->methodA( someArg ); }
    methodB() { m_instance->methodB(); }
    FooImpl *m_instance;
  };
}

namespace KDE_3_0
{
  class Foo
  {
    methodA() { m_instance->methodA( emulatedSomeArg ); }
    methodB() { m_instance->methodB(); }
  };
}

#define KDE_CURRENT KDE_3_1
----

Code linked against 3.0 will use the emulated code, new code with 'using 
namespace KDE_CURRENT' (or KDE_3_1) will pick the up-to-date version.

The performance hit is rather high though and reimplementing virtuals is close 
to impossible, so I wonder if it's worth it.

-- 
Martijn



More information about the kde-multimedia mailing list