Class EventBasedCounter

java.lang.Object
org.djutils.stats.summarizers.Counter
org.djutils.stats.summarizers.event.EventBasedCounter
All Implemented Interfaces:
Serializable, Remote, EventListener, org.djutils.event.EventListener, org.djutils.event.EventProducer, Statistic

public class EventBasedCounter extends Counter implements org.djutils.event.EventProducer, org.djutils.event.EventListener
The Counter class defines a statistics event counter. It embeds an EventProducer so it can keep listeners informed about new observations, and it listens to external events to be able to receive observations, in addition to the register(...) method.

Copyright (c) 2002-2024 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information https://simulation.tudelft.nl. The DSOL project is distributed under a three-clause BSD-style license, which can be found at https://simulation.tudelft.nl/dsol/3.0/license.html.

Author:
Alexander Verbraeck, Peter Jacobs
See Also:
  • Field Summary

    Fields inherited from interface org.djutils.event.EventProducer

    FIRST_POSITION, LAST_POSITION
  • Constructor Summary

    Constructors
    Constructor
    Description
    Construct a new EventBasedCounter.
    EventBasedCounter(String description, org.djutils.event.EventProducer eventProducer)
    Construct a new EventBasedCounter with a specific EventProducer, e.g.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    Method that can be overridden to fire own events or additional events when registering an observation.
    org.djutils.event.EventListenerMap
    void
    Initialize the counter.
    void
    notify(org.djutils.event.Event event)
    long
    register(long value)
    Process one observed value.

    Methods inherited from class org.djutils.stats.summarizers.Counter

    getCount, getDescription, getN, reportFooter, reportHeader, reportLine, toString

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.djutils.event.EventProducer

    addListener, addListener, addListener, addListener, fireEvent, fireEvent, fireEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, getEventTypesWithListeners, getListenerReferences, hasListeners, numberOfListeners, removeAllListeners, removeAllListeners, removeListener

    Methods inherited from interface org.djutils.stats.summarizers.Statistic

    formatFixed
  • Constructor Details

    • EventBasedCounter

      public EventBasedCounter(String description)
      Construct a new EventBasedCounter.
      Parameters:
      description - String; the description for this counter
    • EventBasedCounter

      public EventBasedCounter(String description, org.djutils.event.EventProducer eventProducer)
      Construct a new EventBasedCounter with a specific EventProducer, e.g. a remote one.
      Parameters:
      description - String; the description for this counter
      eventProducer - EventProducer; the EventProducer to embed and use in this statistic
  • Method Details

    • getEventListenerMap

      public org.djutils.event.EventListenerMap getEventListenerMap() throws RemoteException
      Specified by:
      getEventListenerMap in interface org.djutils.event.EventProducer
      Throws:
      RemoteException
    • initialize

      public void initialize()
      Initialize the counter.
      Specified by:
      initialize in interface Statistic
      Overrides:
      initialize in class Counter
    • notify

      public void notify(org.djutils.event.Event event)
      Specified by:
      notify in interface org.djutils.event.EventListener
    • register

      public long register(long value)
      Process one observed value.
      Overrides:
      register in class Counter
      Parameters:
      value - long; the value to process
      Returns:
      long; the value
    • fireEvents

      protected void fireEvents() throws RemoteException
      Method that can be overridden to fire own events or additional events when registering an observation.
      Throws:
      RemoteException - on network error