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

E80355-01

coherence/util/extractor/BoxExtractor.hpp

00001 /*
00002 * BoxExtractor.hpp
00003 *
00004 * Copyright (c) 2000, 2017, 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_BOX_EXTRACTOR_HPP
00017 #define COH_BOX_EXTRACTOR_HPP
00018 
00019 #include "coherence/lang.ns"
00020 
00021 #include "coherence/util/extractor/TypedExtractor.hpp"
00022 
00023 COH_OPEN_NAMESPACE3(coherence,util,extractor)
00024 
00025 
00026 /**
00027 * Template based auto-boxing ValueExtractor implementation.
00028 *
00029 * This extractor functions on const methods which return unmanaged types for
00030 * which there is a corresponding the is a managed type which can "box"
00031 * them via a BoxHandle.
00032 *
00033 * For ease of use the COH_BOX_EXTRACTOR macro can be used to easily construct
00034 * an instance of this class.  For example the following constructs an extractor
00035 * for calling the "int32_t Address::getZip() const" method.
00036 *
00037 * @code
00038 * ValueExtractor::View vExt = COH_BOX_EXTRACTOR(Integer32::View, Address, getZip);
00039 * @endcode
00040 *
00041 * In the case that the supplied class does not extend from Object and instead
00042 * relies on the Managed<> wrapper, the COH_MANAGED_BOX_EXTRACTOR is to be
00043 * used.
00044 *
00045 * @author mf 2009.03.20
00046 *
00047 * @see TypedExtractor
00048 */
00049 template<class RH, class C, typename RH::ValueType::BoxedType (C::*M)() const,
00050     class OH = typename C::Holder>
00051 class BoxExtractor
00052     : public class_spec<BoxExtractor<RH, C, M, OH>,
00053         extends<TypedExtractor<typename RH::ValueType::BoxedType, C, M,
00054             BoxHandle<typename RH::ValueType>, OH> > >
00055     {
00056     friend class factory<BoxExtractor<RH, C, M, OH> >;
00057 
00058     // ----- constructors ---------------------------------------------------
00059 
00060     protected:
00061         /**
00062         * Construct a BoxExtractor
00063         */
00064         BoxExtractor()
00065             {
00066             }
00067 
00068         /**
00069         * Construct a BoxExtractor based on a method name and optional
00070         * parameters.
00071         *
00072         * The method name is only used for the purposes of serializing the
00073         * extractor for execution on remote Java members.
00074         *
00075         * @param vsMethod  the name of the method to invoke via reflection
00076         */
00077         BoxExtractor(String::View vsMethod)
00078             : class_spec<BoxExtractor<RH, C, M, OH>,
00079             extends<TypedExtractor<typename RH::ValueType::BoxedType, C, M,
00080                 BoxHandle<typename RH::ValueType>, OH> > >(vsMethod)
00081             {
00082             }
00083     };
00084 
00085 COH_CLOSE_NAMESPACE3
00086 
00087 /**
00088 * Helper macro for creating a BoxExtractor.
00089 *
00090 * @param H  the handle type to box to, i.e. Integer32::View
00091 * @param C  the class to call the method on, i.e. Address
00092 * @param M  the method to call, i.e. getZip
00093 */
00094 #define COH_BOX_EXTRACTOR(H, C, M) \
00095     coherence::util::extractor::BoxExtractor<H, C, &C::M>::create(#M)
00096 
00097 /**
00098 * Helper macro for creating a BoxExtractor around a Managed<> wrapped class.
00099 *
00100 * @param H  the handle type to box to, i.e. Integer32::View
00101 * @param C  the Managed<> wrapped class to call the method on, i.e. Address
00102 * @param M  the method to call, i.e. getZip
00103 */
00104 #define COH_MANAGED_BOX_EXTRACTOR(H, C, M) \
00105     coherence::util::extractor::BoxExtractor<H, C, &C::M, \
00106         coherence::lang::Managed<C>::Holder>::create(#M)
00107 
00108 #endif // COH_BOX_EXTRACTOR_HPP
Copyright © 2000, 2017, Oracle and/or its affiliates. All rights reserved.