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

E47891-01

coherence/util/CompositeKey.hpp

00001 /*
00002 * CompositeKey.hpp
00003 *
00004 * Copyright (c) 2000, 2014, 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_COMPOSITE_KEY_HPP
00017 #define COH_COMPOSITE_KEY_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/net/cache/KeyAssociation.hpp"
00025 
00026 #include <ostream>
00027 
00028 COH_OPEN_NAMESPACE2(coherence,util)
00029 
00030 using coherence::io::pof::PofReader;
00031 using coherence::io::pof::PofWriter;
00032 using coherence::io::pof::PortableObject;
00033 using coherence::net::cache::KeyAssociation;
00034 
00035 
00036 /**
00037 * Key class that consists of a primary and secondary component. Two instances
00038 * of CompositeKey are considered to be equal iff both the primary and
00039 * secondary components of the two instances are considered equal.
00040 * Additionally, the hash code of a CompositeKey takes into the consideration
00041 * the hash codes of its two components. Finally, the CompositeKey class
00042 * implements KeyAssociation by returning the primary component.
00043 *
00044 * @author wl 2010.09.02
00045 */
00046 class COH_EXPORT CompositeKey
00047     : public class_spec<CompositeKey,
00048         extends<Object>,
00049         implements<KeyAssociation, PortableObject> >
00050     {
00051     friend class factory<CompositeKey>;
00052 
00053     // ----- constructors ---------------------------------------------------
00054 
00055     protected:
00056         /**
00057         * Default constructor.
00058         */
00059         CompositeKey();
00060 
00061         /**
00062         * Create a new CompositeKey that consists of the given primary and
00063         * secondary components.
00064         *
00065         * @param voPrimary   the primary key component; must not be null. This
00066         *                    is also the host key returned by the 
00067         *                    KeyAssociation implementation
00068         * @param voSecondary the secondary key component; must not be null
00069         */
00070         CompositeKey(Object::View voPrimary, Object::View voSecondary);
00071 
00072 
00073     // ----- KeyAssociation interface ---------------------------------------
00074 
00075     public:
00076         /**
00077         * {@inheritDoc}
00078         */
00079         virtual Object::View getAssociatedKey() const;
00080 
00081 
00082     // ----- PortableObject interface ---------------------------------------
00083 
00084     public:
00085         /**
00086         * {@inheritDoc}
00087         */
00088         virtual void readExternal(PofReader::Handle hIn);
00089 
00090         /**
00091         * {@inheritDoc}
00092         */
00093         virtual void writeExternal(PofWriter::Handle hOut) const;
00094 
00095 
00096     // ----- Object methods -------------------------------------------------
00097 
00098     public:
00099         /**
00100         * {@inheritDoc}
00101         */
00102         virtual size32_t hashCode() const;
00103 
00104         /**
00105         * {@inheritDoc}
00106         */
00107         virtual bool equals(Object::View v) const;
00108 
00109         /**
00110         * {@inheritDoc}
00111         */
00112         virtual void toStream(std::ostream& out) const;
00113 
00114 
00115     // ----- accessors ------------------------------------------------------
00116 
00117     public:
00118         /**
00119         * Return the primary key component.
00120         *
00121         * @return the primary key component
00122         */
00123         virtual Object::View getPrimaryKey() const;
00124 
00125         /**
00126         * Return the secondary key component.
00127         *
00128         * @return the secondary key component
00129         */
00130         virtual Object::View getSecondaryKey() const;
00131 
00132 
00133     // ----- data members ---------------------------------------------------
00134 
00135     private:
00136         /**
00137         * The primary key component.
00138         */
00139         FinalView<Object> f_voPrimary;
00140 
00141         /**
00142         * The secondary key component.
00143         */
00144         FinalView<Object> f_voSecondary;
00145     };
00146 
00147 COH_CLOSE_NAMESPACE2
00148 
00149 #endif // COH_COMPOSITE_KEY_HPP
Copyright © 2000, 2014, Oracle and/or its affiliates. All rights reserved.