All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.sciss.lucre.impl.IDummyEvent.scala Maven / Gradle / Ivy

Go to download

Extension of Scala-STM, adding optional durability layer, and providing API for confluent and reactive event layers

The newest version!
/*
 *  IDummyEvent.scala
 *  (Lucre 4)
 *
 *  Copyright (c) 2009-2024 Hanns Holger Rutz. All rights reserved.
 *
 *  This software is published under the GNU Affero General Public License v3+
 *
 *
 *  For further information, please contact Hanns Holger Rutz at
 *  [email protected]
 */

package de.sciss.lucre
package impl

import de.sciss.model.Change

object IDummyEvent {
  /** This method is cheap. */
  def apply[T <: Exec[T], A](): IEvent[T, A] = anyDummy.asInstanceOf[IEvent[T, A]]

  def change[T <: Exec[T], A]: IChangeEvent[T, A] = anyChangeDummy.asInstanceOf[IChangeEvent[T, A]]

  private val anyDummy        = new Impl       [AnyExec]
  private val anyChangeDummy  = new ChangeImpl [AnyExec]

  private final class Impl[T <: Exec[T]] extends IEvent[T, Any] {
    override def toString = "event.IDummy"

    def --->(sink: IEvent[T, Any])(implicit tx: T): Unit = ()
    def -/->(sink: IEvent[T, Any])(implicit tx: T): Unit = ()

    private[lucre] def pullUpdate(pull: IPull[T])(implicit tx: T): Option[Any] = None

    def react(fun: T => Any => Unit)(implicit tx: T): Disposable[T] = Disposable.empty[T]
  }

  private final class ChangeImpl[T <: Exec[T]] extends IChangeEvent[T, Any] {
    override def toString = "event.IDummy"

    def --->(sink: IEvent[T, Any])(implicit tx: T): Unit = ()
    def -/->(sink: IEvent[T, Any])(implicit tx: T): Unit = ()

    private[lucre] def pullChange(pull: IPull[T])(implicit tx: T, phase: IPull.Phase): Any = ()

    def react(fun: T => Change[Any] => Unit)(implicit tx: T): Disposable[T] = Disposable.empty[T]
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy