00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef COH_TYPED_UPDATER_HPP
00017 #define COH_TYPED_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/ReflectionUpdater.hpp"
00025
00026
00027 COH_OPEN_NAMESPACE3(coherence,util,extractor)
00028
00029 using coherence::io::pof::PofReader;
00030 using coherence::io::pof::PofWriter;
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051 template<class A, class C, void (C::*M)(A), class AH = A, class OH = typename C::Handle>
00052 class TypedUpdater
00053 : public class_spec<TypedUpdater<A, C, M, AH, OH>,
00054 extends<ReflectionUpdater> >
00055 {
00056 friend class factory<TypedUpdater<A, C, M, AH, OH> >;
00057
00058
00059
00060 protected:
00061
00062
00063
00064 TypedUpdater()
00065 {
00066 }
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077 TypedUpdater(String::View vsMethod)
00078 : class_spec<TypedUpdater<A, C, M, AH, OH>,
00079 extends<ReflectionUpdater> >(vsMethod)
00080 {
00081 }
00082
00083
00084
00085
00086 public:
00087
00088
00089
00090 virtual void update(Object::Handle hTarget, Object::Holder ohValue) const
00091 {
00092 (*cast<OH>(hTarget).*(M))(cast<AH>(ohValue));
00093 }
00094
00095
00096
00097
00098 public:
00099
00100
00101
00102 virtual bool equals(Object::View v) const
00103 {
00104 return instanceof<typename TypedUpdater<A, C, M, AH, OH>::View>(v);
00105 }
00106
00107
00108
00109
00110 virtual size32_t hashCode() const
00111 {
00112 return Class::getClassName(this)->hashCode();
00113 }
00114
00115
00116
00117
00118 virtual void toStream(std::ostream& out) const
00119 {
00120 out << Class::getClassName(this);
00121 }
00122 };
00123
00124 COH_CLOSE_NAMESPACE3
00125
00126
00127
00128
00129
00130
00131
00132
00133 #define COH_TYPED_UPDATER(C, M, A) \
00134 coherence::util::extractor::TypedUpdater<A, C, &C::M>::create(#M)
00135
00136 #endif // COH_TYPED_UPDATER_HPP