CaptureListener-class {Proc4}R Documentation

Class "CaptureListener"

Description

This listener simply takes its messages and adds them to a list. It is is mainly used for testing the message system.

Details

This listener simply takes all messages and pushes them onto the messages field. The messages field is the complete list of received messages, most recent to most ancient. The method lastMessage() returns the most recent message.

Extends

This class implements the Listener interface.

All reference classes extend and inherit methods from "envRefClass".

Methods

isListener

signature(x = "CaptureListener"): returns true.

receiveMessage

signature(x = "CaptureListener"): If the message is in the messSet, it adds the message to the message list. (See details)

Fields

messages:

Object of class list the list of messages in reverse chronological order.

Class-Based Methods

lastMessage():

Returns the most recent message.

receiveMessage(mess):

Does the work of inserting the message. See Details.

initialize(messages, ...):

Sets the default values for the fields.

Author(s)

Russell Almond

References

This is an example of the observer design pattern. https://en.wikipedia.org/wiki/Observer_pattern.

See Also

Listener, P4Message, CaptureListener, UpdateListener, UpsertListener, InjectionListener, TableListener,

Examples


mess1 <- P4Message(app="default",uid="Phred",context="Down Hill",
                   sender="EABN",mess="Statistics",
                   details=list("Physics_EAP"=0.5237,"Physics_Mode"="High"))

cl <- CaptureListener()
receiveMessage(cl,mess1)
stopifnot(all.equal(mess1,cl$lastMessage()))


[Package Proc4 version 0.4-6 Index]