F:/Dev-Cpp/Projects/Events System 1.0 Revision/Event.hpp

Go to the documentation of this file.
00001 #ifndef _Event
00002 #define _Event
00003 
00004 #include "ComplexElement.hpp"
00005 #include "Policies.hpp"
00006 
00007 namespace EventsSystem
00008 {
00016         namespace Policies
00017         {
00024                 class EventDestructionPolicy : public BasePolicy<Interfaces::ComplexElement>
00025                 {
00026                 public:
00033                         EventDestructionPolicy(Interfaces::ComplexElement &ceNewResponsible)
00034                         : BasePolicy<Interfaces::ComplexElement>(ceNewResponsible)
00035                         {
00036                         }
00037                         
00038                         virtual void operator()()
00039                         {
00040                                         if ( !oResponsible.isFinished() )
00041                                         {
00042                                                 delete oResponsible.getFront();
00043                                                 
00044                                                 oResponsible.removeLastComponent();             
00045                                                 operator()();
00046                                         }
00047                                         else
00048                                         {
00049                                                 oResponsible.removeLastComponent();                             
00050                                                 return;
00051                                         }
00052                         }
00053                 };
00054         }
00055         
00066         namespace Events
00067         {
00085                 template <class ConstructionPolicy, class DestructionPolicy = Policies::EventDestructionPolicy>
00086                 class Event : public Interfaces::ComplexElement
00087                 {
00088                 private:
00094                         DestructionPolicy dspPolicy;
00095                 protected:
00104                         Event() 
00105                         : dspPolicy(*this)
00106                         {
00107                                 ConstructionPolicy(*this)();
00108                         }
00109                         
00110                         ~Event() { dspPolicy(); }
00111                 public:
00118                         void runComponent()
00119                         {
00120                                 if ( !isFinished() )
00121                                 {
00122                                         Interfaces::Element *elCurrent = getCurrentComponent();
00123                                         
00124                                         elCurrent->runComponent();
00125                                         
00126                                         runComponent();
00127                                 }
00128                                 else
00129                                 {
00130                                         getCurrentComponent();
00131                                         return;
00132                                 }
00133                         }
00134                 };
00135         }
00136 }
00137 
00138 #endif

Generated on Thu Apr 13 12:15:07 2006 for Events System by  doxygen 1.4.6-NO