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

E26041-01

coherence/io/pof/UserTypeWriter.hpp

00001 /*
00002 * UserTypeWriter.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_USER_TYPE_WRITER_HPP
00017 #define COH_USER_TYPE_WRITER_HPP
00018 
00019 #include "coherence/lang.ns"
00020 
00021 #include "coherence/io/WriteBuffer.hpp"
00022 #include "coherence/io/pof/PofBufferWriter.hpp"
00023 #include "coherence/io/pof/PofContext.hpp"
00024 #include "coherence/io/pof/WritingPofHandler.hpp"
00025 #include "coherence/util/Binary.hpp"
00026 
00027 COH_OPEN_NAMESPACE3(coherence,io,pof)
00028 
00029 using coherence::io::WriteBuffer;
00030 using coherence::util::Binary;
00031 
00032 
00033 /**
00034 * The UserTypeWriter implementation is a contextually-aware PofWriter whose
00035 * purpose is to write the properties of a value of a specified user type. The
00036 * "contextual awareness" refers to the fact that the UserTypeWriter maintains
00037 * state about the type identifier, the PofWriter's property index position
00038 * within the user type value, and a PofContext that may differ from the
00039 * PofContext that provided the PofSerializer which is using this
00040 * UserTypeWriter to serialize a user type.
00041 *
00042 * @author jh  2008.04.11
00043 */
00044 class COH_EXPORT UserTypeWriter
00045         : public class_spec<UserTypeWriter,
00046             extends<PofBufferWriter> >
00047     {
00048     friend class factory<UserTypeWriter>;
00049     friend class PofBufferWriter;
00050 
00051     // ----- constructors ---------------------------------------------------
00052 
00053     public:
00054         /**
00055         * Construct a UserTypeWriter for writing the property values of a
00056         * user type.
00057         *
00058         * @param hOut     the BufferOutput object to write to; must not be
00059         *                 NULL
00060         * @param vCtx     the PofContext to use for writing the user type
00061         *                 property values within the user type that this
00062         *                 writer will be writing
00063         * @param nTypeId  the type identifier of the user type; must be
00064         *                 non-negative
00065         * @param iProp    the index of the user type being written
00066         */
00067         UserTypeWriter(WriteBuffer::BufferOutput::Handle hOut,
00068                 PofContext::View vCtx, int32_t nTypeId, int32_t iProp);
00069 
00070         /**
00071         * Construct a UserTypeWriter for writing the property values of a
00072         * user type.
00073         *
00074         * @param hParent  the containing PofBufferWriter
00075         * @param hOut     the BufferOutput object to write to; must not be
00076         *                 null
00077         * @param vCtx     the PofContext to use for writing the user type
00078         *                 property values within the user type that this
00079         *                 writer will be writing
00080         * @param nTypeId  the type identifier of the user type; must be
00081         *                 non-negative
00082         * @param iProp    the index of the user type being written
00083         */
00084         UserTypeWriter(PofBufferWriter::Handle hParent,
00085                 WriteBuffer::BufferOutput::Handle hOut,
00086                 PofContext::View vCtx, int32_t nTypeId, int32_t iProp);
00087 
00088         /**
00089         * Construct a UserTypeWriter for writing the property values of a
00090         * user type.
00091         *
00092         * @param hHandler  the WritingPofHandler used to write user type data
00093         *                  (except for the user type id itself, which is
00094         *                  passed as a constructor argument)
00095         * @param vCtx      the PofContext to use for writing the user type
00096         *                  property values within the user type that this
00097         *                  writer will be writing
00098         * @param nTypeId   the type identifier of the user type; must be
00099         *                  non-negative
00100         * @param iProp     the index of the user type being written
00101         */
00102         UserTypeWriter(WritingPofHandler::Handle hHandler,
00103                 PofContext::View vCtx, int32_t nTypeId, int32_t iProp);
00104 
00105         /**
00106         * Construct a UserTypeWriter for writing the property values of a
00107         * user type.
00108         *
00109         * @param hParent  the containing PofBufferWriter
00110         * @param hHandle  the WritingPofHandler used to write user type data
00111         *                 (except for the user type id itself, which is
00112         *                 passed as a constructor argument)
00113         * @param vCtx     the PofContext to use for writing the user type
00114         *                 property values within the user type that this
00115         *                 writer will be writing
00116         * @param nTypeId  the type identifier of the user type; must be
00117         *                 non-negative
00118         * @param iProp    the index of the user type being written
00119         * @param nId      the identity of the object to encode, or -1 if the
00120         *                 identity shouldn't be encoded in the POF stream
00121         */
00122         UserTypeWriter(PofBufferWriter::Handle hParent,
00123                 WritingPofHandler::Handle hHandler,
00124                 PofContext::View vCtx, int nTypeId, int iProp, int nId=-1);
00125 
00126 
00127     // ----- PofWriter interface --------------------------------------------
00128 
00129     public:
00130         /**
00131         * {@inheritDoc}
00132         */
00133         virtual void writeObject(int32_t iProp, Object::View v);
00134 
00135         /**
00136         * {@inheritDoc}
00137         */
00138         virtual int32_t getUserTypeId() const;
00139 
00140         /**
00141         * {@inheritDoc}
00142         */
00143         virtual int32_t getVersionId() const;
00144 
00145         /**
00146         * {@inheritDoc}
00147         */
00148         virtual void setVersionId(int32_t nVersionId);
00149 
00150         /**
00151         * {@inheritDoc}
00152         */
00153         virtual PofWriter::Handle createNestedPofWriter(int32_t iProp);
00154 
00155         /**
00156         * {@inheritDoc}
00157         */
00158         virtual void writeRemainder(Binary::View vBinProps);
00159 
00160 
00161     // ----- internal methods -----------------------------------------------
00162 
00163     protected:
00164         /**
00165         * {@inheritDoc}
00166         */
00167         virtual PofBufferWriter::Handle getParentWriter();
00168 
00169         /**
00170         * {@inheritDoc}
00171         */
00172         virtual PofBufferWriter::View getParentWriter() const;
00173 
00174         /**
00175         * {@inheritDoc}
00176         */
00177         virtual void beginProperty(int32_t iProp);
00178 
00179         /**
00180         * {@inheritDoc}
00181         */
00182         virtual void endProperty(int32_t iProp);
00183 
00184         /**
00185         * Notify the UserTypeWriter that it is being "closed". This
00186         * notification allows the UserTypeWriter to write any remaining data
00187         * that it has pending to write.
00188         */
00189         virtual void closeNested();
00190 
00191         /**
00192         * Write out the type and version identifiers of the user type to the
00193         * POF stream, if they haven't already been written.
00194         *
00195         * @throws IOException on I/O error
00196         */
00197         virtual void writeUserTypeInfo();
00198 
00199         /**
00200         * {@inheritDoc}
00201         */
00202         virtual bool isEvolvable();
00203 
00204 
00205     // ----- accessors ------------------------------------------------------
00206 
00207     public:
00208         /**
00209         * {@inheritDoc}
00210         */
00211         virtual void enableReference();
00212 
00213 
00214     // ----- data members ---------------------------------------------------
00215 
00216     protected:
00217         /**
00218         * The parent (ie containing) PofBufferWriter.
00219         */
00220         FinalHandle<PofBufferWriter> f_hWriterParent;
00221 
00222         /**
00223         * The type identifier of the user type that is being written.
00224         */
00225         const int32_t m_nTypeId;
00226 
00227         /**
00228         * The version identifier of the user type that is being written.
00229         */
00230         int32_t m_nVersionId;
00231 
00232         /**
00233         * The index of the user type being written.
00234         */
00235         const int32_t m_iProp;
00236 
00237         /**
00238         * The identity of the object to encode, or -1 if the identity
00239         * shouldn't be encoded in the POF stream
00240         */
00241         int32_t m_nId;
00242 
00243         /**
00244         * The index of the last property written to the POF stream or -1 if
00245         * the first property has yet to be written.
00246         */
00247         int32_t m_iPrevProp;
00248 
00249         /**
00250         * True iff the type and version identifier of the user type was
00251         * written to the POF stream.
00252         */
00253         bool m_fUserTypeBegin;
00254 
00255         /**
00256         * True iff the user type was written to the POF stream.
00257         */
00258         bool m_fUserTypeEnd;
00259 
00260         /**
00261         * The Complex value that corresponds to the user type that is being
00262         * written.
00263         */
00264         MemberHandle<WritingPofHandler::Complex> m_hComplex;
00265 
00266         /**
00267          * The ID of the Complex value that corresponds to the user type that is being
00268          * written.
00269          */
00270         size64_t m_nComplexId;
00271 
00272         /**
00273         * The currently open nested writer, if any.
00274         */
00275         MemberHandle<UserTypeWriter> m_hWriterNested;
00276     };
00277 
00278 COH_CLOSE_NAMESPACE3
00279 
00280 #endif // COH_USER_TYPE_WRITER_HPP
Copyright © 2000, 2013, Oracle and/or its affiliates. All rights reserved.