Oracle Coherence for C++ API
Release 3.7.1.0

E22845-01

UserTypeWriter Class Reference

#include <coherence/io/pof/UserTypeWriter.hpp>

Inherits PofBufferWriter.

List of all members.


Detailed Description

The UserTypeWriter implementation is a contextually-aware PofWriter whose purpose is to write the properties of a value of a specified user type.

The "contextual awareness" refers to the fact that the UserTypeWriter maintains state about the type identifier, the PofWriter's property index position within the user type value, and a PofContext that may differ from the PofContext that provided the PofSerializer which is using this UserTypeWriter to serialize a user type.

Author:
jh 2008.04.11
 

Public Types

typedef spec::Handle  Handle
  UserTypeWriter Handle definition.
typedef spec::View  View
  UserTypeWriter View definition.
typedef spec::Holder  Holder
  UserTypeWriter Holder definition.

Public Member Functions

  UserTypeWriter (WriteBuffer::BufferOutput::Handle hOut, PofContext::View vCtx, int32_t nTypeId, int32_t iProp)
  Construct a UserTypeWriter for writing the property values of a user type.
  UserTypeWriter (PofBufferWriter::Handle hParent, WriteBuffer::BufferOutput::Handle hOut, PofContext::View vCtx, int32_t nTypeId, int32_t iProp)
  Construct a UserTypeWriter for writing the property values of a user type.
  UserTypeWriter (WritingPofHandler::Handle hHandler, PofContext::View vCtx, int32_t nTypeId, int32_t iProp)
  Construct a UserTypeWriter for writing the property values of a user type.
  UserTypeWriter (PofBufferWriter::Handle hParent, WritingPofHandler::Handle hHandler, PofContext::View vCtx, int nTypeId, int iProp, int nId=-1)
  Construct a UserTypeWriter for writing the property values of a user type.
virtual void  writeObject (int32_t iProp, Object::View v)
  Write an Object property to the POF stream.

The given object must be an instance of one of the following:

  • Boolean
  • Octet
  • Char16
  • Int16
  • Int32
  • Int64
  • Float32
  • Float64
  • Array<bool>
  • Array<octet_t>
  • Array<char16_t>
  • Array<int16_t>
  • Array<int32_t>
  • Array<int64_t>
  • Array<float32_t>
  • Array<float64_t>
  • Binary
  • String
  • RawDate
  • RawDateTime
  • RawDayTimeInterval
  • RawTime
  • RawTimeInterval
  • RawYearMonthInterval
  • Collection, with the same restrictions for all elements
  • LongArray, with the same restrictions for all elements
  • ObjectArray, with the same restrictions for all elements

Otherwise, a PofSerializer for the object must be obtainable from the PofContext associated with this PofWriter.

Parameters:
  iProp  the property index
  v  the Object property to write
Exceptions:
  coherence::lang::IllegalArgumentException  if the property index is invalid, or is less than or equal to the index of the previous property written to the POF stream
  coherence::lang::IllegalArgumentException  if the given property cannot be encoded into a POF stream
  coherence::io::IOException  if an I/O error occurs
virtual int32_t  getUserTypeId () const
  Determine the user type that is currently being written.
Returns:
the user type identifier, or -1 if the PofWriter is not currently writing a user type
virtual int32_t  getVersionId () const
  Determine the version identifier of the user type that is currently being written.
Returns:
the integer version ID of the user type; always non-negative
Exceptions:
  coherence::lang::IllegalStateException  if no user type is being parsed
virtual void  setVersionId (int32_t nVersionId)
  Set the version identifier of the user type that is currently being written.
Parameters:
  nVersionId  the user type identifier; must be non-negative
Exceptions:
  coherence::lang::IllegalArgumentException  if the given version ID is negative
  coherence::lang::IllegalStateException  if no user type is being written
virtual PofWriter::Handle  createNestedPofWriter (int32_t iProp)
  Obtain a PofWriter that can be used to write a set of properties into a single property of the current user type.

The returned PofWriter is only valid from the time that it is returned until the next call is made to this PofWriter.

Parameters:
  iProp  the property index
Returns:
a PofWriter whose contents are nested into a single property of this PofWriter
Exceptions:
  coherence::lang::IllegalArgumentException  if the property index is invalid, or is less than or equal to the index of the previous property written to the POF stream
  coherence::lang::IllegalStateException  if no user type is being written
  coherence::io::IOException  if an I/O error occurs
Since:
Coherence 3.6
virtual void  writeRemainder (Binary::View vBinProps)
  Write the remaining properties to the POF stream, terminating the writing of the currrent user type.

As part of writing out a user type, this method must be called by the PofSerializer that is writing out the user type, or the POF stream will be corrupted.

Calling this method terminates the current user type by writing a -1 to the POF stream after the last indexed property. Subsequent calls to the various writeXYZ methods of this interface will fail after this method is called.

Parameters:
  vBinProps  a buffer that contains zero or more indexed properties in binary POF encoded form; may be NULL
Exceptions:
  coherence::lang::IllegalStateException  if no user type is being written
  coherence::io::IOException  if an I/O error occurs
virtual void  enableReference ()
  Ensure that references (support for cyclic dependencies) are enabled.

Protected Member Functions

