tmf: Split the state system in a separate plugin
[deliverable/tracecompass.git] / org.eclipse.linuxtools.statesystem.core / src / org / eclipse / linuxtools / statesystem / core / backend / NullBackend.java
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.statesystem.core.backend;
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.statesystem.core.interval.ITmfStateInterval;
21 import org.eclipse.linuxtools.statesystem.core.statevalue.ITmfStateValue;
22
23 /**
24 * An implement of a state history back-end to simply discards *all* the
25 * intervals it receives. Obviously, no queries can be done on it. It is useful
26 * for using with a StateSystem on which you will only want to do "ongoing"
27 * requests.
28 *
29 * @author Alexandre Montplaisir
30 * @since 3.0
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 }
This page took 0.038587 seconds and 5 git commands to generate.