Oracle Coherence for C++ API
Release 3.6.1.0
E18813-01

- Main Page
- Namespaces
- Classes
- Files

# coherence/util/processor/ConditionalPut.hpp

    00001 /*
    00002 * ConditionalPut.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_CONDITIONAL_PUT_HPP
    00017 #define COH_CONDITIONAL_PUT_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/InvocableMap.hpp"
    00026 #include "coherence/util/processor/AbstractProcessor.hpp"
    00027
    00028 COH_OPEN_NAMESPACE3(coherence,util, processor)
    00029
    00030 using coherence::io::pof::PofReader;
    00031 using coherence::io::pof::PofWriter;
    00032 using coherence::io::pof::PortableObject;
    00033 using coherence::util::Filter;
    00034 using coherence::util::InvocableMap;
    00035
    00036
    00037 /**
    00038 * ConditionalPut is an EntryProcessor that performs an
    00039 * InvocableMap::Entry#setValue operation if the specified condition is
    00040 * satisfied.
    00041 *
    00042 * @author tb  2008.04.28
    00043 */
    00044 class COH_EXPORT ConditionalPut
    00045     : public class_spec<ConditionalPut,
    00046         extends<AbstractProcessor>,
    00047         implements<PortableObject> >
    00048     {
    00049     friend class factory<ConditionalPut>;
    00050
    00051     // ----- constructors ---------------------------------------------------
    00052
    00053     protected:
    00054         /**
    00055         * Construct a ConditionalPut.
    00056         */
    00057         ConditionalPut();
    00058
    00059         /**
    00060         * Construct a ConditionalPut that updates an entry with a new value
    00061         * if and only if the filter applied to the entry evaluates to true.
    00062         * This processor optionally returns the current value as a result of
    00063         * the invocation if it has not been updated (the filter evaluated to
    00064         * false).
    00065         *
    00066         * @param vFilter  the filter to evaluate an entry
    00067         * @param ohValue  a value to update an entry with
    00068         * @param fReturn  specifies whether or not the processor should
    00069         *                 return the current value in case it has not been
    00070         *                 updated
    00071         */
    00072         ConditionalPut(Filter::View vFilter, Object::Holder ohValue,
    00073                 bool fReturn = false);
    00074
    00075
    00076     // ----- InvocableMap::EntryProcessor interface -------------------------
    00077
    00078     public:
    00079         /**
    00080         * {@inheritDoc}
    00081         */
    00082         virtual Object::Holder process(
    00083                 InvocableMap::Entry::Handle hEntry) const;
    00084
    00085         /**
    00086         * {@inheritDoc}
    00087         */
    00088         virtual Map::View processAll(Set::View vsetEntries) const;
    00089
    00090
    00091     // ----- PortableObject interface ---------------------------------------
    00092
    00093     public:
    00094         /**
    00095         * {@inheritDoc}
    00096         */
    00097         virtual void readExternal(PofReader::Handle hIn);
    00098
    00099         /**
    00100         * {@inheritDoc}
    00101         */
    00102         virtual void writeExternal(PofWriter::Handle hOut) const;
    00103
    00104
    00105     // ----- Object interface -----------------------------------------------
    00106
    00107     public:
    00108         /**
    00109         * {@inheritDoc}
    00110         */
    00111         virtual bool equals(Object::View v) const;
    00112
    00113         /**
    00114         * {@inheritDoc}
    00115         */
    00116         virtual size32_t hashCode() const;
    00117
    00118
    00119     // ----- data members ---------------------------------------------------
    00120
    00121     protected:
    00122         /**
    00123         * The underlying filter.
    00124         */
    00125         MemberView<Filter> m_vFilter;
    00126
    00127         /**
    00128         * Specifies the new value to update an entry with.
    00129         */
    00130         MemberHolder<Object> m_hValue;
    00131
    00132         /**
    00133         * Specifies whether or not a return value is required.
    00134         */
    00135         bool m_fReturn;
    00136     };
    00137
    00138 COH_CLOSE_NAMESPACE3
    00139
    00140 #endif // COH_CONDITIONAL_PUT_HPP

Copyright © 2000, 2010, Oracle and/or its affiliates. All rights reserved.