[Kde-imaging] feature list for host apps

Aurélien Gâteau aurelien.gateau at free.fr
Fri May 7 12:15:49 CEST 2004


Le Vendredi 7 Mai 2004 11:38, Jesper K. Pedersen a écrit :
> But how about this idea:
> How about in the KIPI::Interface class have the following code
>
> namespace KIPI {
>   enum Features { AlbumsHaveDescriptions = 0x0001, xxx = 0x0002,
>                   yyy = 0x0004, ... }
>   Class Interface {
>      int features();
>      ...
>   }
> }
>
> In plugins which want to integrate well into the apps, they could now have
> code like
>
> if ( interface->features() & AlbumHaveDescriptions  == 0 ) {
>    // Host app does not have the concept of album description
>    commentsArea->hide();
> }

The idea is good, but I'm concerned that the host app will still have to 
provide non working implementations of the missing features. In your example, 
you will have to implement the setAlbumDescription() and albumDescription() 
methods.
I'm wondering if it's possible to access such methods through other interfaces 
which could be implemented or not. I don't have a concrete idea yet, but I'm 
thinking about something like this:

---
namespace KIPI {
  class Interface {
    AlbumDescriptionInterface* albumDescriptionInterface();
    /* ... */
  };

  class AlbumDescriptionInterface {
    setDescription(const QString&);
    QString description() const;
  };
}
---

In KimDaBa, you would implement albumDescriptionInterface() as { return 0; }. 
The plugin code would look like this:

---
albumDescIface=interface->albumDescriptionInterface();

if (!albumDescIface) {
  commentsArea->hide();
}
---

Maybe we could even use dynamic_cast, which would produce something like this:
---
namespace KIPI {
  class Interface {
    /* ... */
  };

  class AlbumDescriptionInterface : public Interface {
    setDescription(const QString&);
    QString description() const;
  };
}
---

Plugin code:
---
albumDescIface=dynamic_cast<KIPI::AlbumDescriptionInterface>(interface);

if (!albumDescIface) {
  commentsArea->hide();
}
---

What do you think about this?

Aurélien



More information about the Kde-imaging mailing list