00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef COH_TYPED_SERIALIZER_HPP
00017 #define COH_TYPED_SERIALIZER_HPP
00018
00019 #include "coherence/lang.ns"
00020
00021 #include "coherence/io/pof/PofReader.hpp"
00022 #include "coherence/io/pof/PofSerializer.hpp"
00023 #include "coherence/io/pof/PofWriter.hpp"
00024
00025
00026
00027 template<class T> extern void serialize(coherence::io::pof::PofWriter::Handle hOut, const T& t);
00028 template<class T> extern T deserialize(coherence::io::pof::PofReader::Handle hIn);
00029
00030 COH_OPEN_NAMESPACE3(coherence,io,pof)
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051 template<class T>
00052 class TypedSerializer
00053 : public class_spec<TypedSerializer<T>,
00054 extends<Object>,
00055 implements<PofSerializer> >
00056 {
00057 friend class factory<TypedSerializer<T> >;
00058
00059
00060
00061 protected:
00062
00063
00064
00065
00066
00067
00068 TypedSerializer()
00069 {
00070 }
00071
00072
00073
00074
00075 public:
00076
00077
00078
00079 virtual void serialize(PofWriter::Handle hOut, Object::View v) const
00080 {
00081 ::serialize<typename T::View>(hOut, cast<typename T::View>(v));
00082 hOut->writeRemainder(NULL);
00083 }
00084
00085
00086
00087
00088 virtual Object::Holder deserialize(PofReader::Handle hIn) const
00089 {
00090 TypedHolder<T> oh = ::deserialize<TypedHolder<T > >(hIn);
00091 hIn->readRemainder();
00092 return oh;
00093 }
00094 };
00095
00096 COH_CLOSE_NAMESPACE3
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107 template<class T> void serialize(coherence::io::pof::PofWriter::Handle hOut, const T& t)
00108 {
00109 serialize<typename T::ValueType::BoxedType>(hOut, *t);
00110 }
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122 template<class T> T deserialize(coherence::io::pof::PofReader::Handle hIn)
00123 {
00124 return T::ValueType::create(deserialize<typename T::ValueType::BoxedType>(hIn));
00125 }
00126
00127 #endif // COH_TYPED_SERIALIZER_HPP
Copyright (c) 2000, 2009, Oracle and/or its affiliates. All rights reserved.