coherence/util/Binary.hpp

00001 /*
00002 * Binary.hpp
00003 *
00004 * Copyright (c) 2000, 2009, 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_BINARY_HPP
00017 #define COH_BINARY_HPP
00018 
00019 #include "coherence/lang.ns"
00020 
00021 #include "coherence/io/OctetArrayReadBuffer.hpp"
00022 #include "coherence/io/ReadBuffer.hpp"
00023 
00024 COH_OPEN_NAMESPACE2(coherence,util)
00025 
00026 using coherence::io::OctetArrayReadBuffer;
00027 using coherence::io::ReadBuffer;
00028 
00029 
00030 /**
00031 * A thread-safe immutable binary object.
00032 *
00033 * @author jh  2008.05.29
00034 */
00035 class COH_EXPORT Binary
00036     : public cloneable_spec<Binary,
00037         extends<OctetArrayReadBuffer> >
00038     {
00039     friend class factory<Binary>;
00040 
00041     // ----- constructors ---------------------------------------------------
00042 
00043     private:
00044         /**
00045         * Construct a Binary object from a portion of an octet array.
00046         *
00047         * @param vab  an array of octets; must not be NULL
00048         * @param of   the offset into the octet array
00049         * @param cb   the number of octets to extract
00050         */
00051         Binary(Array<octet_t>::View vab, size32_t of, size32_t cb);
00052 
00053         /**
00054         * Copy constructor.
00055         */
00056         Binary(const Binary& that);
00057 
00058 
00059     // ----- Object interface -----------------------------------------------
00060 
00061     public:
00062         /**
00063         * {@inheritDoc}
00064         */
00065         virtual size32_t hashCode() const;
00066 
00067         /**
00068         * {@inheritDoc}
00069         */
00070         virtual bool equals(Object::View v) const;
00071 
00072         /**
00073         * {@inheritDoc}
00074         */
00075         virtual bool isImmutable() const;
00076 
00077         /**
00078         * {@inheritDoc}
00079         */
00080         virtual void toStream(std::ostream& out) const;
00081 
00082 
00083     // ----- internal methods -----------------------------------------------
00084 
00085     protected:
00086         /**
00087         * {@inheritDoc}
00088         */
00089         virtual void updateLength(size32_t cb);
00090 
00091         /**
00092         * {@inheritDoc}
00093         */
00094         virtual ReadBuffer::View instantiateReadBuffer(size32_t of,
00095                 size32_t cb) const;
00096     };
00097 
00098 COH_CLOSE_NAMESPACE2
00099 
00100 #endif // COH_BINARY_HPP
Copyright (c) 2000, 2009, Oracle and/or its affiliates. All rights reserved.