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

E69640-01

coherence/util/AbstractStableIterator.hpp

00001 /*
00002 * AbstractStableIterator.hpp
00003 *
00004 * Copyright (c) 2000, 2016, 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_ABSTACT_STABLE_ITERATOR_HPP
00017 #define COH_ABSTACT_STABLE_ITERATOR_HPP
00018 
00019 #include "coherence/lang.ns"
00020 
00021 #include "coherence/util/Muterator.hpp"
00022 
00023 COH_OPEN_NAMESPACE2(coherence,util)
00024 
00025 
00026 /**
00027 * An abstract Iterator implementation that is stable between the hasNext() and
00028 * next() methods.
00029 *
00030 * @author mf 2008.02.28
00031 */
00032 class COH_EXPORT AbstractStableIterator
00033     : public abstract_spec<AbstractStableIterator,
00034         extends<Object>,
00035         implements<Muterator> >
00036     {
00037     // ----- constructors ---------------------------------------------------
00038 
00039     protected:
00040         /**
00041         * @internal
00042         */
00043         AbstractStableIterator();
00044 
00045 
00046     // ----- Muterator interface --------------------------------------------
00047 
00048     public:
00049         /**
00050         * {@inheritDoc}
00051         */
00052         virtual void remove();
00053 
00054 
00055     // ----- Iterator interface ---------------------------------------------
00056 
00057     public:
00058         /**
00059         * {@inheritDoc}
00060         */
00061         virtual bool hasNext() const;
00062 
00063         /**
00064         * {@inheritDoc}
00065         */
00066         virtual Object::Holder next();
00067 
00068 
00069     // ----- internal -------------------------------------------------------
00070 
00071     protected:
00072         /**
00073         * Obtain the previous object provided by the Iterator.
00074         *
00075         * @return the object previously returned from a call to #next()
00076         */
00077         virtual Object::Holder getPrevious() const;
00078 
00079         /**
00080         * Specify the next object to provide from the Iterator.
00081         *
00082         * @param ohNext  the next object to provide from the Iterator
00083         */
00084         virtual void setNext(Object::Holder ohNext);
00085 
00086         /**
00087         * Advance to the next object.
00088         *
00089         * This method must be implemented by the concrete sub-class by calling
00090         * #setNext() if there is a next object.
00091         */
00092         virtual void advance() = 0;
00093 
00094         /**
00095         * Remove the specified item.
00096         *
00097         * This is an optional operation. If the Iterator supports element
00098         * removal, then it should implement this method, which is delegated to by
00099         * the #remove() method.
00100         *
00101         * @param ohPrev  the previously iterated object that should be removed
00102         *
00103         * @throws coherence::lang::UnsupportedOperationException if removal
00104         *         is not supported
00105         */
00106         virtual void remove(Object::Holder ohPrev);
00107 
00108 
00109     // ----- Object interface -----------------------------------------------
00110 
00111     protected:
00112         /**
00113         * {@inheritDoc}
00114         */
00115         virtual void onInit();
00116 
00117 
00118     // ----- data members ---------------------------------------------------
00119 
00120     private:
00121         /**
00122         * Set to true when <tt>m_oNext</tt> is the next object to return
00123         * from the iterator. If there is no next object, or if the next object
00124         * is not determined yet, then this will be false. Set up by
00125         * #setNext() and reset by #next().
00126         */
00127         bool m_fNextReady;
00128 
00129         /**
00130         * The next object to return from this iterator.  Set up by
00131         * #setNext() and reset by #next().
00132         */
00133         MemberHolder<Object> m_ohNext;
00134 
00135         /**
00136         * The object that can be deleted, if any. Set up by #next.
00137         */
00138         MemberHolder<Object> m_ohPrev;
00139 
00140         /**
00141         * Set to true when an element has been returned but not yet
00142         * removed. Set up by #next() and reset by #remove().
00143         */
00144         bool m_fCanDelete;
00145     };
00146 
00147 COH_CLOSE_NAMESPACE2
00148 
00149 #endif // COH_ABSTACT_STABLE_ITERATOR_HPP
Copyright © 2000, 2016, Oracle and/or its affiliates. All rights reserved.