Changeset 5931 for branches/newapi

Show
Ignore:
Timestamp:
12/04/07 04:09:51 (12 months ago)
Author:
erijo
Message:

New class: EventQueue?. Every plugin get their own event queue and can
register to receive events. The events are then queued on the plugin's
event queue. When the plugin is done with the event, it must commit it
so that it can continue down the event pipeline.

Location:
branches/newapi/licq
Files:
4 added
7 modified

Legend:

Unmodified
Added
Removed
  • branches/newapi/licq/licq/interface/plugin.h

    r5921 r5931  
    3030{ 
    3131 
     32class EventQueue; 
    3233class Log; 
    3334 
     
    7475    /// The log that the plugin should use when logging. 
    7576    Log* log; 
     77 
     78    /// The plugin's event queue. 
     79    EventQueue* eventQueue; 
    7680 
    7781    /// Number of arguments in argv. Always >= 1. 
  • branches/newapi/licq/src/event/CMakeLists.txt

    r5894 r5931  
    33  event.cpp 
    44  eventloop.cpp 
     5  eventqueue.cpp 
    56  timerset.cpp 
    67) 
  • branches/newapi/licq/src/event/test/CMakeLists.txt

    r5894 r5931  
    33set(test_SRCS 
    44  descriptorsettest.cpp 
     5  eventqueuetest.cpp 
    56  eventtest.cpp 
    67  eventlooptest.cpp 
  • branches/newapi/licq/src/plugin/plugininstance.h

    r5926 r5931  
    3131{ 
    3232 
     33class EventQueue; 
     34 
    3335/** 
    3436 * An abstract interface to ease unit testing. Please refer to 
     
    4143 
    4244  virtual Licq::Plugin::Id getPluginId() const = 0; 
    43   virtual Licq::Plugin* getPlugin() = 0; 
    44   virtual Licq::Thread* getThread() = 0; 
     45  virtual Licq::Plugin* getPlugin() const = 0; 
     46  virtual Licq::Thread* getThread() const = 0; 
     47  virtual LicqDaemon::EventQueue* getEventQueue() const = 0; 
    4548 
    4649protected: 
  • branches/newapi/licq/src/plugin/plugininstanceimpl.cpp

    r5926 r5931  
    4949    myLogSink(sink) 
    5050{ 
    51   mySetup.id = 0; 
    52   mySetup.log = NULL; 
    53   mySetup.argc = 0; 
    54   mySetup.argv = 0; 
     51  ::memset(&mySetup, 0, sizeof(mySetup)); 
    5552} 
    5653 
     
    6865  myPlugin = NULL; 
    6966 
     67  // Cleanup mySetup 
    7068  delete static_cast<Log*>(mySetup.log); 
     69  delete static_cast<EventQueue*>(mySetup.eventQueue); 
     70 
    7171  for (int i = 0; i < mySetup.argc; ++i) 
    7272    free(mySetup.argv[i]); 
     
    9292  mySetup.id = getNextPluginId(); 
    9393 
     94  // Create the plugin's event queue 
     95  mySetup.eventQueue = new EventQueue(myInformation->name); 
     96 
    9497  // Create the plugin 
    9598  myPlugin = myLibrary->createPlugin(mySetup); 
  • branches/newapi/licq/src/plugin/plugininstanceimpl.h

    r5921 r5931  
    2121#define LICQDAEMON_PLUGININSTANCEIMPL_H 
    2222 
     23#include "event/eventqueue.h" 
    2324#include "licq/thread/thread.h" 
    2425#include "plugin/plugininstance.h" 
     
    6162   * @returns This plugin's Licq::Plugin instance. 
    6263   */ 
    63   Licq::Plugin* getPlugin(); 
     64  Licq::Plugin* getPlugin() const; 
    6465 
    6566  /** 
     
    6768   * @returns This plugin's thread. 
    6869   */ 
    69   Licq::Thread* getThread(); 
     70  Licq::Thread* getThread() const; 
     71 
     72  /** 
     73   * @pre load() has been called successfully. 
     74   * @returns This plugin's event queue. 
     75   */ 
     76  EventQueue* getEventQueue() const; 
    7077 
    7178private: 
     
    8895} 
    8996 
    90 inline Licq::Plugin* LicqDaemon::PluginInstanceImpl::getPlugin() 
     97inline Licq::Plugin* LicqDaemon::PluginInstanceImpl::getPlugin() const 
    9198{ 
    9299  return myPlugin; 
    93100} 
    94101 
    95 inline Licq::Thread* LicqDaemon::PluginInstanceImpl::getThread() 
     102inline Licq::Thread* LicqDaemon::PluginInstanceImpl::getThread() const 
    96103{ 
    97104  return myThread; 
    98105} 
    99106 
     107inline LicqDaemon::EventQueue* LicqDaemon::PluginInstanceImpl::getEventQueue() const 
     108{ 
     109  return static_cast<EventQueue*>(mySetup.eventQueue); 
     110} 
     111 
    100112#endif 
  • branches/newapi/licq/src/plugin/pluginmanagerimpl.cpp

    r5926 r5931  
    1818 */ 
    1919 
     20#include "licq/event/eventqueue.h" 
    2021#include "plugin/plugincache.h" 
    2122#include "plugin/plugininstanceimpl.h" 
     
    6566  instance->getThread()->start(); 
    6667 
     68  // Send started event 
     69  boost::shared_ptr<Licq::Event> started = Licq::Event::create("started"); 
     70  instance->getEventQueue()->pushEvent(started); 
     71 
    6772  return id; 
    6873}