[Kde-pim] KCalCore + Observers

Patrick Ohly patrick.ohly at gmx.de
Tue May 3 08:12:13 BST 2011


Hello!

KCalCore uses observers to notify library users of changes. These are
defined as abstract base classes with a few virtual methods:

class KCALCORE_EXPORT RecurrenceRule
{
  public:
    class RuleObserver
    {
      public:
        virtual ~RuleObserver();
        /** This method is called on each change of the recurrence object */
        virtual void recurrenceChanged( RecurrenceRule * ) = 0;
    };
...

Similar for Calendar::CalendarObserver.

Have you considered changing this to the signal/slot mechanism? It has
pros and cons, of course, I just want to get a feeling for your
opinions.

The advantage is that it'll be possible to extend the API without
breaking the ABI. It would also fit better into apps which are already
using QObject.

The disadvantage is that the observer classes can be used in apps which
do not use QObject.

A possible compromise is this:
      * Switch libkcalcore to the signal/slot version of the API,
        removing the register/removeObserver() calls and these Observer
        base classes. Requires adding QObject as base class of some
        classes (ReccurenceRule).
      * Add a second library which offers the Observer style API,
        implemented by connecting the signals in libkcalcore to slots in
        the observers. Its ABI would break if future changes are needed.

-- 
Bye, Patrick Ohly
--  
Patrick.Ohly at gmx.de
http://www.estamos.de/


_______________________________________________
KDE PIM mailing list kde-pim at kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
KDE PIM home page at http://pim.kde.org/



More information about the kde-pim mailing list