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

E26041-01

coherence/io/pof/SimplePofContext.hpp

00001 /*
00002 * SimplePofContext.hpp
00003 *
00004 * Copyright (c) 2000, 2013, 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_SIMPLE_POF_CONTEXT_HPP
00017 #define COH_SIMPLE_POF_CONTEXT_HPP
00018 
00019 #include "coherence/lang.ns"
00020 
00021 #include "coherence/io/ReadBuffer.hpp"
00022 #include "coherence/io/WriteBuffer.hpp"
00023 #include "coherence/io/pof/PofContext.hpp"
00024 #include "coherence/io/pof/PofSerializer.hpp"
00025 #include "coherence/util/LongArray.hpp"
00026 #include "coherence/util/Map.hpp"
00027 
00028 COH_OPEN_NAMESPACE3(coherence,io,pof)
00029 
00030 using coherence::io::ReadBuffer;
00031 using coherence::io::WriteBuffer;
00032 using coherence::util::LongArray;
00033 using coherence::util::Map;
00034 
00035 
00036 /**
00037 * Basic PofContext implementation.
00038 *
00039 * @author gm  2008.10.24
00040 *
00041 * @see PortableObjectSerializer
00042 */
00043 class COH_EXPORT SimplePofContext
00044     : public cloneable_spec<SimplePofContext,
00045         extends<Object>,
00046         implements<PofContext> >
00047     {
00048     friend class factory<SimplePofContext>;
00049 
00050     // ----- constructors ---------------------------------------------------
00051 
00052     protected:
00053         /**
00054         * @internal
00055         */
00056         SimplePofContext();
00057 
00058         /**
00059         * Copy constructor.
00060         */
00061         SimplePofContext(const SimplePofContext& that);
00062 
00063 
00064     // ----- SimplePofContext interface -------------------------------------
00065 
00066     public:
00067         /**
00068         * Associate a user type with a type identifier and
00069         * {@link PofSerializer}.
00070         *
00071         * @param nTypeId      the type identifier of the specified user type;
00072         *                     must be greater or equal to 0
00073         * @param vClass       the user type to register with this PofContext;
00074         *                     must not be NULL
00075         * @param vSerializer  the PofSerializer that will be used to
00076         *                     serialize and deserialize objects of the
00077         *                     specified class; must not be NULL
00078         *
00079         * @throws coherence::lang::IllegalArgumentException on invalid type
00080         *         identifer, class, or PofSerializer
00081         */
00082         virtual void registerUserType(int32_t nTypeId, Class::View vClass,
00083                 PofSerializer::View vSerializer);
00084 
00085         /**
00086         * Unregister a user type previously registered using the specified
00087         * type identifier.
00088         *
00089         * @param nTypeId  the type identifier of the user type to unregister
00090         *
00091         * @throws coherence::lang::IllegalArgumentException  if the specified
00092         *         user type identifier is unknown to this PofContext
00093         */
00094         virtual void unregisterUserType(int32_t nTypeId);
00095 
00096 
00097     // ----- PofContext interface -------------------------------------------
00098 
00099     public:
00100         /**
00101         * {@inheritDoc}
00102         */
00103         virtual PofSerializer::View getPofSerializer(int32_t nTypeId) const;
00104 
00105         /**
00106         * {@inheritDoc}
00107         */
00108         virtual int32_t getUserTypeIdentifier(Object::View v) const;
00109 
00110         /**
00111         * {@inheritDoc}
00112         */
00113         virtual int32_t getUserTypeIdentifier(Class::View vClass) const;
00114 
00115         /**
00116         * {@inheritDoc}
00117         */
00118         virtual int32_t getUserTypeIdentifier(String::View vsClass) const;
00119 
00120         /**
00121         * {@inheritDoc}
00122         */
00123         virtual String::View getClassName(int32_t nTypeId) const;
00124 
00125         /**
00126         * {@inheritDoc}
00127         */
00128         virtual Class::View getClass(int32_t nTypeId) const;
00129 
00130         /**
00131         * {@inheritDoc}
00132         */
00133         virtual bool isUserType(Object::View v) const;
00134 
00135         /**
00136         * {@inheritDoc}
00137         */
00138         virtual bool isUserType(Class::View vClass) const;
00139 
00140         /**
00141         * {@inheritDoc}
00142         */
00143         virtual bool isUserType(String::View vsClass) const;
00144 
00145 
00146     // ----- Serializer interface -------------------------------------------
00147 
00148     public:
00149         /**
00150         * {@inheritDoc}
00151         */
00152         virtual void serialize(WriteBuffer::BufferOutput::Handle hOut,
00153                 Object::View v) const;
00154 
00155         /**
00156         * {@inheritDoc}
00157         */
00158         virtual Object::Holder deserialize(
00159                 ReadBuffer::BufferInput::Handle hIn) const;
00160 
00161 
00162     // ----- Object interface -----------------------------------------------
00163 
00164     public:
00165         /**
00166         * {@inheritDoc}
00167         */
00168         virtual void toStream(std::ostream& out) const;
00169 
00170 
00171     // ----- internal methods -----------------------------------------------
00172 
00173     protected:
00174         /**
00175         * Ensure that the given user type identifier is valid.
00176         *
00177         * @param nTypeId  the user type identifier to validate
00178         *
00179         * @throws coherence::lang::IllegalArgumentException if the given user
00180         *         type identifier is negative
00181         */
00182         virtual void validateTypeId(int32_t nTypeId) const;
00183 
00184 
00185     // ----- accessors ------------------------------------------------------
00186 
00187     public:
00188         /**
00189         * Determine if Identity/Reference type support is enabled for this
00190         * SimplePofContext.
00191         *
00192         * @return true if Identity/Reference type support is enabled
00193         *
00194         * @since Coherence 3.7.1
00195         */
00196         virtual bool isReferenceEnabled() const;
00197 
00198         /**
00199         * Enable or disable POF Identity/Reference type support for this
00200         * SimplePofContext.
00201         *
00202         * @param fEnabled  true to enable POF Identity/Reference type support;
00203         *                  false to disable
00204         *
00205         * @since Coherence 3.7.1
00206         */
00207         virtual void setReferenceEnabled(bool fEnabled);
00208 
00209         /**
00210         * Enable or disable POF Identity/Reference type support for this
00211         * SimplePofContext.
00212         *
00213         * @param fEnabled  true to enable POF Identity/Reference type support;
00214         *                  false to disable
00215         *
00216         * @since Coherence 3.7.1
00217         */
00218         virtual void setReferenceEnabled(bool fEnabled) const;
00219 
00220 
00221     // ----- data members ---------------------------------------------------
00222 
00223     protected:
00224         /**
00225         * A LongArray of user types, indexed by type identifier.
00226         */
00227         FinalHandle<LongArray> f_hlaClass;
00228 
00229         /**
00230         * A LongArray of PofSerializer objects, indexed by type identifier.
00231         */
00232         FinalHandle<LongArray> f_hlaSerializer;
00233 
00234         /**
00235         * A Map that contains mappings from a registered class name to type
00236         * identifier.
00237         */
00238         FinalHandle<Map> f_hMapClassName;
00239 
00240         /**
00241         * True if POF Identity/Reference type support is enabled.
00242         */
00243         mutable bool m_fReferenceEnabled;
00244     };
00245 
00246 COH_CLOSE_NAMESPACE3
00247 
00248 #endif // COH_SIMPLE_POF_CONTEXT_HPP
Copyright © 2000, 2013, Oracle and/or its affiliates. All rights reserved.