00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef __PROCESSEVENT_HPP
00033 #define __PROCESSEVENT_HPP
00034
00035 #include "libecs.hpp"
00036 #include "Process.hpp"
00037
00038 #include "EventScheduler.hpp"
00039
00040
00041 namespace libecs
00042 {
00043
00044
00045
00046 DECLARE_CLASS( ProcessEvent );
00047
00048 class ProcessEvent
00049 :
00050 public EventBase
00051 {
00052
00053
00054 public:
00055
00056 ProcessEvent( TimeParam aTime, ProcessPtr aProcessPtr )
00057 :
00058 EventBase( aTime ),
00059 theProcess( aProcessPtr )
00060 {
00061 ;
00062 }
00063
00064 const ProcessPtr getProcess() const
00065 {
00066 return theProcess;
00067 }
00068
00069
00070 void fire()
00071 {
00072
00073 theProcess->addValue( 1.0 );
00074
00075 reschedule( getTime() );
00076 }
00077
00078 void update( TimeParam aTime )
00079 {
00080 reschedule( aTime );
00081 }
00082
00083 void reschedule( TimeParam aTime )
00084 {
00085 const Time aNewStepInterval( theProcess->getStepInterval() );
00086 setTime( aNewStepInterval + aTime );
00087 }
00088
00089 const bool isDependentOn( ProcessEventCref anEvent ) const
00090 {
00091 return theProcess->isDependentOn( anEvent.getProcess() );
00092 }
00093
00094
00095 const bool operator< ( ProcessEventCref rhs ) const
00096 {
00097
00098
00099 if( getTime() > rhs.getTime() )
00100 {
00101 return false;
00102 }
00103 else if( getTime() < rhs.getTime() )
00104 {
00105 return true;
00106 }
00107 else
00108 {
00109 if( theProcess->getPriority() < rhs.getProcess()->getPriority() )
00110 {
00111 return true;
00112 }
00113 else
00114 {
00115 return false;
00116 }
00117 }
00118 }
00119
00120 const bool operator!= ( ProcessEventCref rhs ) const
00121 {
00122 if( getTime() == rhs.getTime() &&
00123 getProcess() == rhs.getProcess() )
00124 {
00125 return false;
00126 }
00127 else
00128 {
00129 return true;
00130 }
00131 }
00132
00133
00134
00135 ProcessEvent()
00136 {
00137 ;
00138 }
00139
00140
00141 private:
00142
00143 ProcessPtr theProcess;
00144
00145 };
00146
00147
00148
00149 }
00150
00151
00152
00153
00154 #endif
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166