00001 /* 00002 * Copyright (c) 2000, 2020, Oracle and/or its affiliates. 00003 * 00004 * Licensed under the Universal Permissive License v 1.0 as shown at 00005 * http://oss.oracle.com/licenses/upl. 00006 */ 00007 #ifndef COH_SERIALIZER_HPP 00008 #define COH_SERIALIZER_HPP 00009 00010 #include "coherence/lang.ns" 00011 00012 #include "coherence/io/ReadBuffer.hpp" 00013 #include "coherence/io/WriteBuffer.hpp" 00014 00015 COH_OPEN_NAMESPACE2(coherence,io) 00016 00017 00018 /** 00019 * The Serializer interface provides the capability of reading and writing an 00020 * object from and to an in-memory buffer. 00021 * 00022 * @author jh 2007.12.20 00023 * 00024 * @see ReadBuffer 00025 * @see WriteBuffer 00026 */ 00027 class COH_EXPORT Serializer 00028 : public interface_spec<Serializer> 00029 { 00030 // ----- Serializer interface ------------------------------------------- 00031 00032 public: 00033 /** 00034 * Serialize an object to a WriteBuffer by writing its state using the 00035 * specified BufferOutput object. 00036 * 00037 * @param hOut the BufferOutput with which to write the object's 00038 * state 00039 * @param v the object to serialize 00040 * 00041 * virtual void IOException if an I/O error occurs 00042 */ 00043 virtual void serialize(WriteBuffer::BufferOutput::Handle hOut, 00044 Object::View v) const = 0; 00045 00046 /** 00047 * Deserialize an object from a ReadBuffer by reading its state using 00048 * the specified BufferInput object. 00049 * 00050 * @param hIn the BufferInput with which to read the object's state 00051 * 00052 * @return the deserialized user type instance 00053 * 00054 * virtual void IOException if an I/O error occurs 00055 */ 00056 virtual Object::Holder deserialize( 00057 ReadBuffer::BufferInput::Handle hIn) const = 0; 00058 }; 00059 00060 COH_CLOSE_NAMESPACE2 00061 00062 #endif // COH_SERIALIZER_HPP