SDFPortHole.h
1 /**************************************************************************
2 Version identification:
3 @(#)SDFPortHole.h 2.19 3/2/95
4 
5 Copyright (c) 1990-1995 The Regents of the University of California.
6 All rights reserved.
7 
8 Permission is hereby granted, without written agreement and without
9 license or royalty fees, to use, copy, modify, and distribute this
10 software and its documentation for any purpose, provided that the
11 above copyright notice and the following two paragraphs appear in all
12 copies of this software.
13 
14 IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
15 FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
16 ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
17 THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
18 SUCH DAMAGE.
19 
20 THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
21 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
22 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
23 PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
24 CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES,
25 ENHANCEMENTS, OR MODIFICATIONS.
26 
27  PT_COPYRIGHT_VERSION_2
28  COPYRIGHTENDKEY
29 
30  Programmer: E. A. Lee and D. G. Messerschmitt
31  Date of creation: 5/29/90, J. Buck
32 
33 This file contains definitions of SDF-specific PortHole classes.
34 
35 ******************************************************************/
36 #ifndef _SDFPortHole_h
37 #define _SDFPortHole_h 1
38 #ifdef __GNUG__
39 #ifndef CYGWIN
40 #pragma interface
41 #endif
42 #endif
43 
44 #include "kernel/DFPortHole.h"
45 
46 extern bool sDebugPorts;
47 
48 /*****************************************************************
49 SDF: Synchronous Data Flow
50 
51 This is a common special case that is handled differently
52 from other cases:
53 
54  Each PortHole promises to consume or generate a fixed
55  number of Particles each time the Star is invoked.
56  This number is stored in the PortHole and can be accessed
57  by the SDFScheduler
58 
59  The incrementing of time is forced by the SDFScheduler,
60  and not by the Star itself. Incrementing time is effected
61  by consuming or generating Particles
62 ****************************************************************/
63 
64 
65 
67  // class SDFPortHole
69 
70 // Contains all the special features required for
71 // synchronous dataflow (SDF)
72 
73 class SDFPortHole : public DFPortHole
74 {
75  public:
76 
77  // class identification
78  int isA(const char*) const;
79  const char* className() const;
83  /*virtual*/ void initialize();
84 
91  void setNumXfer( int pNewRate );
92 
93  // Services of PortHole that are often used:
94  // setPort(DataType d);
95  // Particle& operator % (int);
96 };
97 
99  // class InSDFPort
101 
102 class InSDFPort : public SDFPortHole
103 {
104  public:
105  int isItInput () const ; // {return TRUE; }
106 
107  // Get Particles from input Geodesic
108  inline void receiveData()
109  {
110  if( mNotify || sDebugPorts )
112  else
113  DFPortHole::receive();
114 // NOTIFYDEBUGGER(mNotify);
115  }
116 
122 
123 
136  template<class T> InSDFPort& operator >> (T** pBuffer);
137 
138  };
139 
141  // class OutSDFPort
143 
144 class OutSDFPort : public SDFPortHole
145 {
146  public:
147  int isItOutput () const; // {return TRUE; }
148 
149  void increment();
150 
151  // Move the current Particle in the input buffer -- this
152  // method is invoked by the SDFScheduler before go()
153  virtual void receiveData();
154 
155  // Put the Particles that were generated into the
156  // output Geodesic -- this method is invoked by the
157  // SDFScheduler after go()
158  inline void sendData()
159  {
160  if( mNotify || sDebugPorts )
162  else
163  DFPortHole::send();
164  // <af> note: put the notify after send()
165  // to enable inspection of the output in conjunction with the new
166  // data transfer mechanism. (as opposed to previous ordering)
167 // NOTIFYDEBUGGER(mNotify);
168  }
169 
174  void sendDataWithPortDebug();
175 
176  template< class T>
177  OutSDFPort& operator << (T*);
178 
181  template<class T>
182  void rbwr( T* state_array, int* n_elements, int* status );
184 
185 };
186 
188 // class MultiSDFPort
190 
191 // Synchronous dataflow MultiPortHole: same as DFPortHole
192 
193 typedef MultiDFPort MultiSDFPort;
194 
196 // class MultiInSDFPort
198 
199 // MultiInSDFPort is an SDF input MultiPortHole
200 
201 class MultiInSDFPort : public MultiSDFPort
202 {
203  public:
204  int isItInput () const; // {return TRUE; }
205 
206  // Add a new physical port to the MultiPortHole list
207  PortHole& newPort();
208 };
209 
210 
212 // class MultiOutSDFPort
214 
215 // MultiOutSDFPort is an SDF output MultiPortHole
216 
217 class MultiOutSDFPort : public MultiSDFPort
218 {
219  public:
220  int isItOutput () const; // {return TRUE; }
221 
222  // Add a new physical port to the MultiPortHole list
223  PortHole& newPort();
224 };
225 
226 
231 class InSDFMPHIter : public MPHIter {
232 public:
233  InSDFMPHIter(MultiInSDFPort& mph) : MPHIter(mph) {}
234  InSDFPort* next() { return (InSDFPort*) MPHIter::next();}
235  InSDFPort* operator++(POSTFIX_OP) { return next();}
236 };
237 
238 class OutSDFMPHIter : public MPHIter {
239 public:
240  OutSDFMPHIter(MultiOutSDFPort& mph) : MPHIter(mph) {}
241  OutSDFPort* next() { return (OutSDFPort*) MPHIter::next();}
242  OutSDFPort* operator++(POSTFIX_OP) { return next();}
243 };
245 
246 
247 #endif
248 
249 
250 
Definition: SDFPortHole.h:217
void sendDataWithPortDebug()
Definition: SDFPortHole.cc:151
Definition: SDFPortHole.h:144
void rbwr(T *state_array, int *n_elements, int *status)
Definition: SDFPortHole.h:102
void receiveDataWithPortDebug()
Definition: SDFPortHole.cc:130
InSDFPort & operator>>(T **pBuffer)
Definition: SDFPortHole.cc:93
void initialize()
Definition: SDFPortHole.cc:50
void setNumXfer(int pNewRate)
Definition: SDFPortHole.cc:56
Definition: SDFPortHole.h:238
Definition: SDFPortHole.h:73
Definition: SDFPortHole.h:231
Definition: SDFPortHole.h:201