00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef COH_SYSTEM_POF_CONTEXT_HPP
00017 #define COH_SYSTEM_POF_CONTEXT_HPP
00018
00019 #include "coherence/lang.ns"
00020
00021 #include "coherence/io/ReadBuffer.hpp"
00022 #include "coherence/io/WriteBuffer.hpp"
00023 #include "coherence/io/pof/PofContext.hpp"
00024 #include "coherence/io/pof/PofSerializer.hpp"
00025 #include "coherence/io/pof/PortableObjectSerializer.hpp"
00026 #include "coherence/io/pof/TypedSerializer.hpp"
00027 #include "coherence/util/LongArray.hpp"
00028 #include "coherence/util/Map.hpp"
00029 #include "coherence/util/ThreadGate.hpp"
00030
00031 COH_OPEN_NAMESPACE3(coherence,io,pof)
00032
00033 using coherence::io::ReadBuffer;
00034 using coherence::io::WriteBuffer;
00035 using coherence::util::LongArray;
00036 using coherence::util::Map;
00037 using coherence::util::ThreadGate;
00038
00039
00040
00041
00042
00043
00044
00045
00046 class COH_EXPORT SystemPofContext
00047 : public class_spec<SystemPofContext,
00048 extends<Object>,
00049 implements<PofContext> >
00050 {
00051 friend class factory<SystemPofContext>;
00052
00053
00054
00055 private:
00056
00057
00058
00059 using this_spec::create;
00060
00061
00062
00063
00064 SystemPofContext();
00065
00066
00067
00068
00069 public:
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085 virtual void registerUserType(int32_t nTypeId, Class::View vClass,
00086 PofSerializer::View vSerializer);
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097 virtual void unregisterUserType(int32_t nTypeId);
00098
00099
00100
00101
00102 public:
00103
00104
00105
00106 virtual PofSerializer::View getPofSerializer(int32_t nTypeId) const;
00107
00108
00109
00110
00111 virtual int32_t getUserTypeIdentifier(Object::View v) const;
00112
00113
00114
00115
00116 virtual int32_t getUserTypeIdentifier(Class::View vClass) const;
00117
00118
00119
00120
00121 virtual int32_t getUserTypeIdentifier(String::View vsClass) const;
00122
00123
00124
00125
00126 virtual String::View getClassName(int32_t nTypeId) const;
00127
00128
00129
00130
00131 virtual Class::View getClass(int32_t nTypeId) const;
00132
00133
00134
00135
00136 virtual bool isUserType(Object::View v) const;
00137
00138
00139
00140
00141 virtual bool isUserType(Class::View vClass) const;
00142
00143
00144
00145
00146 virtual bool isUserType(String::View vsClass) const;
00147
00148
00149
00150
00151 public:
00152
00153
00154
00155 virtual void serialize(WriteBuffer::BufferOutput::Handle hOut,
00156 Object::View v) const;
00157
00158
00159
00160
00161 virtual Object::Holder deserialize(
00162 ReadBuffer::BufferInput::Handle hIn) const;
00163
00164
00165
00166
00167 public:
00168
00169
00170
00171 virtual void toStream(std::ostream& out) const;
00172
00173
00174
00175
00176 protected:
00177
00178
00179
00180
00181
00182
00183
00184
00185 virtual void validateTypeId(int32_t nTypeId) const;
00186
00187
00188
00189
00190 protected:
00191
00192
00193
00194 const LongArray::Handle m_hlaClass;
00195
00196
00197
00198
00199 const LongArray::Handle m_hlaSerializer;
00200
00201
00202
00203
00204
00205 const Map::Handle m_hMapTypeId;
00206
00207
00208
00209
00210 mutable ThreadGate::Handle m_hGate;
00211
00212
00213
00214
00215 public:
00216
00217
00218
00219
00220
00221 static Handle getInstance();
00222 };
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235 #define COH_REGISTER_POF_SERIALIZER(POF_TYPE_ID, CLASS, POF_SERIALIZER) \
00236 COH_STATIC_INIT(coherence::io::pof::SystemPofContext::getInstance()-> \
00237 registerUserType(POF_TYPE_ID, \
00238 coherence::lang::SystemClassLoader::getInstance()-> \
00239 registerClass(CLASS), POF_SERIALIZER))
00240
00241
00242
00243
00244
00245
00246
00247
00248 #define COH_REGISTER_PORTABLE_CLASS(POF_TYPE_ID, TYPE) \
00249 COH_REGISTER_POF_SERIALIZER(POF_TYPE_ID, \
00250 coherence::lang::TypedClass<TYPE >::create(), \
00251 coherence::io::pof::PortableObjectSerializer::create(POF_TYPE_ID))
00252
00253
00254
00255
00256
00257
00258
00259
00260 #define COH_REGISTER_MANAGED_CLASS(POF_TYPE_ID, TYPE) \
00261 COH_REGISTER_POF_SERIALIZER(POF_TYPE_ID, \
00262 coherence::lang::TypedClass<coherence::lang::Managed<TYPE > >::create(), \
00263 coherence::io::pof::TypedSerializer<coherence::lang::Managed<TYPE > >::create())
00264
00265 COH_CLOSE_NAMESPACE3
00266
00267 #endif // COH_SYSTEM_POF_CONTEXT_HPP
Copyright (c) 2000-2008 Oracle. All rights reserved.