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

E90870-01

coherence/io/pof/PofAnnotationSerializer.hpp

00001 /*
00002 * PofAnnotationSerializer.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_POF_ANNOTATION_SERIALIZER_HPP
00017 #define COH_POF_ANNOTATION_SERIALIZER_HPP
00018 
00019 #include "coherence/lang.ns"
00020 
00021 #include "coherence/io/pof/PofReader.hpp"
00022 #include "coherence/io/pof/PofSerializer.hpp"
00023 #include "coherence/io/pof/PofWriter.hpp"
00024 
00025 COH_OPEN_NAMESPACE3(coherence,io,pof)
00026 
00027 /**
00028 * A PofAnnotationSerializer provides annotation based (de)serialization.
00029 * This serializer must be instantiated with the intended class which is
00030 * eventually scanned for the presence of the following annotations.
00031 * <ul>
00032 *      <li>coherence::io::pof::annotation::Portable</li>
00033 *      <li>coherence::io::pof::annotation::PortableProperty</li>
00034 * </ul>
00035 *
00036 * This serializer supports classes iff they are annotated with the type level
00037 * annotation; Portable. This annotation is a marker indicating the ability
00038 * to (de)serialize using this serializer.
00039 *
00040 * All methods annotated with PortableProperty are explicitly
00041 * deemed POF serializable with the option of specifying overrides to
00042 * provide explicit behaviour such as:
00043 * <ul>
00044 *      <li>explicit POF indexes</li>
00045 *      <li>Custom coherence::io::pof::reflect::Codec to
00046 *          specify concrete implementations / customizations</li>
00047 * </ul>
00048 *
00049 * The PortableProperty::getIndex() (POF index) can be omitted iff the
00050 * auto-indexing feature is enabled. This is enabled by instantiating this
00051 * class with the \c fAutoIndex constructor argument. This feature
00052 * determines the index based on any explicit indexes specified and the name
00053 * of the portable properties. Currently objects with multiple versions is
00054 * not supported. The following illustrates the auto index algorithm:
00055 * <table border=1>
00056 *   <tr><td>Name</td><td>Explicit Index</td><td>Determined Index</td></tr>
00057 *   <tr><td>c</td><td>1</td><td>1</td>
00058 *   <tr><td>a</td><td></td><td>0</td>
00059 *   <tr><td>b</td><td></td><td>2</td>
00060 * </table>
00061 *
00062 * <b>NOTE:</b> This implementation does support objects that implement
00063 * Evolvable.
00064 *
00065 * @author hr 2011.06.29
00066 *
00067 * @since 3.7.1
00068 *
00069 * @see COH_REGISTER_TYPED_CLASS
00070 * @see COH_REGISTER_POF_ANNOTATED_CLASS
00071 * @see COH_REGISTER_POF_ANNOTATED_CLASS_AI
00072 * @see Portable
00073 */
00074 class COH_EXPORT PofAnnotationSerializer
00075     : public class_spec<PofAnnotationSerializer,
00076         extends<Object>,
00077         implements<PofSerializer> >
00078     {
00079     friend class factory<PofAnnotationSerializer>;
00080 
00081     // ----- constructors ---------------------------------------------------
00082 
00083     protected:
00084         /**
00085         * Constructs a PofAnnotationSerializer.
00086         *
00087         * @param nTypeId     the POF type id
00088         * @param vClz        type this serializer is aware of
00089         * @param fAutoIndex  turns on the auto index feature, default = false
00090         */
00091         PofAnnotationSerializer(int32_t nTypeId, Class::View vClz, bool fAutoIndex = false);
00092 
00093     // ----- PofSerializer interface ----------------------------------------
00094 
00095     public:
00096         /**
00097         * {@inheritDoc}
00098         */
00099         virtual void serialize(PofWriter::Handle hOut, Object::View v) const;
00100 
00101         /**
00102         * {@inheritDoc}
00103         */
00104         virtual Object::Holder deserialize(PofReader::Handle hIn) const;
00105 
00106     // ---- helpers ---------------------------------------------------------
00107 
00108     protected:
00109         /**
00110         * Initialize this class based on the provided information.
00111         *
00112         * @param nTypeId     the POF type id
00113         * @param vClz        type this serializer is aware of
00114         * @param fAutoIndex  turns on the auto index feature
00115         */
00116         virtual void initialize(int32_t nTypeId, Class::View vClz, bool fAutoIndex);
00117 
00118     // ---- data members ----------------------------------------------------
00119 
00120     private:
00121         /**
00122         * A structural definition of the type information.
00123         */
00124         FinalHandle<Object> f_ohTypeMetadata;
00125     };
00126 
00127 COH_CLOSE_NAMESPACE3
00128 
00129 #endif // COH_POF_ANNOTATION_SERIALIZER_HPP
Copyright © 2000, 2019, Oracle and/or its affiliates. All rights reserved.