Oracle Coherence for C++ API
Release 3.6.0.0

E15728-01

coherence/net/cache/CacheEvent.hpp

00001 /*
00002 * CacheEvent.hpp
00003 *
00004 * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
00005 *
00006 * Oracle is a registered trademarks of Oracle Corporation and/or its
00007 * affiliates.
00008 *
00009 * This software is the confidential and proprietary information of Oracle
00010 * Corporation. You shall not disclose such confidential and proprietary
00011 * information and shall use it only in accordance with the terms of the
00012 * license agreement you entered into with Oracle.
00013 *
00014 * This notice may not be removed or altered.
00015 */
00016 #ifndef COH_CACHE_EVENT_HPP
00017 #define COH_CACHE_EVENT_HPP
00018 
00019 #include "coherence/lang.ns"
00020 
00021 #include "coherence/util/MapEvent.hpp"
00022 #include "coherence/util/ObservableMap.hpp"
00023 
00024 COH_OPEN_NAMESPACE3(coherence,net,cache)
00025 
00026 using coherence::util::MapEvent;
00027 using coherence::util::ObservableMap;
00028 
00029 
00030 /**
00031 * An extension of the MapEvent which allows to differentiate between client
00032 * driven (natural) events and cache internal (synthetic) events.
00033 * <p>
00034 * Consider a client code calling a remove() method for a cache. Quite
00035 * naturally it causes a corresponding ENTRY_DELETED event. However, the same
00036 * event could be as well caused by the client code calling put() forcing an
00037 * entry eviction.  Alternatively, the put() method called by client code
00038 * naturally causes either ENTRY_INSERTED or ENTRY_UPDATED event. However, the
00039 * same event could be as well caused by a client call to a get() method that
00040 * in turn forces an entry insertion by a cache loader.
00041 *
00042 * @author js  2008.06.06
00043 */
00044 class COH_EXPORT CacheEvent
00045     : public class_spec<CacheEvent,
00046         extends<MapEvent> >
00047     {
00048     friend class factory<CacheEvent>;
00049 
00050     // ----- constructors ---------------------------------------------------
00051 
00052     protected:
00053         /**
00054         * Create a new CacheEvent.
00055         *
00056         * @param hMap        the map on which the Event initially occurred
00057         * @param nId         the events id (ENTRY_INSERTED | ENTRY_UPDATED |
00058         *                    ENTRY_DELETED)
00059         * @param voKey       the key into the map
00060         * @param voValueOld  the old value (for update and delete events)
00061         * @param voValueNew  the new value (for insert and update events)
00062         * @param fSynthetic  true iff the event is caused by internal cache
00063         *                    processing such as eviction or loading
00064         */
00065         CacheEvent(ObservableMap::Handle hMap, int32_t nId,
00066                 Object::View voKey, Object::View voValueOld,
00067                 Object::View voValueNew, bool fSynthetic);
00068 
00069 
00070     // ----- CacheEvent interface -------------------------------------------
00071 
00072     public:
00073         /**
00074         * Return true iff this event is caused by internal cache processing
00075         * such as eviction or loading.
00076         *
00077         * @return true iff this event is caused by internal cache processing
00078         */
00079         virtual bool isSynthetic() const;
00080 
00081 
00082     // ----- Describable interface ------------------------------------------
00083 
00084     public:
00085         /**
00086         * {@inheritDoc}
00087         */
00088         virtual void outputDescription(std::ostream& out) const;
00089 
00090 
00091     // ----- data members ---------------------------------------------------
00092 
00093     protected:
00094         /**
00095         * Event cause flag.
00096         */
00097         bool m_fSynthetic;
00098     };
00099 
00100 COH_CLOSE_NAMESPACE3
00101 
00102 #endif // COH_CACHE_EVENT_HPP
00103 
Copyright © 2000, 2010, Oracle and/or its affiliates. All rights reserved.