virtual
PofBufferWriter::Handle 
getParentWriter ()
  If this writer is contextually within a user type, obtain the writer which created this writer in order to write the user type.
Returns:
the containing writer
virtual
PofBufferWriter::View 
getParentWriter () const
  If this writer is contextually within a user type, obtain the writer which created this writer in order to write the user type.
Returns:
the containing writer
virtual void  beginProperty (int32_t iProp)
  Report that a POF property is about to be written to the POF stream.

This method call will be followed by one or more separate calls to a "write" method and the property extent will then be terminated by a call to endProperty.

Parameters:
  iProp  the index of the property being written
Exceptions:
  IllegalArgumentException  if the property index is invalid, or is less than or equal to the index of the previous property written to the POF stream
  IOException  if an I/O error occurs
virtual void  endProperty (int32_t iProp)
  Signifies the termination of the current POF property.
Parameters:
  iProp  the index of the current property
virtual void  closeNested ()
  Notify the UserTypeWriter that it is being "closed".
virtual void  writeUserTypeInfo ()
  Write out the type and version identifiers of the user type to the POF stream, if they haven't already been written.
virtual bool  isEvolvable ()
  Determine if the object to be written is either Evolvable or part of an Evolvable object.
Returns:
true iff the object to be written is Evolvable
Since:
Coherence 3.7.1

Protected Attributes

MemberHandle
< PofBufferWriter
m_hWriterParent
  The parent (ie containing) PofBufferWriter.
const int32_t  m_nTypeId
  The type identifier of the user type that is being written.
int32_t  m_nVersionId
  The version identifier of the user type that is being written.
const int32_t  m_iProp
  The index of the user type being written.
int32_t  m_nId
  The identity of the object to encode, or -1 if the identity shouldn't be encoded in the POF stream.
int32_t  m_iPrevProp
  The index of the last property written to the POF stream or -1 if the first property has yet to be written.
bool  m_fUserTypeBegin
  True iff the type and version identifier of the user type was written to the POF stream.
bool  m_fUserTypeEnd
  True iff the user type was written to the POF stream.
MemberHandle
< WritingPofHandler::Complex
m_hComplex
  The Complex value that corresponds to the user type that is being written.
MemberHandle
< UserTypeWriter
m_hWriterNested
  The currently open nested writer, if any.

Constructor & Destructor Documentation

UserTypeWriter ( WriteBuffer::BufferOutput::Handle  hOut,
    PofContext::View  vCtx,
    int32_t  nTypeId,
    int32_t  iProp  
  )      

Construct a UserTypeWriter for writing the property values of a user type.

Parameters:
  hOut  the BufferOutput object to write to; must not be NULL
  vCtx  the PofContext to use for writing the user type property values within the user type that this writer will be writing
  nTypeId  the type identifier of the user type; must be non-negative
  iProp  the index of the user type being written

UserTypeWriter ( PofBufferWriter::Handle  hParent,
    WriteBuffer::BufferOutput::Handle  hOut,
    PofContext::View  vCtx,
    int32_t  nTypeId,
    int32_t  iProp  
  )      

Construct a UserTypeWriter for writing the property values of a user type.

Parameters:
  hParent  the containing PofBufferWriter
  hOut  the BufferOutput object to write to; must not be null
  vCtx  the PofContext to use for writing the user type property values within the user type that this writer will be writing
  nTypeId  the type identifier of the user type; must be non-negative
  iProp  the index of the user type being written

UserTypeWriter ( WritingPofHandler::Handle  hHandler,
    PofContext::View  vCtx,
    int32_t  nTypeId,
    int32_t  iProp  
  )      

Construct a UserTypeWriter for writing the property values of a user type.

Parameters:
  hHandler  the WritingPofHandler used to write user type data (except for the user type id itself, which is passed as a constructor argument)
  vCtx  the PofContext to use for writing the user type property values within the user type that this writer will be writing
  nTypeId  the type identifier of the user type; must be non-negative
  iProp  the index of the user type being written

UserTypeWriter ( PofBufferWriter::Handle  hParent,
    WritingPofHandler::Handle  hHandler,
    PofContext::View  vCtx,
    int  nTypeId,
    int  iProp,
    int  nId = -1  
  )      

Construct a UserTypeWriter for writing the property values of a user type.

Parameters:
  hParent  the containing PofBufferWriter
  hHandle  the WritingPofHandler used to write user type data (except for the user type id itself, which is passed as a constructor argument)
  vCtx  the PofContext to use for writing the user type property values within the user type that this writer will be writing
  nTypeId  the type identifier of the user type; must be non-negative
  iProp  the index of the user type being written
  nId  the identity of the object to encode, or -1 if the identity shouldn't be encoded in the POF stream

Member Function Documentation

virtual void closeNested (    )  [protected, virtual]

Notify the UserTypeWriter that it is being "closed".

This notification allows the UserTypeWriter to write any remaining data that it has pending to write.

virtual void writeUserTypeInfo (    )  [protected, virtual]

Write out the type and version identifiers of the user type to the POF stream, if they haven't already been written.

Exceptions:
  IOException  on I/O error

The documentation for this class was generated from the following file:

Copyright © 2000, 2011, Oracle and/or its affiliates. All rights reserved.