Commit | Line | Data |
---|---|---|
f9a76cac AM |
1 | /******************************************************************************* |
2 | * Copyright (c) 2013 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 | * Alexandre Montplaisir - Initial API and implementation | |
11 | *******************************************************************************/ | |
12 | ||
13 | package org.eclipse.linuxtools.internal.tmf.core.statesystem.backends; | |
14 | ||
15 | import java.io.File; | |
16 | import java.io.FileInputStream; | |
17 | import java.io.PrintWriter; | |
18 | import java.util.List; | |
19 | ||
20 | import org.eclipse.linuxtools.internal.tmf.core.statesystem.StateSystem; | |
21 | import org.eclipse.linuxtools.tmf.core.interval.ITmfStateInterval; | |
22 | import org.eclipse.linuxtools.tmf.core.statevalue.ITmfStateValue; | |
23 | ||
24 | /** | |
25 | * An implement of a state history back-end to simply discards *all* the | |
26 | * intervals it receives. Obviously, no queries can be done on it. It is useful | |
27 | * for using with a {@link StateSystem} on which you will only want to do | |
28 | * "ongoing" requests. | |
29 | * | |
30 | * @author Alexandre Montplaisir | |
31 | */ | |
32 | public class NullBackend implements IStateHistoryBackend { | |
33 | ||
34 | /** | |
35 | * Constructor | |
36 | */ | |
37 | public NullBackend() {} | |
38 | ||
39 | @Override | |
40 | public long getStartTime() { | |
41 | return 0; | |
42 | } | |
43 | ||
44 | @Override | |
45 | public long getEndTime() { | |
46 | return 0; | |
47 | } | |
48 | ||
49 | /** | |
50 | * The interval will be discarded when using a null backend. | |
51 | */ | |
52 | @Override | |
53 | public void insertPastState(long stateStartTime, long stateEndTime, | |
54 | int quark, ITmfStateValue value) { | |
55 | /* The interval is always discarded. */ | |
56 | } | |
57 | ||
58 | @Override | |
59 | public void finishedBuilding(long endTime) { | |
60 | /* Nothing to do */ | |
61 | } | |
62 | ||
63 | @Override | |
64 | public FileInputStream supplyAttributeTreeReader() { | |
65 | return null; | |
66 | } | |
67 | ||
68 | @Override | |
69 | public File supplyAttributeTreeWriterFile() { | |
70 | return null; | |
71 | } | |
72 | ||
73 | @Override | |
74 | public long supplyAttributeTreeWriterFilePosition() { | |
75 | return -1; | |
76 | } | |
77 | ||
78 | @Override | |
79 | public void removeFiles() { | |
80 | /* Nothing to do */ | |
81 | } | |
82 | ||
83 | @Override | |
84 | public void dispose() { | |
85 | /* Nothing to do */ | |
86 | } | |
87 | ||
88 | /** | |
89 | * Null back-ends cannot run queries. Nothing will be put in | |
90 | * currentStateInfo. | |
91 | */ | |
92 | @Override | |
93 | public void doQuery(List<ITmfStateInterval> currentStateInfo, long t) { | |
94 | /* Cannot do past queries */ | |
95 | } | |
96 | ||
97 | /** | |
98 | * Null back-ends cannot run queries. 'null' will be returned. | |
99 | * | |
100 | * @return Always returns null. | |
101 | */ | |
102 | @Override | |
103 | public ITmfStateInterval doSingularQuery(long t, int attributeQuark) { | |
104 | /* Cannot do past queries */ | |
105 | return null; | |
106 | } | |
107 | ||
108 | /** | |
109 | * Null back-ends cannot run queries. | |
110 | * | |
111 | * @return Always returns false. | |
112 | */ | |
113 | @Override | |
114 | public boolean checkValidTime(long t) { | |
115 | /* Cannot do past queries */ | |
116 | return false; | |
117 | } | |
118 | ||
119 | @Override | |
120 | public void debugPrint(PrintWriter writer) { | |
121 | writer.println("Null history backend"); //$NON-NLS-1$ | |
122 | } | |
123 | } |