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

E90870-01

coherence/util/DeltaSet.hpp

00001 /*
00002 * DeltaSet.hpp
00003 *
00004 * Copyright (c) 2000, 2019, 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_DELTA_SET_HPP
00017 #define COH_DELTA_SET_HPP
00018 
00019 #include "coherence/lang.ns"
00020 
00021 #include "coherence/util/AbstractSet.hpp"
00022 #include "coherence/util/Set.hpp"
00023 
00024 COH_OPEN_NAMESPACE2(coherence,util)
00025 
00026 
00027 /**
00028 * Implements a set which is based on another set, which is assumed to be
00029 * immutable.
00030 *
00031 * @author tb 2009.02.10
00032 */
00033 class COH_EXPORT DeltaSet
00034     : public class_spec<DeltaSet,
00035         extends<AbstractSet> >
00036     {
00037     friend class factory<DeltaSet>;
00038 
00039     // ----- constructor ----------------------------------------------------
00040 
00041     public:
00042         /**
00043         * Construct this set based on an existing set.
00044         *
00045         * @param set  the set to base this delta set on
00046         */
00047         DeltaSet(Set::Holder hSet);
00048 
00049 
00050     // ----- DeltaSet accessors ---------------------------------------------
00051 
00052     public:
00053         /**
00054         * Determine what items were in the original set.
00055         *
00056         * @return the set used to construct this DeltaSet
00057         */
00058         virtual Set::View getOriginal() const;
00059 
00060         /**
00061         * Determine if the set has been modified.
00062         *
00063         * @return  true if any items have been removed
00064         */
00065         virtual bool isModified() const;
00066 
00067         /**
00068         * Determine what items were added to the DeltaSet.
00069         *
00070         * @return a set of added items
00071         */
00072         virtual Set::View getAdded() const;
00073 
00074         /**
00075         * Determine what items were removed from the DeltaSet.
00076         *
00077         * @return an immutable set of removed items
00078         */
00079         virtual Set::View getRemoved() const;
00080 
00081         /**
00082         * Get a mutable set of items that were added to the DeltaSet.
00083         *
00084         * @return a mutable set of added items
00085         */
00086         virtual Set::Handle ensureAdded();
00087 
00088         /**
00089         * Get a mutable set of items that are removed in the DeltaSet.
00090         *
00091         * @return a mutable set of removed items
00092         */
00093         virtual Set::Handle ensureRemoved();
00094 
00095         /**
00096         * Apply the changes to the underlying set ("commit").
00097         */
00098         virtual void resolve();
00099 
00100         /**
00101         * Discard the changes to the set ("rollback").
00102         */
00103         virtual void reset();
00104 
00105 
00106     // ----- Set interface --------------------------------------------------
00107 
00108     public:
00109         /**
00110         * {@inheritDoc}
00111         */
00112         virtual size32_t size() const;
00113 
00114         /**
00115         * {@inheritDoc}
00116         */
00117         virtual bool contains(Object::View v) const;
00118 
00119         /**
00120         * {@inheritDoc}
00121         */
00122         virtual Iterator::Handle iterator() const;
00123 
00124         /**
00125         * {@inheritDoc}
00126         */
00127         virtual Muterator::Handle iterator();
00128 
00129         /**
00130         * {@inheritDoc}
00131         */
00132         virtual ObjectArray::Handle toArray(ObjectArray::Handle hao = NULL) const;
00133 
00134         /**
00135         * {@inheritDoc}
00136         */
00137         virtual bool add(Object::Holder oh);
00138 
00139         /**
00140         * {@inheritDoc}
00141         */
00142         virtual bool remove(Object::View v);
00143 
00144         /**
00145         * {@inheritDoc}
00146         */
00147         virtual void clear();
00148 
00149 
00150     // ----- data members ---------------------------------------------------
00151 
00152     protected:
00153         /**
00154         * The underlying set (assumed immutable).
00155         */
00156         FinalHolder<Set> f_ohSetOrig;
00157 
00158         /**
00159         * The added items.
00160         */
00161         MemberHandle<Set> m_hSetAdded;
00162 
00163         /**
00164         * The removed items.
00165         */
00166         MemberHandle<Set> m_hSetRemoved;
00167     };
00168 
00169 COH_CLOSE_NAMESPACE2
00170 
00171 #endif // COH_DELTA_SET_HPP
Copyright © 2000, 2019, Oracle and/or its affiliates. All rights reserved.