Class EventBasedCounter

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

public class EventBasedCounter extends Counter implements EventProducer, 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-2025 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
  • Constructor Details

    • EventBasedCounter

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

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

    • getEventListenerMap

      public EventListenerMap getEventListenerMap()
      Specified by:
      getEventListenerMap in interface EventProducer
    • initialize

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

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

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

      protected void fireEvents()
      Method that can be overridden to fire own events or additional events when registering an observation.