SPQEvent.h
1 // -----------------------------------------------------------------//
2 // //
3 // Project : MLDesigner //
4 // Author : Andreas Franck //
5 // eMail : andreas.franck@mldesigner.com //
6 // Copyright : MLDesign Technologies, Inc. //
7 // Created : 10/26/2001 //
8 // //
9 //------------------------------------------------------------------//
10 
11 #ifndef __SPQEvent_h
12 #define __SPQEvent_h 1
13 
14 // -------------------------------------------------------------------
15 
16 #ifdef __GNUG__
17 #ifndef CYGWIN
18 #pragma interface
19 #endif
20 #endif
21 
22 // -------------------------------------------------------------------
23 
24 #include <iostream>
25 #include <deque>
26 #include <algorithm>
27 
28 // -------------------------------------------------------------------
29 
30 #include "kernel/types.h"
31 #include "kernel/DataStruct.h"
32 #include "kernel/PriorityQueue.h"
33 #include "kernel/PortHole.h"
34 #include "kernel/Exception.h"
35 
36 class Particle;
37 class Star;
38 
39 // -------------------------------------------------------------------
40 
41 enum EventTypeT
42 {
43  PortHoleEntry,
44  SpecEventEntry,
45  ProcessEntry,
46  ContinuousBreakEntry,
47  ContinuousSampleEntry,
48 };
49 
50 // -------------------------------------------------------------------
51 
57 struct SPQEvent {
58 public:
59  SPQEvent(): mParticle( 0 ),
60  mPort( 0 ),
61  mProcessEvent( 0 ),
62  mLevel( 0 ),
63  mFineLevel( 0 ),
64  mEventType ( PortHoleEntry ),
65  mAbsEventNum( 0 )
66  {}
67 
68  SPQEvent( Particle* pPa, PortHole* pPh,
69  const double& pL, const double& pFL,
70  long pEventNum, EventTypeT t = PortHoleEntry ):
71  mParticle( pPa ), mPort( pPh ), mProcessEvent( 0 ),
72  mLevel( pL ), mFineLevel( pFL ),
73  mEventType ( t ),
74  mAbsEventNum( pEventNum )
75  {}
76 
77  SPQEvent( Particle* pPa, PortHole* pPh,
78  const double& pL, long pEventNum, EventTypeT t = PortHoleEntry ):
79  mParticle( pPa ), mPort( pPh ), mProcessEvent( 0 ),
80  mLevel( pL ), mFineLevel( 0 ),
81  mEventType ( t ),
82  mAbsEventNum( pEventNum )
83  {}
84 
85  SPQEvent( Pointer pP,
86  const double& pL,
87  long pEventNum,
88  EventTypeT t = PortHoleEntry ):
89  mParticle( 0 ),
90  mPort( 0 ),
91  mProcessEvent( pP ),
92  mLevel( pL ),
93  mFineLevel( 0.0 ),
94  mEventType ( t ),
95  mAbsEventNum( pEventNum )
96  {}
97 
98  SPQEvent( Pointer pP,
99  const double& pL, const double& pFL,
100  long pEventNum, EventTypeT t = PortHoleEntry ):
101  mParticle( 0 ),
102  mPort( 0 ),
103  mProcessEvent( pP ),
104  mLevel( pFL ),
105  mFineLevel( pFL ),
106  mEventType ( t ),
107  mAbsEventNum( pEventNum )
108  {}
109 
110  Particle* mParticle;
111  PortHole* mPort;
112  Pointer mProcessEvent;
113  double mLevel;
114  double mFineLevel;
115  EventTypeT mEventType;
116 
125 };
126 
135  public:
136  bool operator() ( const SPQEvent* lhs, const SPQEvent* rhs ) const
137  {
138  if( lhs->mLevel == rhs->mLevel )
139  return lhs->mAbsEventNum > rhs->mAbsEventNum;
140  else
141  return lhs->mLevel > rhs->mLevel;
142  }
143 };
144 
145 
155  public:
156  int operator() ( const SPQEvent* lhs, const SPQEvent* rhs ) const
157  {
158  if( lhs->mLevel > rhs->mLevel)
159  return true;
160  else if( lhs->mLevel == rhs->mLevel )
161  {
162  // special case: if finelevels are equal, use order of insertion
163  if( lhs->mFineLevel == rhs->mFineLevel )
164  return lhs->mAbsEventNum > rhs->mAbsEventNum;
165  else return lhs->mFineLevel > rhs->mFineLevel;
166  }
167  else return false;
168  }
169 /*
170  int operator() ( const SPQEvent* lhs, const SPQEvent* rhs ) const {
171  if( lhs->mLevel > rhs->mLevel)
172  return true;
173  else if( lhs->mLevel == rhs->mLevel )
174  return lhs->mFineLevel > rhs->mFineLevel;
175  else return false;
176  }
177 */
178 };
179 
180 
181 #endif // __SPQEvent_h
182 
183 
184 
185 
186 
187 
Definition: SPQEvent.h:154
Definition: SPQEvent.h:134
long mAbsEventNum
Definition: SPQEvent.h:124
Definition: SPQEvent.h:57