gdbtrace: Move plugins to the Trace Compass namespace
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.control.core / src / org / eclipse / linuxtools / internal / lttng2 / control / core / relayd / lttngviewerCommands / NewStreamsResponse.java
CommitLineData
8e15b929
MK
1/**********************************************************************
2 * Copyright (c) 2014 Ericsson
3 *
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *
9 * Contributors:
10 * Matthew Khouzam - Initial implementation and API
11 * Marc-Andre Laperle - Initial implementation and API
12 **********************************************************************/
13
14package org.eclipse.linuxtools.internal.lttng2.control.core.relayd.lttngviewerCommands;
15
16import java.io.DataInputStream;
17import java.io.IOException;
18import java.nio.ByteBuffer;
19import java.nio.ByteOrder;
20import java.util.List;
21
22import com.google.common.collect.ImmutableList;
23
24/**
25 * Response to a "new streams" command
26 *
27 * @author Matthew Khouzam
28 * @since 3.0
29 */
30public class NewStreamsResponse implements IRelayResponse {
31
8adfbb73
MAL
32 /**
33 * Response size
34 *
35 * fStatus + fNbStreams
36 */
8e15b929
MK
37 private static final int SIZE = (Integer.SIZE + Integer.SIZE) / 8;
38 /** status of the request */
39 private final NewStreamsReturnCode fStatus;
40 /** the number of streams */
41 private final int fNbStreams;
42 /** the list of streams in the response */
43 private final List<StreamResponse> fStreamList;
44
45 /**
46 * New stream response network constructor
47 *
48 * @param inNet
49 * network stream
50 * @throws IOException
51 * network error
52 */
53 public NewStreamsResponse(DataInputStream inNet) throws IOException {
54 byte[] data = new byte[SIZE];
55 inNet.readFully(data);
56 ByteBuffer bb = ByteBuffer.wrap(data);
57 bb.order(ByteOrder.BIG_ENDIAN);
58 fStatus = NewStreamsReturnCode.values()[bb.getInt() - 1];
59 fNbStreams = bb.getInt();
60 ImmutableList.Builder<StreamResponse> sl = new ImmutableList.Builder<>();
61 if (getStatus().equals(NewStreamsReturnCode.LTTNG_VIEWER_NEW_STREAMS_OK)) {
62 for (int stream = 0; stream < fNbStreams; stream++) {
63 sl.add(new StreamResponse(inNet));
64 }
65 }
66 fStreamList = sl.build();
67 }
68
69 /**
70 * Gets the status
71 *
72 * @return the status
73 */
74 public NewStreamsReturnCode getStatus() {
75 return fStatus;
76 }
77
78 /**
79 * gets the stream list
80 *
81 * @return the stream list
82 */
83 public List<StreamResponse> getStreamList() {
84 return fStreamList;
85 }
86
87 /**
88 * The number of streams
89 *
90 * @return the number of streams
91 */
92 public int getNbStreams() {
93 return fNbStreams;
94 }
95
96}
This page took 0.035834 seconds and 5 git commands to generate.