lttng: Move plugins to the Trace Compass namespace
[deliverable/tracecompass.git] / org.eclipse.tracecompass.lttng2.control.core / src / org / eclipse / linuxtools / internal / lttng2 / control / core / relayd / lttngviewerCommands / AttachSessionRequest.java
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
14 package org.eclipse.linuxtools.internal.lttng2.control.core.relayd.lttngviewerCommands;
15
16 import java.nio.ByteBuffer;
17 import java.nio.ByteOrder;
18
19 /**
20 * VIEWER_ATTACH_SESSION payload.
21 *
22 * @author Matthew Khouzam
23 * @since 3.0
24 */
25 public class AttachSessionRequest implements IRelayCommand {
26
27 /**
28 * Command size
29 *
30 * fSessionId + fOffset + fSeek
31 */
32 public static final int SIZE = (Long.SIZE + Long.SIZE) / 8 + SeekCommand.SIZE;
33 /** the id of a session */
34 private final long fSessionId;
35 /** unused for now */
36 private final long fOffset;
37 /** enum lttng_viewer_seek */
38 private final SeekCommand fSeek;
39
40 /**
41 * Attach session request constructor
42 *
43 * @param id
44 * the session id
45 * @param seekCommand
46 * the seek command
47 */
48 public AttachSessionRequest(long id, SeekCommand seekCommand) {
49 this(id, 0, seekCommand);
50 }
51
52 /**
53 * Attach session request constructor
54 *
55 * @param id
56 * the session id
57 * @param offset
58 * unused for now
59 * @param seekCommand
60 * the seek command
61 */
62
63 public AttachSessionRequest(long id, int offset, SeekCommand seekCommand) {
64 fSessionId = id;
65 fOffset = offset;
66 fSeek = seekCommand;
67
68 }
69
70 @Override
71 public byte[] serialize() {
72 byte data[] = new byte[SIZE];
73 ByteBuffer bb = ByteBuffer.wrap(data);
74 bb.order(ByteOrder.BIG_ENDIAN);
75 bb.putLong(fSessionId);
76 bb.putLong(fOffset);
77 bb.putInt(fSeek.getCommand());
78 return data;
79 }
80
81 }
This page took 0.032177 seconds and 5 git commands to generate.