tmf: Generalization of the statistics view
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / viewers / statistics / model / TmfStatistics.java
1 /*******************************************************************************
2 * Copyright (c) 2011, 2012 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 *******************************************************************************/
12
13 package org.eclipse.linuxtools.tmf.ui.viewers.statistics.model;
14
15 /**
16 * Primitive container for Statistics data
17 *
18 * Contains information about statistics that can be retrieved with any type of
19 * traces
20 *
21 * There are two counters : one for the total number of events in the trace and
22 * another for the number of events in the selected time range
23 *
24 * @version 2.0
25 * @version 2.0
26 * @since 2.0
27 * @author Mathieu Denis
28 */
29 public class TmfStatistics {
30
31 /**
32 * Total number of events.
33 *
34 * @since 2.0
35 */
36 protected long fNbEvents = 0;
37
38 /**
39 * Number of events within a time range (Partial event count).
40 *
41 * @since 2.0
42 */
43 protected long fNbEventsInTimeRange = 0;
44
45 /**
46 * @return the total events count
47 * @since 2.0
48 */
49 public long getTotal() {
50 return fNbEvents;
51 }
52
53 /**
54 * @return the partial events count within a time range
55 * @since 2.0
56 */
57 public long getPartial() {
58 return fNbEventsInTimeRange;
59 }
60
61 /**
62 * Increments by one the total number of events.
63 *
64 * @since 2.0
65 */
66 public void incrementTotal() {
67 ++fNbEvents;
68 }
69
70 /**
71 * Increments <b>nb</b> times the total number of events.
72 *
73 * @param nb
74 * Amount that will be added to the total events count. Ignored
75 * if negative.
76 * @since 2.0
77 */
78 public void incrementTotal(int nb) {
79 if (nb > 0) {
80 fNbEvents += nb;
81 }
82 }
83
84 /**
85 * Increments by one the number of events within a time range (partial events
86 * count).
87 *
88 * @since 2.0
89 */
90 public void incrementPartial() {
91 ++fNbEventsInTimeRange;
92 }
93
94 /**
95 * Increments <b>nb</b> times the number of events within a time range
96 * (partial events count).
97 *
98 * @param nb
99 * Amount that will be added to the partial events count. Ignored
100 * if negative.
101 * @since 2.0
102 */
103 public void incrementPartial(int nb) {
104 if (nb > 0) {
105 fNbEventsInTimeRange += nb;
106 }
107 }
108
109 /**
110 * Resets the total number of events.
111 *
112 * @since 2.0
113 */
114 public void resetTotalCount() {
115 fNbEvents = 0;
116 }
117
118 /**
119 * Resets the number of events within a time range (partial events count).
120 *
121 * @since 2.0
122 */
123 public void resetPartialCount() {
124 fNbEventsInTimeRange = 0;
125 }
126 }
This page took 0.033546 seconds and 5 git commands to generate.