00001 /* 00002 * CacheEventFilter.hpp 00003 * 00004 * Copyright (c) 2000, 2014, 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_FILTER_HPP 00017 #define COH_CACHE_EVENT_FILTER_HPP 00018 00019 #include "coherence/lang.ns" 00020 00021 #include "coherence/io/pof/PofReader.hpp" 00022 #include "coherence/io/pof/PofWriter.hpp" 00023 #include "coherence/io/pof/PortableObject.hpp" 00024 00025 #include "coherence/util/filter/MapEventFilter.hpp" 00026 00027 COH_OPEN_NAMESPACE3(coherence,util,filter) 00028 00029 using coherence::io::pof::PofReader; 00030 using coherence::io::pof::PofWriter; 00031 using coherence::io::pof::PortableObject; 00032 00033 00034 /** 00035 * An extension of the {@link MapEventFilter} which allows selection of client 00036 * driven (natural) events, cache internal (synthetic) events, or both. 00037 * 00038 * @author rhl 2013.04.10 00039 */ 00040 class COH_EXPORT CacheEventFilter 00041 : public class_spec<CacheEventFilter, 00042 extends<MapEventFilter> > 00043 { 00044 friend class factory<CacheEventFilter>; 00045 00046 // ----- constructors --------------------------------------------------- 00047 00048 protected: 00049 /** 00050 * Default constructor (necessary for the PortableObject interface). 00051 */ 00052 CacheEventFilter(); 00053 00054 /** 00055 * Construct a CacheEventFilter that evaluates MapEvent objects based on the 00056 * specified combination of event types. 00057 * 00058 * @param vFilter the filter passed previously to a keySet() query method 00059 * @param nMaskSynthetic any combination of e_synthetic and e_natural 00060 */ 00061 CacheEventFilter(int32_t nMask, int32_t nMaskSynthetic); 00062 00063 /** 00064 * Construct a CacheEventFilter that evaluates MapEvent objects that would 00065 * affect the results of a keySet filter issued by a previous call to 00066 * coherence::util::QueryMap::keySet(coherence::util::Filter::View). 00067 * It is possible to easily implement <i>continuous query</i> functionality. 00068 * <p> 00069 * Using this constructor is equivalent to: 00070 * <tt> 00071 * CacheEventFilter::create(e_keyset, vFilter, nMaskSynthetic); 00072 * </tt> 00073 * 00074 * @param vFilter the filter passed previously to a keySet() query method 00075 * @param nMaskSynthetic any combination of e_synthetic and e_natural 00076 */ 00077 CacheEventFilter(Filter::View vFilter, int32_t nMaskSynthetic); 00078 00079 /** 00080 * Construct a CacheEventFilter that evaluates MapEvent objects based on the 00081 * specified combination of event types. 00082 * 00083 * @param nMask any combination of e_inserted, e_updated, e_deleted, 00084 * e_updated_entered, e_updated_within, and e_updated_left 00085 * @param vFilter the filter passed previously to a keySet() query method 00086 * @param nMaskSynthetic any combination of e_synthetic and e_natural 00087 */ 00088 CacheEventFilter(int32_t nMask, Filter::View vFilter, int32_t nMaskSynthetic); 00089 00090 private: 00091 /** 00092 * Blocked copy constructor. 00093 */ 00094 CacheEventFilter(const CacheEventFilter&); 00095 00096 // ----- Filter interface ----------------------------------------------- 00097 00098 public: 00099 /** 00100 * {@inheritDoc} 00101 */ 00102 virtual bool evaluate(Object::View v) const; 00103 00104 00105 // ----- PortableObject interface --------------------------------------- 00106 00107 public: 00108 /** 00109 * {@inheritDoc} 00110 */ 00111 virtual void readExternal(PofReader::Handle hIn); 00112 00113 /** 00114 * {@inheritDoc} 00115 */ 00116 virtual void writeExternal(PofWriter::Handle hOut) const; 00117 00118 00119 // ----- Object interface ----------------------------------------------- 00120 00121 public: 00122 /** 00123 * {@inheritDoc} 00124 */ 00125 virtual bool equals(Object::View v) const; 00126 00127 /** 00128 * {@inheritDoc} 00129 */ 00130 virtual size32_t hashCode() const; 00131 00132 00133 // ----- Describable interface ------------------------------------------ 00134 00135 public: 00136 /** 00137 * {@inheritDoc} 00138 */ 00139 virtual void outputDescription(std::ostream& out) const; 00140 00141 00142 // ----- constants ------------------------------------------------------ 00143 00144 public: 00145 /** 00146 * Bitmask to select synthetic events. 00147 */ 00148 static const int32_t e_synthetic = 0x1; 00149 00150 /** 00151 * Bitmask to select natural events. 00152 */ 00153 static const int32_t e_natural = 0x2; 00154 00155 00156 // ----- data members --------------------------------------------------- 00157 00158 protected: 00159 /** 00160 * Bitmask that selects whether to include synthetic, natural, or all events. 00161 */ 00162 int32_t m_nMaskSynthetic; 00163 }; 00164 00165 COH_CLOSE_NAMESPACE3 00166 00167 #endif // COH_CACHE_EVENT_FILTER_HPP