#include <coherence/util/MapListenerSupport.hpp>
Inherits Object.
Public Types | |
| typedef spec::Handle | Handle |
| MapListenerSupport Handle definition. | |
| typedef spec::View | View |
| MapListenerSupport View definition. | |
| typedef spec::Holder | Holder |
| MapListenerSupport Holder definition. | |
Public Member Functions | |
| virtual void | addListener (MapListener::Handle hListener, Filter::View vFilter, bool fLite) |
| Add a map listener that receives events based on a filter evaluation. | |
| virtual void | addListener (MapListener::Handle hListener, Object::View vKey, bool fLite) |
| Add a map listener for a specific key. | |
| virtual void | removeListener (MapListener::View vListener, Filter::View vFilter) |
| Remove a map listener that previously signed up for events based on a filter evaluation. | |
| virtual void | removeListener (MapListener::View vListener, Object::View vKey) |
| Remove a map listener that previously signed up for events about a specific key. | |
| virtual void | clear () |
| Remove all signed up listeners. | |
| virtual bool | isEmpty () const |
| Checks whether or not this MapListenerSupport object contains any listeners. | |
| virtual bool | isEmpty (Filter::View vFilter) const |
| Checks whether or not this MapListenerSupport object contains any listeners for a given filter. | |
| virtual bool | isEmpty (Object::View vKey) const |
| Checks whether or not this MapListenerSupport object contains any listeners for a given key. | |
| virtual bool | containsStandardListeners (Filter::View vFilter) const |
| Checks whether or not this MapListenerSupport object contains any standard (not lite) listeners for a given filter. | |
| virtual bool | containsStandardListeners (Object::View vKey) const |
| Checks whether or not this MapListenerSupport object contains any standard (not lite) listeners for a given key. | |
| virtual Set::View | getFilterSet () const |
| Obtain a set of all filters that have assosiated global listeners. | |
| virtual Set::View | getKeySet () const |
| Obtain a set of all keys that have assosiated key listeners. | |
| virtual Listeners::View | getListeners (Filter::View vFilter) const |
| Obtain the Listeners object for a given filter. | |
| virtual Listeners::View | getListeners (Object::View vKey) const |
| Obtain the Listeners object for a given key. | |
| virtual Listeners::View | collectListeners (MapEvent::View vEvent) |
| Collect all Listeners that should be notified for a given event. | |
| virtual void | fireEvent (MapEvent::Handle hEvent, bool fStrict) |
| Fire the specified map event. | |
|
virtual TypedHandle < const String > | toString () const |
| Output a human-readable description of this Object to the given stream. Note that when overriding this method the return type must be TypedHandle<const String> rather then String::View. These two types are assignment compatible but not equivalent and declaring the override with String::View will not be a compatible override. coherence::lang::operator<<(std::ostream, Object::View) is defined and will call into the toString 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 and is generally how toString() will be implemented.
Object::View vKey = ... Object::View vValue = ... std::cout << vKey << " = " << vValue << std::endl; String::View vs = COH_TO_STRING(vKey << " = " << vValue); The COH_TO_STRING macro is also the most common way to implement the toString method. For example:
virtual TypedHandle<const String> Person::toString() const { return COH_TO_STRING("Name: " << f_sName << " SSN: " << f_nSSN); }
| |
Static Public Member Functions | |
| static MapEvent::Handle | convertEvent (MapEvent::View vEvent, ObservableMap::Handle hmapConv, Converter::View vConvKey=NULL, Converter::View vConvVal=NULL) |
| Convert the specified map event into another MapEvent that ensures the lazy event data conversion using the specified converters. | |
| static MapEvent::Handle | enrichEvent (MapEvent::Handle hEvent, Listeners::View vListeners) |
| Transform the given MapEvent into a FilterEvent if it is not already a FilterEvent and there are matching filters associated with the specified Listeners object. | |
| static MapEvent::View | unwrapEvent (MapEvent::View vEvent) |
| Unwrap the specified map event and return the underlying source event. | |
| static bool | isPrimingListener (MapListener::Handle listener) |
| Check if the given listener is a PrimingListener or if it wraps one. | |
Protected Types | |
| enum | Plan |
| Optimization Plan enum. | |
Protected Member Functions | |
| MapListenerSupport () | |
| Create a new MapListenerSupport. | |
Static Protected Member Functions | |
| static bool | evaluateEvent (Filter::View vFilter, MapEvent::View vEvent) |
| Evaluate whether or not the specified event should be delivered to the listener associated with the specified filter. | |
| static bool | isTransformedEvent (MapEvent::View vEvent) |
| Return true iff the specified event represents a transformed CacheEvent. | |
| static void | addSafeListener (Map::Handle hmapListeners, Object::View vKey, MapListener::Handle hListener) |
| Ensure that the specified map has a Listeners object assosiated with the specified key and add the specified listener to it. | |
| static void | addSafeListener (Map::Handle hMapListeners, Filter::View vAnyFilter, MapListener::Handle hListener) |
| Ensure that the specified map has a Listeners object associated with the specified Filter and add the specified listener to it. | |
| static void | removeSafeListener (Map::Handle hmapListeners, Object::View vKey, MapListener::View vListener) |
| Remove the specified listener from the Listeners object assosiated with the specified key. | |
| static void | addListenerState (Map::Handle hmapStandardListeners, Object::View vKey, MapListener::Handle hListener, bool fLite) |
| Add a state information (lite or standard) associated with specified key and listener. | |
| static void | removeListenerState (Map::Handle hmapStandardListeners, Object::View vKey, MapListener::View vListener) |
| Remove a state information (lite or standard) assosiated with specified key and listener. | |
| static MapListener::Handle | unwrapListener (MapListener::Handle hListener) |
| Unwrap the specified map listener and return the underlying map listener. | |
Protected Attributes | |
| MemberHandle< Map > | m_hmapListeners |
| The collections of MapListener objects that have signed up for notifications from an ObservableMap implementation keyed by the corresponding Filter objects. | |
| MemberHandle< Map > | m_hmapKeyListeners |
| The collections of MapListener objects that have signed up for key based notifications from an ObservableMap implementation keyed by the corresponding key objects. | |
| MemberHandle< Map > | m_hmapStandardListeners |
| The subset of standard (not lite) global listeners. | |
| MemberHandle< Map > | m_hmapStandardKeyListeners |
| The subset of standard (not lite) key listeners. | |
| Plan | m_optimizationPlan |
| The optimization plan which indicates the fastest way to put together a set of listeners. | |
| MemberView< Listeners > | m_vListenersCached |
| A cached set of Listeners. | |
Classes | |
| class | FilterEvent |
| An extension of the CacheEvent which may carry no values (old or new), but instead holds an array of Filter objects being the "cause" of the event. More... | |
| class | PrimingListener |
| A tag interface indicating that tagged MapListener implementation has to receive the MapEvent notifications in a synchronous manner for lite events (carrying only a key). More... | |
| class | SynchronousListener |
| A tag interface indicating that tagged MapListener implementation has to receive the MapEvent notifications in a synchronous manner. More... | |
| class | WrapperPrimingListener |
| A wrapper class that turns the specified MapListener into a Priminglistener. More... | |
| class | WrapperSynchronousListener |
| A wrapper class that turns the specified MapListener into a synchronous listener. More... | |
| virtual void addListener | ( | MapListener::Handle | hListener, | |
| Filter::View | vFilter, | |||
| bool | fLite | |||
| ) | [virtual] |
Add a map listener that receives events based on a filter evaluation.
| hListener | the listener to add | |
| vFilter | a filter that will be passed MapEvent objects to select from; a MapEvent will be delivered to the listener only if the filter evaluates to true for that MapEvent; NULL is equivalent to a filter that alway returns true | |
| fLite | true to indicate that the MapEvent objects do not have to include the OldValue and NewValue property values in order to allow optimizations |
| virtual void addListener | ( | MapListener::Handle | hListener, | |
| Object::View | vKey, | |||
| bool | fLite | |||
| ) | [virtual] |
Add a map listener for a specific key.
| hListener | the listener to add | |
| vKey | the key that identifies the entry for which to raise events | |
| fLite | true to indicate that the MapEvent objects do not have to include the OldValue and NewValue property values in order to allow optimizations |
| virtual void removeListener | ( | MapListener::View | vListener, | |
| Filter::View | vFilter | |||
| ) | [virtual] |
| virtual void removeListener | ( | MapListener::View | vListener, | |
| Object::View | vKey | |||
| ) | [virtual] |
Remove a map listener that previously signed up for events about a specific key.
| vListener | the listener to remove | |
| vKey | the key that identifies the entry for which to raise events |
| virtual bool isEmpty | ( | ) | const [virtual] |
Checks whether or not this MapListenerSupport object contains any listeners.
| virtual bool isEmpty | ( | Filter::View | vFilter | ) | const [virtual] |
Checks whether or not this MapListenerSupport object contains any listeners for a given filter.
| vFilter | the filter |
| virtual bool isEmpty | ( | Object::View | vKey | ) | const [virtual] |
Checks whether or not this MapListenerSupport object contains any listeners for a given key.
| vKey | the key |
| virtual bool containsStandardListeners | ( | Filter::View | vFilter | ) | const [virtual] |
Checks whether or not this MapListenerSupport object contains any standard (not lite) listeners for a given filter.
| vFilter | the filter |
| virtual bool containsStandardListeners | ( | Object::View | vKey | ) | const [virtual] |
Checks whether or not this MapListenerSupport object contains any standard (not lite) listeners for a given key.
| vKey | the key |
| virtual Set::View getFilterSet | ( | ) | const [virtual] |
Obtain a set of all filters that have assosiated global listeners.
Note: The returned value must be treated as an immutable.
| virtual Set::View getKeySet | ( | ) | const [virtual] |
Obtain a set of all keys that have assosiated key listeners.
Note: The returned value must be treated as an immutable.
| virtual Listeners::View getListeners | ( | Filter::View | vFilter | ) | const [virtual] |
| virtual Listeners::View getListeners | ( | Object::View | vKey | ) | const [virtual] |
| virtual Listeners::View collectListeners | ( | MapEvent::View | vEvent | ) | [virtual] |
| virtual void fireEvent | ( | MapEvent::Handle | hEvent, | |
| bool | fStrict | |||
| ) | [virtual] |
Fire the specified map event.
| hEvent | the map event | |
| fStrict | if true then any RuntimeException thrown by event handlers stops all further event processing and the exception is re-thrown; if false then all exceptions are logged and the process continues |
| static MapEvent::Handle convertEvent | ( | MapEvent::View | vEvent, | |
| ObservableMap::Handle | hmapConv, | |||
| Converter::View | vConvKey = NULL, |
|||
| Converter::View | vConvVal = NULL | |||
| ) | [static] |
Convert the specified map event into another MapEvent that ensures the lazy event data conversion using the specified converters.
| vEvent | the map event | |
| hmapConv | the source for the converted event | |
| vConvKey | (optional) the key Converter | |
| vConvVal | (optional) the value converter |
| static MapEvent::Handle enrichEvent | ( | MapEvent::Handle | hEvent, | |
| Listeners::View | vListeners | |||
| ) | [static] |
Transform the given MapEvent into a FilterEvent if it is not already a FilterEvent and there are matching filters associated with the specified Listeners object.
| static MapEvent::View unwrapEvent | ( | MapEvent::View | vEvent | ) | [static] |
Unwrap the specified map event and return the underlying source event.
| vEvent | the event to unwrap |
| static bool isPrimingListener | ( | MapListener::Handle | listener | ) | [static] |
Check if the given listener is a PrimingListener or if it wraps one.
| listener | Map listener to check |
| static bool evaluateEvent | ( | Filter::View | vFilter, | |
| MapEvent::View | vEvent | |||
| ) | [static, protected] |
| static bool isTransformedEvent | ( | MapEvent::View | vEvent | ) | [static, protected] |
Return true iff the specified event represents a transformed CacheEvent.
| vEvent | the event to test |
| static void addSafeListener | ( | Map::Handle | hmapListeners, | |
| Object::View | vKey, | |||
| MapListener::Handle | hListener | |||
| ) | [static, protected] |
Ensure that the specified map has a Listeners object assosiated with the specified key and add the specified listener to it.
| hmapListeners | map of listeners | |
| vKey | key of the listener | |
| hListener | the listener to add |
| static void addSafeListener | ( | Map::Handle | hMapListeners, | |
| Filter::View | vAnyFilter, | |||
| MapListener::Handle | hListener | |||
| ) | [static, protected] |
| static void removeSafeListener | ( | Map::Handle | hmapListeners, | |
| Object::View | vKey, | |||
| MapListener::View | vListener | |||
| ) | [static, protected] |
Remove the specified listener from the Listeners object assosiated with the specified key.
| hmapListeners | map of listeners | |
| vKey | key of the listener | |
| vListener | the listener to remove |
| static void addListenerState | ( | Map::Handle | hmapStandardListeners, | |
| Object::View | vKey, | |||
| MapListener::Handle | hListener, | |||
| bool | fLite | |||
| ) | [static, protected] |
Add a state information (lite or standard) associated with specified key and listener.
| hmapStandardListeners | map of standard listeners | |
| vKey | key of the listener | |
| hListener | the listener to add | |
| fLite | true to indicate that the MapEvent objects do not have to include the OldValue and NewValue property values |
| static void removeListenerState | ( | Map::Handle | hmapStandardListeners, | |
| Object::View | vKey, | |||
| MapListener::View | vListener | |||
| ) | [static, protected] |
Remove a state information (lite or standard) assosiated with specified key and listener.
| hmapStandardListeners | map of standard listeners | |
| vKey | key of the listener | |
| vListener | the listener to remove |
| static MapListener::Handle unwrapListener | ( | MapListener::Handle | hListener | ) | [static, protected] |
Unwrap the specified map listener and return the underlying map listener.
| hL | istener the listener to unwrap |
MemberHandle<Map> m_hmapStandardListeners [protected] |
The subset of standard (not lite) global listeners.
The keys are the Filter objects, the values are sets of corresponding standard listeners.
MemberHandle<Map> m_hmapStandardKeyListeners [protected] |
The subset of standard (not lite) key listeners.
The keys are the key objects, the values are sets of corresponding standard listeners.