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