ioeventfilter.rb

Path: lib/mues/filters/ioeventfilter.rb  (CVS)
Last Update: Sat Aug 18 22:54:10 -0700 2007

This file contains the MUES::IOEventFilter class, which is an abstract base class for filter objects in a MUES::IOEventStream. The filters act as links in a Chain of Responsibility (patterndigest.com/patterns/ChainOfResponsibili.html), acting on the contents of MUES::IOEvent objects which are passed up and down the stream, modifying them, creating other events based on them, changing their own internal state or the state of an associated object based on them, or ignoring them, depending on the task which the filter is supposed to accomplish.

This class also fulfills the Subject role of the <strong>Observer</strong> design pattern (patterndigest.com/patterns/Observer.html), with the MUES::IOEventStream as the Observer part. Filters notify the streams they are associated with when they have pending events.

When you define a derivative of IOEventFilter, you will need to define a class constant called ‘DefaultSortPosition’, which is a number between 0 and 1000, inclusive. This number is used by the Comparable interface to determine the order in which filters should be sorted, and therefore the order in which they are given the IOEvents which have entered the stream. Lower values means the filter will sort more towards the <strong>output</strong> side of the stream, higher values sort towards the <strong>input</strong> side, and middle values generally act as modifying, macro, or duplicative filters.

You can also pass a different sort order value for a specific instance to this class‘s initialize method via super().

Synopsis

  require 'mues/filters/ioeventfilter'

  class MyFilter < MUES::IOEventFilter
    DefaultSortPosition = 550
    ...
    def handleInputEvents( *events )
      ...
    end

    def handleOutputEvents( *events )
      ...
    end
  end

Subversion ID

$Id: ioeventfilter.rb 1215 2004-06-14 06:02:09Z deveiant $

Authors

  • Michael Granger <ged@FaerieMUD.org>

Copyright

Copyright (c) 2000-2003 The FaerieMUD Consortium. All rights reserved.

This module is free software. You may use, modify, and/or redistribute this software under the terms of the Perl Artistic License. (See language.perl.com/misc/Artistic.html)

THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.

Required files

observer   mues/object   mues/mixins   mues/events   mues/exceptions  

[Validate]