ss: History trees can define their own node types
[deliverable/tracecompass.git] / statesystem / org.eclipse.tracecompass.statesystem.core / src / org / eclipse / tracecompass / internal / statesystem / core / backend / NullBackend.java
1 /*******************************************************************************
2 * Copyright (c) 2013, 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 * Alexandre Montplaisir - Initial API and implementation
11 *******************************************************************************/
12
13 package org.eclipse.tracecompass.internal.statesystem.core.backend;
14
15 import java.io.File;
16 import java.io.FileInputStream;
17 import java.util.List;
18
19 import org.eclipse.jdt.annotation.NonNull;
20 import org.eclipse.tracecompass.statesystem.core.backend.IStateHistoryBackend;
21 import org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval;
22 import org.eclipse.tracecompass.statesystem.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 StateSystem on which you will only want to do "ongoing"
28 * requests.
29 *
30 * @author Alexandre Montplaisir
31 */
32 public class NullBackend implements IStateHistoryBackend {
33
34 private final @NonNull String ssid;
35
36 /**
37 * Constructor
38 *
39 * @param ssid
40 * The state system's id
41 */
42 public NullBackend(@NonNull String ssid) {
43 this.ssid = ssid;
44 }
45
46 @Override
47 public String getSSID() {
48 return ssid;
49 }
50
51 @Override
52 public long getStartTime() {
53 return 0;
54 }
55
56 @Override
57 public long getEndTime() {
58 return 0;
59 }
60
61 /**
62 * The interval will be discarded when using a null backend.
63 */
64 @Override
65 public void insertPastState(long stateStartTime, long stateEndTime,
66 int quark, ITmfStateValue value) {
67 /* The interval is always discarded. */
68 }
69
70 @Override
71 public void finishedBuilding(long endTime) {
72 /* Nothing to do */
73 }
74
75 @Override
76 public FileInputStream supplyAttributeTreeReader() {
77 return null;
78 }
79
80 @Override
81 public File supplyAttributeTreeWriterFile() {
82 return null;
83 }
84
85 @Override
86 public long supplyAttributeTreeWriterFilePosition() {
87 return -1;
88 }
89
90 @Override
91 public void removeFiles() {
92 /* Nothing to do */
93 }
94
95 @Override
96 public void dispose() {
97 /* Nothing to do */
98 }
99
100 /**
101 * Null back-ends cannot run queries. Nothing will be put in
102 * currentStateInfo.
103 */
104 @Override
105 public void doQuery(List<ITmfStateInterval> currentStateInfo, long t) {
106 /* Cannot do past queries */
107 }
108
109 /**
110 * Null back-ends cannot run queries. 'null' will be returned.
111 *
112 * @return Always returns null.
113 */
114 @Override
115 public ITmfStateInterval doSingularQuery(long t, int attributeQuark) {
116 /* Cannot do past queries */
117 return null;
118 }
119 }
This page took 0.033276 seconds and 5 git commands to generate.