Oracle Coherence for C++ API
Release 3.6.0.0
E15728-01

- Main Page
- Namespaces
- Classes
- Files

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# MapEventFilter Class Reference

`#include <coherence/util/filter/MapEventFilter.hpp>`

Inherits Object, PortableObject, and Filter.

List of all members.

## Detailed Description

Filter which evaluates the content of a MapEvent object according to the specified criteria.

This filter is intended to be used by various ObservableMap listeners that are interested in particular subsets of MapEvent notifications emitted by the map.

Usage examples:

- a filter that evaluates to true if an Employee object is inserted into a cache with a value of Married property set to true.

         MapEventFilter::create(MapEventFilter.E_INSERT,
             EqualsFilter::create(ReflectionExtractor::create("isMarried"),
                     Boolean::create(true));

- a filter that evaluates to true if any object is removed from a cache.

         MapEventFilter::create(MapEventFilter::E_DELETE);

- a filter that evaluates to true if there is an update to an Employee object where either an old or new value of LastName property equals to "Smith"

         MapEventFilter::create(MapEventFilter::E_UPDATE,
             EqualsFilter::create(ReflectionExtractor::create("LastName"),
                     String::create("Smith")));

- a filter that is used to keep a cached keySet result based on some map filter up-to-date.

         Set::View    setKeys   = HashSet::create();
         Filter::View filterEvt = MapEventFilter::create(filterMap);
         MapListener::Handle listener = MapListener::create();
         map.addMapListener(listener, filterEvt, true);
         setKeys.addAll(map.keySet(filterMap));

see ValueChangeEventFilter

Author:
  djl 2008.05.19

## Public Types
typedef spec::Handle | Handle
| MapEventFilter Handle definition.
typedef spec::View | View
| MapEventFilter View definition.
typedef spec::Holder | Holder
| MapEventFilter Holder definition.
## Public Member Functions
virtual bool | evaluate (Object::View v) const
  | Apply the test to the object. Parameters:
  | v | the object to test
Returns: true if the test passes, false otherwise
virtual void | readExternal (PofReader::Handle hIn)
virtual void | writeExternal (PofWriter::Handle hOut) const
virtual bool | equals (Object::View v) const
virtual size32_t | hashCode () const
| Return a hash code value for the Object. This method is supported for the benefit of hash-based containers. The general contract of `hashCode` is: Whenever it is invoked on the same Object more than once during an execution of an application, the `hashCode` method must consistently return the same value, provided no information used in `equals` comparisons on the object is modified. This value need not remain consistent from one execution of an application to another execution of the same application. If two Objects are equal according to the `equals` method, then calling the `hashCode` method on each of the two Objects must produce the same value. It is not required that if two Objects are unequal according to the `equals` method, then calling the `hashCode` method on each of the two objects must produce distinct results. However, the programmer should be aware that producing distinct results for unequal objects may improve the performance of hash-based containers. The default implementation is identity based. Returns: a hash code value for this Object
virtual void | toStream (std::ostream &out) const
| Output a human-readable description of this Object to the given stream. coherence::lang::operator<<(std::ostream, Object::View) is defined and will call into the toStream method, to output Objects. If a managed String object is desired, the COH_TO_STRING macro can be used to build up a String from streamable contents.
     Object::View vKey   = ...
     Object::View vValue = ...
     std::cout << vKey << " = " << vValue << std::endl;

     String::Handle hs = COH_TO_STRING(vKey << " = " << vValue);
  Parameters:
  | out | the stream used to output the description
virtual int32_t | getEventMask () const
| Obtain the event mask.
virtual Filter::View | getFilter () const
| Obtain the Filter object used to evaluate the event value(s).
## Static Public Member Functions
static int32_t | getMask (size32_t iEvent)
| Event id to event mask translation.
## Static Public Attributes
static const int32_t | E_INSERTED
| This value indicates that MapEvent::ENTRY_INSERTED ENTRY_INSERTED} events should be evaluated.
static const int32_t | E_UPDATED
| This value indicates that MapEvent::ENTRY_UPDATED ENTRY_UPDATED events should be evaluated.
static const int32_t | E_DELETED
| This value indicates that MapEvent::ENTRY_DELETED ENTRY_DELETED events should be evaluated.
static const int32_t | E_UPDATED_ENTERED
| This value indicates that MapEvent::ENTRY_UPDATED ENTRY_UPDATED events should be evaluated, but only if filter evaluation is false for the old value and true for the new value.
static const int32_t | E_UPDATED_LEFT
| This value indicates that MapEvent::ENTRY_UPDATED ENTRY_UPDATED events should be evaluated, but only if filter evaluation is true for the old value and false for the new value.
static const int32_t | E_UPDATED_WITHIN
| This value indicates that MapEvent::ENTRY_UPDATED ENTRY_UPDATED events should be evaluated, but only if filter evaluation is true for both the old and the new value.
static const int32_t | E_ALL
| This value indicates that all events should be evaluated.
static const int32_t | E_KEYSET
| This value indicates that all events that would affect the result of a coherence::util::QueryMap::keySet(coherence::util::Filter) query should be evaluated.
## Protected Member Functions
| MapEventFilter ()
| Default constructor (necessary for the PortableObject interface).
| MapEventFilter (Filter::View vFilter)
| Construct a MapEventFilter that evaluates MapEvent objects that would affect the results of a keySet filter issued by a previous call to coherence::util::QueryMap::keySet(coherence::util::Filter::View).
| MapEventFilter (int32_t nMask, Filter::View vFilter=NULL)
| Construct a MapEventFilter that evaluates MapEvent objects based on the specified combination of event types.
## Protected Attributes
int32_t | m_nMask
| The event mask.
MemberView< Filter > | m_vFilter
| The event value(s) filter.

