removed apps
[luayats.git] / src / user / fork.c
blobe9d1a305ce498b1f4315bb614f231ce6ef6cbbe7
1 /*************************************************************************
3 * YATS - Yet Another Tiny Simulator
5 **************************************************************************
7 * Copyright (C) 1995-1997 Chair for Telecommunications
8 * Dresden University of Technology
9 * D-01062 Dresden
10 * Germany
12 **************************************************************************
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 **************************************************************************
30 * Module author: Matthias Baumann, TUD
31 * Creation: Oct 2, 1997
33 * History:
35 *************************************************************************/
38 * Fork -- sends a copy of an incoming data object to each output. The
39 * original data object is forwarded to the first output.
40 * The data type should not matter, if the clone() method is defined
41 * properly. This is just to test the clone() methods.
43 * Fork fork: NOUT=3,
44 * OUT=sink[1], sink[2], sink[3];
45 * or (equivalent, if names follow a regular structure):
46 * Fork fork: NOUT=3,
47 * OUT=(i: sink[i]);
48 * // NOUT: # of outputs
49 * // in case of a given counter variable (it has to be defined in advance),
50 * // output names are generated by the template given
53 #include "fork.h"
55 dfork::dfork(void)
58 dfork::~dfork(void)
61 // data item has arrived.
62 // Send a clone to each output.
63 rec_typ dfork::REC(data * pd, int)
65 int n;
67 // first send the clones, since pd might be deleted by
68 // the receiver
70 for (n = 1; n < noutp; ++n)
71 sucs[n]->rec(pd->clone(), shands[n]);
73 // original data object sent to first output
74 sucs[0]->rec(pd, shands[0]);
76 return ContSend;