5f44da2c7fba6684d7b937010e5741420577e821
[fleet.git] / src / edu / berkeley / fleet / interpreter / Packet.java
1 package edu.berkeley.fleet.interpreter;
2 import edu.berkeley.fleet.api.*;
3
4 class Packet {
5
6     private final InterpreterPath path;
7     private final BitVector value;
8     private final boolean isToken;
9
10     public Packet(InterpreterPath path, BitVector value, boolean isToken) {
11         this.value = value;
12         this.path = path;
13         this.isToken = isToken;
14         this.value.setImmutable();
15     }
16
17     public void send() {
18         if (isToken) {
19             Log.token(path.getSource(), path.getDestination());
20         } else {
21             Log.data(value+"", path.getSource(), path.getDestination());
22         }
23         ((InterpreterDestination)path.getDestination()).addDataFromFabric(this);
24     }
25
26     public Destination getDestination() {
27         return path.getDestination();
28     }
29
30     public BitVector getSignal() {
31         return path.getSignal();
32     }
33
34     public BitVector getValue() {
35         return value;
36     }
37
38     public boolean isToken() {
39         return isToken;
40     }
41
42 }