00001 /* 00002 * NotFilter.hpp 00003 * 00004 * Copyright (c) 2000, 2013, 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_NOT_FILTER_HPP 00017 #define COH_NOT_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 #include "coherence/util/Filter.hpp" 00025 #include "coherence/util/Map.hpp" 00026 #include "coherence/util/filter/EntryFilter.hpp" 00027 #include "coherence/util/filter/IndexAwareFilter.hpp" 00028 00029 COH_OPEN_NAMESPACE3(coherence,util,filter) 00030 00031 using coherence::io::pof::PofReader; 00032 using coherence::io::pof::PofWriter; 00033 using coherence::io::pof::PortableObject; 00034 00035 /** 00036 * Provide for "pluggable" conditional behavior that negates. 00037 * 00038 * @author djl 2008.03.02 00039 */ 00040 class COH_EXPORT NotFilter 00041 : public class_spec<NotFilter, 00042 extends<Object>, 00043 implements<IndexAwareFilter, PortableObject> > 00044 { 00045 friend class factory<NotFilter>; 00046 00047 // ----- constructors --------------------------------------------------- 00048 00049 protected: 00050 /** 00051 * Default constructor (necessary for the PortableObject interface). 00052 */ 00053 NotFilter(); 00054 00055 /** 00056 * Create and return a Handle to a new Object instance. 00057 */ 00058 NotFilter(Filter::View hFilter); 00059 00060 00061 // ----- Entry Filter interface ----------------------------------------- 00062 00063 public: 00064 /** 00065 * Apply the test to a Map::Entry and negate the result. 00066 * 00067 * @param vEntry the Map::Entry to evaluate; never NULL 00068 * 00069 * @return false if the test passes, true otherwise 00070 */ 00071 virtual bool evaluateEntry(Map::Entry::View vEntry) const; 00072 00073 00074 // ----- Filter interface ----------------------------------------------- 00075 00076 public: 00077 /** 00078 * Apply the test to the object and negate the result. 00079 * 00080 * @param v the object to test 00081 * 00082 * @return true if the test passes, false otherwise 00083 */ 00084 virtual bool evaluate(Object::View v) const; 00085 00086 00087 // ----- IndexAwareFilter interface ------------------------------------- 00088 00089 public: 00090 /** 00091 * {@inheritDoc} 00092 */ 00093 virtual size32_t calculateEffectiveness(Map::View vMapIndexes, 00094 Set::View vSetKeys) const; 00095 00096 /** 00097 * {@inheritDoc} 00098 */ 00099 virtual Filter::View applyIndex(Map::View vMapIndexes, 00100 Set::Handle hSetKeys) const; 00101 00102 00103 // ----- helpers -------------------------------------------------------- 00104 00105 protected: 00106 /** 00107 * Get a Map of the available non-partial indexes from the given Map of all 00108 * available indexes. 00109 * 00110 * @param vMapIndexes the available MapIndex objects keyed by the 00111 * related ValueExtractor; read-only 00112 * 00113 * @return a Map of the available non-partial MapIndex objects 00114 */ 00115 virtual Map::View getNonPartialIndexes(Map::View vMapIndexes) const; 00116 00117 00118 // ----- PortableObject interface --------------------------------------- 00119 00120 public: 00121 /** 00122 * Restore the contents of a user type instance by reading its state 00123 * using the specified PofReader. 00124 * 00125 * @param hIn the PofReader from which to read the object's state 00126 */ 00127 virtual void readExternal(PofReader::Handle hIn); 00128 00129 /** 00130 * Save the contents of a POF user type instance by writing its state 00131 * using the specified PofWriter. 00132 * 00133 * @param hOut the PofWriter to which to write the object's state 00134 */ 00135 virtual void writeExternal(PofWriter::Handle hOut) const; 00136 00137 00138 // ----- Object interface ----------------------------------------------- 00139 00140 public: 00141 /** 00142 * Compare the NotFilter with another object to determine equality. 00143 * 00144 * @param v the object to compare with 00145 * 00146 * @return true iff this NotFilter and the passed object are equivalent 00147 * NotFilter objects 00148 */ 00149 virtual bool equals(Object::View v) const; 00150 00151 /** 00152 * {@inheritDoc} 00153 */ 00154 virtual size32_t hashCode() const; 00155 00156 /** 00157 * Output a human-readable description of this Object to the given 00158 * stream. 00159 * 00160 * @param out the stream used to output the description 00161 */ 00162 virtual void toStream(std::ostream& out) const; 00163 00164 00165 // ----- data member accessors ------------------------------------------ 00166 00167 public: 00168 /** 00169 * Obtain the Filter whose results are negated by this filter. 00170 * 00171 * @return the filter whose results are negated by this filter 00172 */ 00173 virtual Filter::View getFilter() const; 00174 00175 00176 // ----- data members --------------------------------------------------- 00177 00178 private: 00179 /** 00180 * The Filter whose results are negated by this filter. 00181 */ 00182 FinalView<Filter> f_vFilter; 00183 }; 00184 00185 COH_CLOSE_NAMESPACE3 00186 00187 #endif // COH_NOT_FILTER_HPP