Commit | Line | Data |
---|---|---|
8c8bf09f ASL |
1 | /******************************************************************************* |
2 | * Copyright (c) 2009, 2010 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 | * Francois Chouinard - Initial API and implementation | |
11 | *******************************************************************************/ | |
12 | ||
6c13869b | 13 | package org.eclipse.linuxtools.tmf.core.request; |
8c8bf09f | 14 | |
72f1e62a | 15 | import org.eclipse.linuxtools.tmf.core.event.ITmfEvent; |
8c8bf09f ASL |
16 | |
17 | /** | |
8fd82db5 FC |
18 | * The TMF data request |
19 | * | |
20 | * @version 1.0 | |
21 | * @author Francois Chouinard | |
8c8bf09f | 22 | */ |
72f1e62a | 23 | public interface ITmfDataRequest<T extends ITmfEvent> { |
8c8bf09f | 24 | |
550d787e FC |
25 | // ------------------------------------------------------------------------ |
26 | // Constants | |
27 | // ------------------------------------------------------------------------ | |
28 | ||
f6b14ce2 | 29 | public enum ExecutionType { BACKGROUND, FOREGROUND }; |
550d787e | 30 | |
8c8bf09f ASL |
31 | // ------------------------------------------------------------------------ |
32 | // Accessors | |
33 | // ------------------------------------------------------------------------ | |
34 | ||
35 | /** | |
36 | * @return request data type (T) | |
37 | */ | |
38 | public Class<T> getDataType(); | |
39 | ||
40 | /** | |
41 | * @return request ID | |
42 | */ | |
2fb2eb37 | 43 | public int getRequestId(); |
8c8bf09f | 44 | |
550d787e FC |
45 | /** |
46 | * @return request ID | |
47 | */ | |
48 | public ExecutionType getExecType(); | |
49 | ||
8c8bf09f ASL |
50 | /** |
51 | * @return the index of the first event requested | |
52 | */ | |
9e0640dc | 53 | public long getIndex(); |
8c8bf09f ASL |
54 | |
55 | /** | |
56 | * @return the number of requested events | |
57 | */ | |
58 | public int getNbRequested(); | |
59 | ||
8016d660 FC |
60 | /** |
61 | * @return the block size (for BG requests) | |
62 | */ | |
63 | public int getBlockSize(); | |
64 | ||
8c8bf09f ASL |
65 | /** |
66 | * @return the number of events read so far | |
67 | */ | |
68 | public int getNbRead(); | |
69 | ||
70 | // ------------------------------------------------------------------------ | |
71 | // Request state | |
72 | // ------------------------------------------------------------------------ | |
73 | ||
550d787e | 74 | public boolean isRunning(); |
8c8bf09f ASL |
75 | public boolean isCompleted(); |
76 | public boolean isFailed(); | |
77 | public boolean isCancelled(); | |
78 | ||
79 | // ------------------------------------------------------------------------ | |
80 | // Data handling | |
81 | // ------------------------------------------------------------------------ | |
82 | ||
f9673903 | 83 | public void handleData(T data); |
8c8bf09f ASL |
84 | |
85 | // ------------------------------------------------------------------------ | |
86 | // Request handling | |
87 | // ------------------------------------------------------------------------ | |
88 | ||
550d787e | 89 | public void handleStarted(); |
8c8bf09f ASL |
90 | public void handleCompleted(); |
91 | public void handleSuccess(); | |
92 | public void handleFailure(); | |
93 | public void handleCancel(); | |
94 | ||
95 | /** | |
96 | * To suspend the client thread until the request completes | |
97 | * (or is canceled). | |
98 | */ | |
2fb2eb37 | 99 | public void waitForCompletion() throws InterruptedException; |
8c8bf09f ASL |
100 | |
101 | // ------------------------------------------------------------------------ | |
102 | // Request state modifiers | |
103 | // ------------------------------------------------------------------------ | |
104 | ||
550d787e | 105 | public void start(); |
8c8bf09f ASL |
106 | public void done(); |
107 | public void fail(); | |
108 | public void cancel(); | |
109 | } |