Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 3edddb816bf08855d2bb23f138abe401f608ca17 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*******************************************************************************
 * Copyright (c) 2011, 2015 Ericsson
 *
 * All rights reserved. This program and the accompanying materials are
 * made available under the terms of the Eclipse Public License v1.0 which
 * accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *   Mathieu Denis <mathieu.denis@polymtl.ca> - Intial API and Implementation
 *   Bernd Hufmann - Allow zero value in setValue()
 *******************************************************************************/

package org.eclipse.tracecompass.tmf.ui.viewers.statistics.model;

/**
 * Primitive container for Statistics values.
 *
 * Contains information about statistics that can be retrieved with any type of
 * traces.
 *
 * There are two counters : one for the total number of events in the trace, and
 * another for the number of events in the selected time range.
 *
 * @author Mathieu Denis
 */
public class TmfStatisticsValues {

    /**
     * Total number of events.
     */
    protected long fNbEvents = 0;

    /**
     * Number of events within a time range (Partial event count).
     */
    protected long fNbEventsInTimeRange = 0;

    /**
     * @return the total events count
     */
    public long getTotal() {
        return fNbEvents;
    }

    /**
     * @return the partial events count within a time range
     */
    public long getPartial() {
        return fNbEventsInTimeRange;
    }

    /**
     * Set either the "global" or the "time range" value.
     *
     * @param global
     *            True to set the global value, false for the timerange one.
     * @param nb
     *            The new value to set
     */
    public void setValue(boolean global, long nb) {
        if (nb >= 0) {
            if (global) {
                fNbEvents = nb;
            } else {
                fNbEventsInTimeRange = nb;
            }
        }
    }

    /**
     * Resets the total number of events.
     */
    public void resetTotalCount() {
        fNbEvents = 0;
    }

    /**
     * Resets the number of events within a time range (partial events count).
     */
    public void resetPartialCount() {
        fNbEventsInTimeRange = 0;
    }

    @Override
    public String toString() {
        return fNbEvents + ", " + fNbEventsInTimeRange; //$NON-NLS-1$
    }
}

Back to the top