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