## Constructor & Destructor Documentation

MapEventFilter | ( | Filter::View | vFilter | ) | `[protected]`

Construct a MapEventFilter that evaluates MapEvent objects that would affect the results of a keySet filter issued by a previous call to coherence::util::QueryMap::keySet(coherence::util::Filter::View).

It is possible to easily implement continuous query functionality.

Using this constructor is equivalent to: `MapEventFilter::create(E_KEYSET, filter);`

Parameters:

  | vFilter | the filter passed previously to a keySet() query method

MapEventFilter | ( | int32_t | nMask,
|  | Filter::View | vFilter = `NULL` |
| ) |  |  | `[protected]`

Construct a MapEventFilter that evaluates MapEvent objects based on the specified combination of event types.

Parameters:

  | nMask | combination of any of the E_* values
  | vFilter | (optional) the filter used for evaluating event values

## Member Function Documentation

virtual int32_t getEventMask | ( |  | ) | const `[virtual]`

Obtain the event mask.

The mask value is concatenation of any of the E_* values.

Returns:
  the event mask

virtual Filter::View getFilter | ( |  | ) | const `[virtual]`

Obtain the Filter object used to evaluate the event value(s).

Returns:
  the filter used to evaluate the event value(s)

static int32_t getMask | ( | size32_t | iEvent | ) | `[static]`

Event id to event mask translation.

Parameters:

  | iEvent | the event index

Returns:
  the translated event mask

## Member Data Documentation

const int32_t E_INSERTED `[static]`

This value indicates that MapEvent::ENTRY_INSERTED ENTRY_INSERTED} events should be evaluated.

The event will be fired if there is no filter specified or the filter evaluates to true for a new value.

const int32_t E_UPDATED `[static]`

This value indicates that MapEvent::ENTRY_UPDATED ENTRY_UPDATED events should be evaluated.

The event will be fired if there is no filter specified or the filter evaluates to true when applied to either old or new value.

const int32_t E_DELETED `[static]`

This value indicates that MapEvent::ENTRY_DELETED ENTRY_DELETED events should be evaluated.

The event will be fired if there is no filter specified or the filter evaluates to true for an old value.

const int32_t E_UPDATED_ENTERED `[static]`

This value indicates that MapEvent::ENTRY_UPDATED ENTRY_UPDATED events should be evaluated, but only if filter evaluation is false for the old value and true for the new value.

This corresponds to an item that was not in a keySet filter result changing such that it would now be in that keySet filter result.

const int32_t E_UPDATED_LEFT `[static]`

This value indicates that MapEvent::ENTRY_UPDATED ENTRY_UPDATED events should be evaluated, but only if filter evaluation is true for the old value and false for the new value.

This corresponds to an item that was in a keySet filter result changing such that it would no longer be in that keySet filter result.

const int32_t E_UPDATED_WITHIN `[static]`

This value indicates that MapEvent::ENTRY_UPDATED ENTRY_UPDATED events should be evaluated, but only if filter evaluation is true for both the old and the new value.

This corresponds to an item that was in a keySet filter result changing but not leaving the keySet filter result.

The documentation for this class was generated from the following file:

- coherence/util/filter/MapEventFilter.hpp

Copyright © 2000, 2010, Oracle and/or its affiliates. All rights reserved.