Toshio Koide | 58b3497 | 2014-02-12 14:54:47 -0800 | [diff] [blame] | 1 | package net.onrc.onos.intent; |
| 2 | |
| 3 | import net.onrc.onos.ofcontroller.networkgraph.NetworkGraph; |
| 4 | |
| 5 | /** |
| 6 | * @author Toshio Koide (t-koide@onlab.us) |
| 7 | */ |
| 8 | public class IntentDeserializer { |
| 9 | private String id; |
| 10 | private String className; |
| 11 | private Intent intent = null; |
| 12 | private NetworkGraph g; |
| 13 | |
| 14 | public IntentDeserializer(NetworkGraph graph, byte[] b) { |
| 15 | // TODO deserialize object and get (unique id, class name, object data) tuple. |
| 16 | g = graph; |
| 17 | id = "id"; |
| 18 | className = "pi"; |
| 19 | byte[] objectData = null; |
| 20 | |
| 21 | switch (className) { |
| 22 | case "pi": |
| 23 | parsePathIntent(objectData); |
| 24 | break; |
| 25 | case "spi": |
| 26 | parseShortestPathIntent(objectData); |
| 27 | break; |
| 28 | case "cspi": |
| 29 | parseConstrainedShortestPathIntent(objectData); |
| 30 | break; |
| 31 | default: |
| 32 | // TODO error |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | private void parsePathIntent(byte[] objectData) { |
| 37 | // TODO deserialize object and create instance |
| 38 | intent = new PathIntent(id, null, null, null); |
| 39 | } |
| 40 | |
| 41 | private void parseShortestPathIntent(byte[] objectData) { |
| 42 | // TODO deserialize object and create instance |
| 43 | intent = new ShortestPathIntent(g, id, 0L, 0L, 0L, 0L, 0L, 0L); |
| 44 | } |
| 45 | |
| 46 | private void parseConstrainedShortestPathIntent(byte[] objectData) { |
| 47 | // TODO deserialize object and create instance |
| 48 | intent = new ConstrainedShortestPathIntent(g, id, 0L, 0L, 0L, 0L, 0L, 0L, 0.0); |
| 49 | } |
| 50 | |
| 51 | public Intent getIntent() { |
| 52 | return intent; |
| 53 | } |
| 54 | } |