00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef COH_TYPED_EXTRACTOR_HPP
00017 #define COH_TYPED_EXTRACTOR_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/ReflectionExtractor.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 R, class C, R (C::*M)() const, class RH = Object::Holder,
00052 class OH = typename C::Holder>
00053 class TypedExtractor
00054 : public class_spec<TypedExtractor<R, C, M, RH, OH>,
00055 extends<ReflectionExtractor> >
00056 {
00057 friend class factory<TypedExtractor<R, C, M, RH, OH> >;
00058
00059
00060
00061 protected:
00062
00063
00064
00065 TypedExtractor()
00066 {
00067 }
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078 TypedExtractor(String::View vsMethod)
00079 : class_spec<TypedExtractor<R, C, M, RH, OH>,
00080 extends<ReflectionExtractor> >(vsMethod)
00081 {
00082 }
00083
00084
00085
00086
00087 public:
00088
00089
00090
00091 virtual Object::Holder extract(Object::Holder ohTarget) const
00092 {
00093 return RH(((*cast<OH>(ohTarget)).*(M))());
00094 }
00095
00096
00097
00098
00099 public:
00100
00101
00102
00103 virtual bool equals(Object::View v) const
00104 {
00105 return instanceof<typename TypedExtractor<R, C, M, RH, OH>::View>(v);
00106 }
00107
00108
00109
00110
00111 virtual size32_t hashCode() const
00112 {
00113 return Class::getClassName(this)->hashCode();
00114 }
00115
00116
00117
00118
00119 virtual void toStream(std::ostream& out) const
00120 {
00121 out << Class::getClassName(this);
00122 }
00123 };
00124
00125 COH_CLOSE_NAMESPACE3
00126
00127
00128
00129
00130
00131
00132
00133
00134 #define COH_TYPED_EXTRACTOR(H, C, M) \
00135 coherence::util::extractor::TypedExtractor<H, C, &C::M>::create(#M)
00136
00137 #endif // COH_TYPED_EXTRACTOR_HPP