Oracle® Fusion Middleware C++ API Reference for Oracle Coherence
12c (12.2.1.3.0)

E80355-01

coherence/util/aggregator/AbstractComparableAggregator.hpp

00001 /*
00002 * AbstractComparableAggregator.hpp
00003 *
00004 * Copyright (c) 2000, 2017, 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_ABSTRACT_COMPARABLE_AGGREGATOR_HPP
00017 #define COH_ABSTRACT_COMPARABLE_AGGREGATOR_HPP
00018 
00019 #include "coherence/lang.ns"
00020 
00021 #include "coherence/util/aggregator/AbstractAggregator.hpp"
00022 #include "coherence/util/Comparator.hpp"
00023 #include "coherence/util/ValueExtractor.hpp"
00024 
00025 COH_OPEN_NAMESPACE3(coherence,util,aggregator)
00026 
00027 using coherence::io::pof::PofReader;
00028 using coherence::io::pof::PofWriter;
00029 using coherence::io::pof::PortableObject;
00030 
00031 using coherence::util::Comparator;
00032 using coherence::util::ValueExtractor;
00033 
00034 
00035 /**
00036 * Abstract aggregator that processes values extracted from a set of entries
00037 * in a Map, with knowledge of how to compare those values. There are two ways
00038 * to use the AbstractComparableAggregator:
00039 * <ul>
00040 * <li>All the extracted objects must implement <tt>Comparable</tt>, or</li>
00041 * <li>The AbstractComparableAggregator has to be provided with a
00042 * <tt>Comparator object</tt>.</li>
00043 * </ul>
00044 * If the set of entries passed to <tt>aggregate</tt> is empty, a
00045 * <tt>NULL</tt> result is returned.
00046 *
00047 * @author djl/pp  2008.05.09
00048 */
00049 class COH_EXPORT AbstractComparableAggregator
00050     : public abstract_spec<AbstractComparableAggregator,
00051         extends<AbstractAggregator> >
00052     {
00053     // ----- constructors ---------------------------------------------------
00054 
00055     protected:
00056         /**
00057         * @internal
00058         */
00059         AbstractComparableAggregator();
00060 
00061         /**
00062         * Construct an AbstractComparableAggregator object.
00063         *
00064         * @param vExtractor   the extractor that provides an object to be 
00065         *                     compared
00066         * @param vComparator  the comparator used to compare the extracted
00067         *                     object, if NULL then the extracted object must
00068         *                     implement Comparable
00069         */
00070         AbstractComparableAggregator(ValueExtractor::View vExtractor,
00071                 Comparator::View vComparator = NULL);
00072 
00073         /**
00074         * Construct an AbstractComparableAggregator that will aggregate 
00075         * values extracted from a set of InvocableMap::Entry objects.
00076         *
00077         * @param vsMethod     the name of the method that could be 
00078         *                     invoked via reflection and that returns values 
00079         *                     to aggregate; this parameter can also be a 
00080         *                     dot-delimited sequence of method names which 
00081         *                     would result in an aggregator based on the
00082         *                     ChainedExtractor that is based on an array of
00083         *                     corresponding ReflectionExtractor objects
00084         * @param vComparator  the comparator used to compare the extracted
00085         *                     object, if NULL then the extracted object must
00086         *                     implement Comparable
00087         *
00088         * @since Coherence 12.1.2
00089         */
00090         AbstractComparableAggregator(String::View vsMethod,
00091                 Comparator::View vComparator = NULL);
00092 
00093     private:
00094         /**
00095         * Blocked copy constructor.
00096         */
00097         AbstractComparableAggregator(const AbstractComparableAggregator&);
00098 
00099 
00100     // ----- AbstractAggregator Interface  ----------------------------------
00101 
00102     protected:
00103         /**
00104         * {@inheritDoc}
00105         */
00106         virtual void init(bool fFinal);
00107 
00108         /**
00109         * {@inheritDoc}
00110         */
00111         virtual Object::Holder finalizeResult(bool fFinal);
00112 
00113 
00114     // ----- PortableObject interface ---------------------------------------
00115 
00116     public:
00117         /**
00118         * {@inheritDoc}
00119         */
00120         virtual void readExternal(PofReader::Handle hIn);
00121 
00122         /**
00123         * {@inheritDoc}
00124         */
00125         virtual void writeExternal(PofWriter::Handle hOut) const;
00126 
00127 
00128     // ----- data members ---------------------------------------------------
00129 
00130     protected:
00131         /**
00132         * The count of processed entries.
00133         */
00134         int32_t m_count;
00135 
00136         /**
00137         * The running result value.
00138         */
00139         MemberView<Object> m_vResult;
00140 
00141         /**
00142         * The comparator to use for comparing extracted values.
00143         */
00144         FinalView<Comparator> f_vComparator;
00145     };
00146 
00147 COH_CLOSE_NAMESPACE3
00148 
00149 #endif // COH_ABSTRACT_COMPARABLE_AGGREGATOR_HPP
Copyright © 2000, 2017, Oracle and/or its affiliates. All rights reserved.