00001 /* 00002 * BoxUpdater.hpp 00003 * 00004 * Copyright (c) 2000, 2014, 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_UPDATER_HPP 00017 #define COH_BOX_UPDATER_HPP 00018 00019 #include "coherence/lang.ns" 00020 00021 #include "coherence/util/extractor/TypedUpdater.hpp" 00022 00023 COH_OPEN_NAMESPACE3(coherence,util,extractor) 00024 00025 00026 /** 00027 * Template based auto-boxing ValueUpdater implementation. 00028 * 00029 * This updater functions on non-const methods which take 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_UPDATER macro can be used to easily construct 00034 * an instance of this class. For example the following constructs an updater 00035 * for calling the "void Address::setZip(int32_t)" method. 00036 * 00037 * @code 00038 * ValueUpdater::View vUpd = COH_BOX_UPDATER(Address, setZip, Integer32::View); 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_UPDATER is to be 00043 * used. 00044 * 00045 * @author mf 2009.07.29 00046 * 00047 * @see TypedUpdater 00048 */ 00049 template<class AH, class C, void (C::*M)(typename AH::ValueType::BoxedType), 00050 class OH = typename C::Handle> 00051 class BoxUpdater 00052 : public class_spec<BoxUpdater<AH, C, M, OH>, 00053 extends<TypedUpdater<typename AH::ValueType::BoxedType, C, M, 00054 BoxHandle<typename AH::ValueType>, OH> > > 00055 { 00056 friend class factory<BoxUpdater<AH, C, M, OH> >; 00057 00058 // ----- constructors --------------------------------------------------- 00059 00060 protected: 00061 /** 00062 * Construct a BoxUpdater 00063 */ 00064 BoxUpdater() 00065 { 00066 } 00067 00068 /** 00069 * Construct a BoxUpdater 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 BoxUpdater(String::View vsMethod) 00078 : class_spec<BoxUpdater<AH, C, M, OH>, 00079 extends<TypedUpdater<typename AH::ValueType::BoxedType, C, M, 00080 BoxHandle<typename AH::ValueType>, OH> > >(vsMethod) 00081 { 00082 } 00083 }; 00084 00085 COH_CLOSE_NAMESPACE3 00086 00087 /** 00088 * Helper macro for creating a BoxUpdater. 00089 * 00090 * @param C the class to call the method on, i.e. Address 00091 * @param M the method to call, i.e. setZip 00092 * @param A the argument handle type to unbox from, i.e. Integer32::View 00093 */ 00094 #define COH_BOX_UPDATER(C, M, A) \ 00095 coherence::util::extractor::BoxUpdater<A, C, &C::M>::create(#M) 00096 00097 /** 00098 * Helper macro for creating a BoxUpdater around a Managed<> wrapped class. 00099 * 00100 * @param C the Managed<> wrapped class to call the method on, i.e. Address 00101 * @param M the method to call, i.e. setZip 00102 * @param A the argument handle type to unbox from, i.e. Integer32::View 00103 */ 00104 #define COH_MANAGED_BOX_UPDATER(C, M, A) \ 00105 coherence::util::extractor::BoxUpdater<A, C, &C::M, \ 00106 coherence::lang::Managed<C>::Handle>::create(#M) 00107 00108 #endif // COH_BOX_UPDATER_HPP