analysis: Move plugins to their own sub-directory
[deliverable/tracecompass.git] / org.eclipse.tracecompass.tmf.ui / src / org / eclipse / tracecompass / tmf / ui / viewers / statistics / model / TmfStatisticsValues.java
1 /*******************************************************************************
2 * Copyright (c) 2011, 2015 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 * Mathieu Denis <mathieu.denis@polymtl.ca> - Intial API and Implementation
11 * Bernd Hufmann - Allow zero value in setValue()
12 *******************************************************************************/
13
14 package org.eclipse.tracecompass.tmf.ui.viewers.statistics.model;
15
16 /**
17 * Primitive container for Statistics values.
18 *
19 * Contains information about statistics that can be retrieved with any type of
20 * traces.
21 *
22 * There are two counters : one for the total number of events in the trace, and
23 * another for the number of events in the selected time range.
24 *
25 * @author Mathieu Denis
26 */
27 public class TmfStatisticsValues {
28
29 /**
30 * Total number of events.
31 */
32 protected long fNbEvents = 0;
33
34 /**
35 * Number of events within a time range (Partial event count).
36 */
37 protected long fNbEventsInTimeRange = 0;
38
39 /**
40 * @return the total events count
41 */
42 public long getTotal() {
43 return fNbEvents;
44 }
45
46 /**
47 * @return the partial events count within a time range
48 */
49 public long getPartial() {
50 return fNbEventsInTimeRange;
51 }
52
53 /**
54 * Set either the "global" or the "time range" value.
55 *
56 * @param global
57 * True to set the global value, false for the timerange one.
58 * @param nb
59 * The new value to set
60 */
61 public void setValue(boolean global, long nb) {
62 if (nb >= 0) {
63 if (global) {
64 fNbEvents = nb;
65 } else {
66 fNbEventsInTimeRange = nb;
67 }
68 }
69 }
70
71 /**
72 * Resets the total number of events.
73 */
74 public void resetTotalCount() {
75 fNbEvents = 0;
76 }
77
78 /**
79 * Resets the number of events within a time range (partial events count).
80 */
81 public void resetPartialCount() {
82 fNbEventsInTimeRange = 0;
83 }
84
85 @Override
86 public String toString() {
87 return fNbEvents + ", " + fNbEventsInTimeRange; //$NON-NLS-1$
88 }
89 }
This page took 0.033711 seconds and 5 git commands to generate.