• Immutable Page
  • Info
  • Attachments

Compiz++ Plugin-Classes System

The plugin-classes system (formerly called privates system) is needed for the plugin specific implementations of the Screen/Window classes inside of the main CompScreen/CompWindow classes. It also provides a system to allow plugins to get the Screen/Window classes of other plugins.

Plugin-class index allocation, saving of the Plugin pointer and the freeing of the index is now done automatically in the background. The plugin only needs to derive its classes from PluginClassHandler<[plugin class name],[storage class name] [,OPTIONAL: plugin abi]> and call it's constructor with the storage class pointer. The third template parameter is optional and should be set to the plugin ABI in plugin plugins.

Example:

class FooWindow :
  public PluginClassHandler<FooWindow, CompWindow>,
  ... // other derived classes
{
  ...
}

FooWindow::FooWindow (CompWindow *w) :
  PluginClassHandler<FooWindow, CompWindow> (w),
  ... // other constructors or variable initalisations
{
  ... // other initialisations
}

The PluginClassHandler template class creates a static "get" function that allows to get the plugin class pointer out of the main class.

FooWindow * FooWindow::get (CompWindow *); // replaces the FOO_WINDOW(w) C compiz macro

To get a class of a other plugin plugin, only the header of this plugin needs to be included and then its "get" functions to be called.

someFooPluginFunction ()
{
  GLScreen *gScreen = GLScreen::get (screen);
  CompositeScreen *cScreen = CompositeScreen::get (screen);
}

The "get" functions check the ABI of the other plugin and will return NULL if the ABI doesn't match or the other plugin is not loaded.

To avoid unneeded calls to the "get" function, a plugin that uses other plugins should store the pointers to the other plugin classes in its own class and use the "get" function only to initialise them in the constructor.

Example:

class FooWindow :
  public PluginClassHandler<FooWindow, CompWindow>,
  ... // other derived classes
{
  ...
  CompositeWindow *cWindow;
  GLWindow        *gWindow;
  ...
}

FooWindow::FooWindow (CompWindow *w) :
  PluginClassHandler<FooWindow, CompWindow> (w),
  cWindow (CompositeWindow::get (w)),
  gWindow (GLWindow::get (w)),
  ... // other constructors or variable initalisations
{
  ... // other initialisations
}

Development/Compiz++Documentation/C++PluginClasses (last edited 2009-03-14 16:28:55 by adsl-71-145-148-138)