C++ Client API Reference for Oracle Coherence
14c (14.1.2.0.0)

F79659-03

coherence/util/MapValuesCollection.hpp

00001 /*
00002  * Copyright (c) 2000, 2020, Oracle and/or its affiliates.
00003  *
00004  * Licensed under the Universal Permissive License v 1.0 as shown at
00005  * http://oss.oracle.com/licenses/upl.
00006  */
00007 #ifndef COH_MAP_VALUES_COLLECTION_HPP
00008 #define COH_MAP_VALUES_COLLECTION_HPP
00009 
00010 #include "coherence/lang.ns"
00011 
00012 #include "coherence/util/ConverterCollections.hpp"
00013 
00014 COH_OPEN_NAMESPACE2(coherence,util)
00015 
00016 
00017 /**
00018 * A wrapper class that provides the Collection interface for the value
00019 * collection of a map. It's returned by the default implementation of the
00020 * AbstractMap::values() method. MapValuesCollection is based on the
00021 * ConverterCollections functionality which will convert a map's entrySet
00022 * into a KeySet
00023 *
00024 * Note that because this ConverterSet is based on the Map's entrySet,
00025 * all write operations on the set must be converted out to a method on
00026 * the Map, not the keyset.
00027 *
00028 * @author nsa 2008.01.30
00029 */
00030 class COH_EXPORT MapValuesCollection
00031     : public class_spec<MapValuesCollection,
00032         extends<ConverterCollections::ConverterCollection> >
00033     {
00034     friend class factory<MapValuesCollection>;
00035 
00036     // ----- constructors ---------------------------------------------------
00037 
00038     protected:
00039         /**
00040         * Create a WrapperCollections#AbstractWrapperCollection which
00041         * delegates to the specified Collection.
00042         *
00043         * @param hMapDelegate  the underlying map
00044         */
00045         MapValuesCollection(Map::Handle hMapDelegate);
00046 
00047         /**
00048         * Create a WrapperCollections#AbstractWrapperCollection which
00049         * delegates to the specified Collection.
00050         *
00051         * @param vMapDelegate  the underlying map
00052         */
00053         MapValuesCollection(Map::View vMapDelegate);
00054 
00055 
00056     // ----- Collection interface -------------------------------------------
00057 
00058     public:
00059         /**
00060         * @{inheritDoc}
00061         */
00062         virtual bool remove(Object::View v);
00063 
00064         /**
00065         * @{inheritDoc}
00066         */
00067         virtual bool removeAll(Collection::View vc);
00068 
00069         /**
00070         * @{inheritDoc}
00071         */
00072         virtual bool retainAll(Collection::View vc);
00073 
00074         /**
00075         * @{inheritDoc}
00076         */
00077         virtual bool contains(Object::View v) const;
00078 
00079         /**
00080         * @{inheritDoc}
00081         */
00082         virtual bool containsAll(Collection::View vc) const;
00083 
00084 
00085     // ----- accessors ------------------------------------------------------
00086 
00087     protected:
00088         /**
00089         * Return the delegate Map instance.
00090         *
00091         * @return the delegate Map instance
00092         */
00093         virtual Map::Handle getMapDelegate();
00094 
00095         /**
00096         * Return the delegate Map instance.
00097         *
00098         * @return the delegate Map instance
00099         */
00100         virtual Map::View getMapDelegate() const;
00101 
00102 
00103     // ----- inner class: ValueConverter ------------------------------------
00104 
00105     public:
00106         /**
00107         * Convert a Map::Entry into a Map::Entry::Key
00108         */
00109         class ValueConverter
00110             : public class_spec<ValueConverter,
00111                 extends<Object>,
00112                 implements<Converter> >
00113             {
00114             friend class factory<ValueConverter>;
00115 
00116             // ----- constructor ----------------------------------------
00117 
00118             protected:
00119                 /**
00120                 * Create a new ValueConverter
00121                 */
00122                 ValueConverter();
00123 
00124             // ----- Converter interface --------------------------------
00125 
00126             public:
00127                 /**
00128                 * Convert an {@link coherence::lang::Object Object} referenced
00129                 * by the supplied holder.
00130                 *
00131                 * @param oh the holder to the Object to convert
00132                 *
00133                 * @return the holder to the converted Object
00134                 */
00135                 virtual Object::Holder convert(Object::Holder oh) const;
00136 
00137                 /**
00138                 * Return a singleton instance of the ValueConverter.
00139                 */
00140                 static ValueConverter::View getInstance();
00141             };
00142 
00143 
00144     // ----- data members ---------------------------------------------------
00145 
00146     protected:
00147         /**
00148         * The Map to which this KeySet is tied
00149         */
00150         FinalHolder<Map> f_thMapDelegate;
00151     };
00152 
00153 COH_CLOSE_NAMESPACE2
00154 
00155 #endif // COH_MAP_VALUES_COLLECTION_HPP
Copyright © 2000, 2025, Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.