19 #ifndef INCLUDE_RCF_MARSHAL_HPP
20 #define INCLUDE_RCF_MARSHAL_HPP
22 #include <RCF/AmiThreadPool.hpp>
23 #include <RCF/ClientStub.hpp>
24 #include <RCF/CurrentSerializationProtocol.hpp>
25 #include <RCF/ObjectPool.hpp>
26 #include <RCF/PublishingService.hpp>
27 #include <RCF/RcfServer.hpp>
28 #include <RCF/RcfSession.hpp>
29 #include <RCF/SerializationProtocol.hpp>
30 #include <RCF/ThreadLocalData.hpp>
31 #include <RCF/Tools.hpp>
32 #include <RCF/TypeTraits.hpp>
33 #include <RCF/Version.hpp>
35 #include <boost/mpl/and.hpp>
36 #include <boost/mpl/assert.hpp>
37 #include <boost/mpl/and.hpp>
38 #include <boost/mpl/if.hpp>
39 #include <boost/mpl/not.hpp>
40 #include <boost/mpl/or.hpp>
41 #include <boost/scoped_ptr.hpp>
42 #include <boost/static_assert.hpp>
43 #include <boost/type_traits.hpp>
46 #include <SF/memory.hpp>
49 #if RCF_FEATURE_BOOST_SERIALIZATION==1
50 #include <RCF/BsAutoPtr.hpp>
51 #include <boost/serialization/binary_object.hpp>
54 #include <SF/Tools.hpp>
63 #define RCF_DEFINE_PRIMITIVE_POINTER_SERIALIZATION(type) \
64 inline void serializeImpl( \
65 SerializationProtocolOut &out, \
69 serializeImpl(out, *pt, 0); \
72 inline void serializeImpl( \
73 SerializationProtocolOut &out, \
77 serializeImpl(out, *pt, 0); \
80 inline void deserializeImpl( \
81 SerializationProtocolIn &in, \
85 RCF_ASSERT(pt==NULL); \
87 deserializeImpl(in, *pt, 0); \
90 SF_FOR_EACH_FUNDAMENTAL_TYPE( RCF_DEFINE_PRIMITIVE_POINTER_SERIALIZATION )
92 #define RCF_DEFINE_PRIMITIVE_POINTER_SERIALIZATION_T3(type) \
93 template<typename T1, typename T2, typename T3> \
94 inline void serializeImpl( \
95 SerializationProtocolOut &out, \
96 const type<T1,T2,T3> *pt, \
99 serializeImpl(out, *pt, 0); \
102 template<typename T1, typename T2, typename T3> \
103 inline void serializeImpl( \
104 SerializationProtocolOut &out, \
105 type<T1,T2,T3> *const pt, \
108 serializeImpl(out, *pt, 0); \
111 template<typename T1, typename T2, typename T3> \
112 inline void deserializeImpl( \
113 SerializationProtocolIn &in, \
114 type<T1,T2,T3> *&pt, \
117 RCF_ASSERT(pt==NULL); \
118 pt = new type<T1,T2,T3>(); \
119 deserializeImpl(in, *pt, 0); \
122 #if RCF_FEATURE_BOOST_SERIALIZATION==1
124 RCF_DEFINE_PRIMITIVE_POINTER_SERIALIZATION_T3(std::basic_string)
128 #undef RCF_DEFINE_PRIMITIVE_POINTER_SERIALIZATION
130 #undef RCF_DEFINE_PRIMITIVE_POINTER_SERIALIZATION_T3
134 #define RefCountSmartPtr boost::shared_ptr
137 inline void serializeImpl(
138 SerializationProtocolOut &out,
139 const RefCountSmartPtr<T> *spt,
142 serialize(out, *spt);
146 inline void serializeImpl(
147 SerializationProtocolOut &out,
148 RefCountSmartPtr<T> *
const spt,
151 serialize(out, *spt);
155 inline void deserializeImpl(
156 SerializationProtocolIn &in,
157 RefCountSmartPtr<T> *&spt,
160 spt =
new RefCountSmartPtr<T>();
161 deserialize(in, *spt);
165 inline void serializeImpl(
166 SerializationProtocolOut &out,
167 const RefCountSmartPtr<T> &spt,
170 serialize(out, spt.get());
174 inline void deserializeImpl(
175 SerializationProtocolIn &in,
176 RefCountSmartPtr<T> &spt,
181 spt = RefCountSmartPtr<T>(pt);
184 #undef RefCountSmartPtr
186 #if RCF_FEATURE_BOOST_SERIALIZATION==1
189 namespace boost {
namespace serialization {
191 template<
class Archive>
192 void save(Archive & ar,
const RCF::ByteBuffer &byteBuffer,
unsigned int)
197 boost::uint32_t len = byteBuffer.getLength();
199 ar & make_binary_object(byteBuffer.getPtr(), len);
203 template<
class Archive>
204 void load(Archive &ar, RCF::ByteBuffer &byteBuffer,
unsigned int)
209 boost::uint32_t len = 0;
212 RCF::ReallocBufferPtr bufferPtr = RCF::getObjectPool().getReallocBufferPtr();
213 bufferPtr->resize(len);
214 byteBuffer = RCF::ByteBuffer(bufferPtr);
216 ar & make_binary_object(byteBuffer.getPtr(), byteBuffer.getLength());
221 BOOST_SERIALIZATION_SPLIT_FREE(RCF::ByteBuffer);
224 #endif // RCF_FEATURE_BOOST_SERIALIZATION==1
231 bool serializeOverride(SerializationProtocolOut &, U &)
237 bool serializeOverride(SerializationProtocolOut &, U *)
243 bool deserializeOverride(SerializationProtocolIn &, U &)
248 RCF_EXPORT
bool serializeOverride(SerializationProtocolOut &out, ByteBuffer & u);
250 RCF_EXPORT
bool serializeOverride(SerializationProtocolOut &out, ByteBuffer * pu);
252 RCF_EXPORT
bool deserializeOverride(SerializationProtocolIn &in, ByteBuffer & u);
256 template<
typename T>
void vc6DefaultInit(T *) {}
265 ParmStore() : mptPtr(), mpT(NULL)
269 ParmStore(std::vector<char> & vec) : mptPtr(), mpT(NULL)
274 void allocate(std::vector<char> & vec)
276 RCF_ASSERT(mpT == NULL);
278 getObjectPool().getObj(mptPtr,
false);
289 vec.resize(
sizeof(T));
290 mpT = (T *) & vec[0];
293 #pragma warning( push )
294 #pragma warning( disable : 4345 ) // warning C4345: behavior change: an object of POD type constructed with an initializer of the form () will be default-initialized
302 #pragma warning( pop )
310 RCF_ASSERT(mpT == NULL);
337 boost::shared_ptr<T> mptPtr;
346 Deleter(T *& pt) : mpt(pt), mDismissed(false)
351 if ( !mDismissed && mpt )
375 BOOST_MPL_ASSERT(( boost::mpl::not_< IsPointer<T> > ));
376 BOOST_MPL_ASSERT(( boost::mpl::not_< IsReference<T> > ));
378 Sm_Value(std::vector<char> & vec) : mPs(vec)
387 void set(
bool assign,
const T &t)
400 void read(SerializationProtocolIn &in)
402 if (in.getRemainingArchiveLength() != 0)
404 if (!deserializeOverride(in, *mPs))
406 deserialize(in, *mPs);
411 void write(SerializationProtocolOut &)
425 Sm_Value(std::vector<char> &)
440 void set(bool ,
const Void &)
445 void set(
const Void &)
450 void read(SerializationProtocolIn &)
455 void write(SerializationProtocolOut &)
466 BOOST_MPL_ASSERT(( boost::mpl::not_< IsPointer<T> > ));
467 BOOST_MPL_ASSERT(( boost::mpl::not_< IsReference<T> > ));
469 Sm_Ret(std::vector<char> & vec) : mPs(vec)
478 void set(
bool assign,
const T &t)
491 void read(SerializationProtocolIn &)
496 void write(SerializationProtocolOut &out)
498 if (!serializeOverride(out, *mPs))
500 serialize(out, *mPs);
508 template<
typename CRefT>
513 typedef typename RemoveReference<CRefT>::type CT;
514 typedef typename RemoveCv<CT>::type T;
515 BOOST_MPL_ASSERT(( IsReference<CRefT> ));
517 BOOST_MPL_ASSERT(( IsConst<CT> ));
519 BOOST_MPL_ASSERT(( boost::mpl::not_< IsPointer<T> > ));
521 Sm_CRef(std::vector<char> & vec) : mPs(), mVec(vec)
529 void set(
bool assign,
const T &t)
542 void read(SerializationProtocolIn &in)
544 if (in.getRemainingArchiveLength() != 0)
546 int ver = in.getRuntimeVersion();
553 Deleter<T> deleter(pt);
562 deserialize(in, *mPs);
570 int sp = in.getSerializationProtocol();
571 if ( (sp == Sp_SfBinary || sp == Sp_SfText)
572 && getObjectPool().isCachingEnabled( (T *) NULL ))
575 deserialize(in, *mPs);
580 Deleter<T> deleter(pt);
584 RCF::Exception e(RCF::_RcfError_DeserializationNullPointer());
598 void write(SerializationProtocolOut &)
605 std::vector<char> & mVec;
608 template<
typename RefT>
613 typedef typename RemoveReference<RefT>::type T;
614 typedef typename RemoveCv<T>::type U;
615 BOOST_MPL_ASSERT(( IsReference<RefT> ));
616 BOOST_MPL_ASSERT(( boost::mpl::not_< IsPointer<T> > ));
618 Sm_Ref(std::vector<char> & vec) : mVec(vec)
626 void set(
bool assign,
const T &t)
639 void read(SerializationProtocolIn &in)
641 if (in.getRemainingArchiveLength() != 0)
643 int ver = in.getRuntimeVersion();
650 Deleter<T> deleter(pt);
660 deserialize(in, *mPs);
668 int sp = in.getSerializationProtocol();
669 if ( (sp == Sp_SfBinary || sp == Sp_SfText)
670 && getObjectPool().isCachingEnabled( (T *) NULL ))
673 deserialize(in, *mPs);
678 Deleter<T> deleter(pt);
682 RCF::Exception e(RCF::_RcfError_DeserializationNullPointer());
696 void write(SerializationProtocolOut &out)
698 RCF_ASSERT(mPs.get());
700 if (!serializeOverride(out, *mPs))
706 serialize(out, *mPs);
712 std::vector<char> & mVec;
715 template<
typename OutRefT>
720 typedef typename RemoveOut<OutRefT>::type RefT;
721 typedef typename RemoveReference<RefT>::type T;
722 typedef typename RemoveCv<T>::type U;
723 BOOST_MPL_ASSERT(( IsReference<RefT> ));
724 BOOST_MPL_ASSERT(( boost::mpl::not_< IsPointer<T> > ));
726 Sm_OutRef(std::vector<char> & vec) : mPs(vec)
735 void set(
bool assign,
const T &t)
748 void read(SerializationProtocolIn &)
753 void write(SerializationProtocolOut &out)
755 if (!serializeOverride(out, *mPs))
761 serialize(out, *mPs);
769 template<
typename PtrT>
774 typedef typename RemovePointer<PtrT>::type T;
775 typedef typename RemoveCv<T>::type U;
776 BOOST_MPL_ASSERT(( IsPointer<PtrT> ));
777 BOOST_MPL_ASSERT(( boost::mpl::not_< IsPointer<T> > ));
779 Sm_Ptr(std::vector<char> &)
787 void set(
bool assign,
const T &t)
800 void read(SerializationProtocolIn &in)
802 if (in.getRemainingArchiveLength() != 0)
805 Deleter<T> deleter(pt);
812 void write(SerializationProtocolOut &)
829 BOOST_MPL_ASSERT(( boost::mpl::not_< IsPointer<T> > ));
830 BOOST_MPL_ASSERT(( boost::mpl::not_< IsReference<T> > ));
834 RCF::ClientStub * pClientStub = getTlsClientStubPtr();
835 std::vector<char> & vec = pClientStub->getRetValVec();
844 void set(
bool assign,
const T &t)
857 void read(SerializationProtocolIn &in)
859 if (in.getRemainingArchiveLength() != 0)
861 if (!deserializeOverride(in, *mPs))
863 deserialize(in, *mPs);
868 void write(SerializationProtocolOut &)
882 BOOST_MPL_ASSERT(( boost::mpl::not_< IsPointer<T> > ));
883 BOOST_MPL_ASSERT(( boost::mpl::not_< IsReference<T> > ));
887 Cm_Value(
const T &t) : mT( const_cast<T &>(t) )
896 void read(SerializationProtocolIn &in)
898 RCF_UNUSED_VARIABLE(in);
901 void write(SerializationProtocolOut &out)
903 if (!serializeOverride(out, mT))
913 template<
typename PtrT>
918 typedef typename RemovePointer<PtrT>::type T;
920 BOOST_MPL_ASSERT(( IsPointer<PtrT> ));
922 BOOST_MPL_ASSERT(( boost::mpl::not_< IsPointer<T> > ));
927 Cm_Ptr(T * pt) : mpT(pt)
936 void read(SerializationProtocolIn &in)
938 RCF_UNUSED_VARIABLE(in);
941 void write(SerializationProtocolOut &out)
950 template<
typename CRefT>
955 typedef typename RemoveReference<CRefT>::type CT;
956 typedef typename RemoveCv<CT>::type T;
957 BOOST_MPL_ASSERT(( IsReference<CRefT> ));
959 BOOST_MPL_ASSERT(( IsConst<CT> ));
961 BOOST_MPL_ASSERT(( boost::mpl::not_< IsPointer<T> > ));
963 Cm_CRef(
const T &t) : mT(t)
971 void read(SerializationProtocolIn &in)
973 RCF_UNUSED_VARIABLE(in);
976 void write(SerializationProtocolOut &out)
978 int ver = out.getRuntimeVersion();
997 template<
typename RefT>
1002 typedef typename RemoveReference<RefT>::type T;
1003 BOOST_MPL_ASSERT(( IsReference<RefT> ));
1004 BOOST_MPL_ASSERT(( boost::mpl::not_< IsConst<RefT> > ));
1005 BOOST_MPL_ASSERT(( boost::mpl::not_< IsPointer<T> > ));
1007 Cm_Ref(T &t) : mT(t)
1015 void read(SerializationProtocolIn &in)
1017 if (in.getRemainingArchiveLength() != 0)
1019 if (!deserializeOverride(in, mT))
1021 deserialize(in, mT);
1026 void write(SerializationProtocolOut &out)
1028 int ver = out.getRuntimeVersion();
1031 serialize(out, &mT);
1039 serialize(out, &mT);
1047 template<
typename OutRefT>
1052 typedef typename RemoveOut<OutRefT>::type RefT;
1053 typedef typename RemoveReference<RefT>::type T;
1054 BOOST_MPL_ASSERT(( IsReference<RefT> ));
1055 BOOST_MPL_ASSERT(( boost::mpl::not_< IsConst<RefT> > ));
1056 BOOST_MPL_ASSERT(( boost::mpl::not_< IsPointer<T> > ));
1058 Cm_OutRef(T &t) : mT(t)
1066 void read(SerializationProtocolIn &in)
1068 if (in.getRemainingArchiveLength() != 0)
1070 if (!deserializeOverride(in, mT))
1072 deserialize(in, mT);
1077 void write(SerializationProtocolOut &)
1086 template<
typename T>
1087 struct IsConstReference
1092 IsConst< typename RemoveReference<T>::type >
1095 enum { value = type::value };
1098 template<
typename T>
1099 struct ServerMarshalRet
1103 boost::is_same<void, T>,
1105 Sm_Ret<T> >::type type;
1108 template<
typename T>
1109 struct ServerMarshal
1115 typename boost::mpl::if_<
1116 IsConstReference<T>,
1118 typename boost::mpl::if_<
1121 typename boost::mpl::if_<
1134 template<
typename T>
1135 struct ClientMarshal
1141 typename boost::mpl::if_<
1142 IsConstReference<T>,
1144 typename boost::mpl::if_<
1147 typename boost::mpl::if_<
1163 template<
typename T>
1170 typename boost::mpl::if_<
1172 typename boost::add_reference<T>::type,
1173 typename boost::add_reference<
1174 typename boost::add_const<T>::type
1183 virtual ~I_Parameters() {}
1184 virtual void read(SerializationProtocolIn &in) = 0;
1185 virtual void write(SerializationProtocolOut &out) = 0;
1186 virtual bool enrolFutures(RCF::ClientStub *pClientStub) = 0;
1189 template<
typename T>
1190 struct IsInParameter
1192 typedef typename boost::mpl::not_< boost::is_same<T,Void> >::type NotVoid;
1193 typedef typename boost::mpl::not_< IsOut<T> >::type NotExplicitOutParameter;
1195 typedef typename boost::mpl::and_<
1197 NotExplicitOutParameter
1200 enum { value = type::value };
1203 template<
typename T>
1204 struct IsOutParameter
1211 typename RemoveReference<T>::type
1214 >::type NonConstRef_;
1216 typedef typename IsOut<T>::type ExplicitOutParameter;
1225 enum { value = NonConstRef_::value || ExplicitOutParameter::value };
1228 template<
typename T>
1229 struct IsReturnValue
1231 typedef typename boost::mpl::not_< boost::is_same<T, Void> >::type type;
1232 enum { value = type::value };
1238 I_Future * find(
const void * pv)
1240 I_Future * pFuture = NULL;
1241 for (std::size_t i=0; i<mCandidateList.size(); ++i)
1243 if (mCandidateList[i].first == pv)
1245 RCF_ASSERT(!pFuture);
1246 pFuture = mCandidateList[i].second;
1252 void erase(
const void * pv)
1254 for (std::size_t i=0; i<mCandidateList.size(); ++i)
1256 if (mCandidateList[i].first == pv)
1258 mCandidateList.erase( mCandidateList.begin() + i );
1265 void add(
const void * pv, I_Future * pFuture)
1267 for (std::size_t i=0; i<mCandidateList.size(); ++i)
1269 if (mCandidateList[i].first == pv)
1271 mCandidateList[i].second = pFuture;
1275 mCandidateList.push_back( std::make_pair(pv, pFuture) );
1280 typedef std::vector< std::pair<const void *, I_Future *> > CandidateList;
1281 CandidateList mCandidateList;
1286 RCF_EXPORT Mutex & gCandidatesMutex();
1287 RCF_EXPORT Candidates & gCandidates();
1306 class ClientParameters :
public I_Parameters
1310 typedef typename RemoveOut<A1 >::type A1_;
1311 typedef typename RemoveOut<A2 >::type A2_;
1312 typedef typename RemoveOut<A3 >::type A3_;
1313 typedef typename RemoveOut<A4 >::type A4_;
1314 typedef typename RemoveOut<A5 >::type A5_;
1315 typedef typename RemoveOut<A6 >::type A6_;
1316 typedef typename RemoveOut<A7 >::type A7_;
1317 typedef typename RemoveOut<A8 >::type A8_;
1318 typedef typename RemoveOut<A9 >::type A9_;
1319 typedef typename RemoveOut<A10>::type A10_;
1320 typedef typename RemoveOut<A11>::type A11_;
1321 typedef typename RemoveOut<A12>::type A12_;
1322 typedef typename RemoveOut<A13>::type A13_;
1323 typedef typename RemoveOut<A14>::type A14_;
1324 typedef typename RemoveOut<A15>::type A15_;
1326 typedef typename ReferenceTo<A1_ >::type A1Ref;
1327 typedef typename ReferenceTo<A2_ >::type A2Ref;
1328 typedef typename ReferenceTo<A3_ >::type A3Ref;
1329 typedef typename ReferenceTo<A4_ >::type A4Ref;
1330 typedef typename ReferenceTo<A5_ >::type A5Ref;
1331 typedef typename ReferenceTo<A6_ >::type A6Ref;
1332 typedef typename ReferenceTo<A7_ >::type A7Ref;
1333 typedef typename ReferenceTo<A8_ >::type A8Ref;
1334 typedef typename ReferenceTo<A9_ >::type A9Ref;
1335 typedef typename ReferenceTo<A10_>::type A10Ref;
1336 typedef typename ReferenceTo<A11_>::type A11Ref;
1337 typedef typename ReferenceTo<A12_>::type A12Ref;
1338 typedef typename ReferenceTo<A13_>::type A13Ref;
1339 typedef typename ReferenceTo<A14_>::type A14Ref;
1340 typedef typename ReferenceTo<A15_>::type A15Ref;
1343 A1Ref a1, A2Ref a2, A3Ref a3, A4Ref a4, A5Ref a5, A6Ref a6,
1344 A7Ref a7, A8Ref a8, A9Ref a9, A10Ref a10, A11Ref a11, A12Ref a12,
1345 A13Ref a13, A14Ref a14, A15Ref a15) :
1346 a1(a1), a2(a2), a3(a3), a4(a4), a5(a5), a6(a6), a7(a7), a8(a8),
1347 a9(a9), a10(a10), a11(a11), a12(a12), a13(a13), a14(a14), a15(a15)
1351 void read(SerializationProtocolIn &in)
1353 if (IsReturnValue<R>::value) r.read(in);
1354 if (IsOutParameter<A1 >::value) a1.read(in);
1355 if (IsOutParameter<A2 >::value) a2.read(in);
1356 if (IsOutParameter<A3 >::value) a3.read(in);
1357 if (IsOutParameter<A4 >::value) a4.read(in);
1358 if (IsOutParameter<A5 >::value) a5.read(in);
1359 if (IsOutParameter<A6 >::value) a6.read(in);
1360 if (IsOutParameter<A7 >::value) a7.read(in);
1361 if (IsOutParameter<A8 >::value) a8.read(in);
1362 if (IsOutParameter<A9 >::value) a9.read(in);
1363 if (IsOutParameter<A10>::value) a10.read(in);
1364 if (IsOutParameter<A11>::value) a11.read(in);
1365 if (IsOutParameter<A12>::value) a12.read(in);
1366 if (IsOutParameter<A13>::value) a13.read(in);
1367 if (IsOutParameter<A14>::value) a14.read(in);
1368 if (IsOutParameter<A15>::value) a15.read(in);
1371 void write(SerializationProtocolOut &out)
1373 if (IsInParameter<A1 >::value) a1.write(out);
1374 if (IsInParameter<A2 >::value) a2.write(out);
1375 if (IsInParameter<A3 >::value) a3.write(out);
1376 if (IsInParameter<A4 >::value) a4.write(out);
1377 if (IsInParameter<A5 >::value) a5.write(out);
1378 if (IsInParameter<A6 >::value) a6.write(out);
1379 if (IsInParameter<A7 >::value) a7.write(out);
1380 if (IsInParameter<A8 >::value) a8.write(out);
1381 if (IsInParameter<A9 >::value) a9.write(out);
1382 if (IsInParameter<A10>::value) a10.write(out);
1383 if (IsInParameter<A11>::value) a11.write(out);
1384 if (IsInParameter<A12>::value) a12.write(out);
1385 if (IsInParameter<A13>::value) a13.write(out);
1386 if (IsInParameter<A14>::value) a14.write(out);
1387 if (IsInParameter<A15>::value) a15.write(out);
1390 bool enrolFutures(RCF::ClientStub *pClientStub)
1392 bool enrolled =
false;
1394 const void * pva[] = {
1412 for (std::size_t i=0; i<
sizeof(pva)/
sizeof(pva[0]); ++i)
1414 const void *pv = pva[i];
1415 I_Future * pFuture = NULL;
1418 Lock lock(gCandidatesMutex());
1419 pFuture = gCandidates().find(pv);
1422 gCandidates().erase(pv);
1428 pClientStub->enrol( pFuture );
1437 typename ClientMarshal<A1>::type a1;
1438 typename ClientMarshal<A2>::type a2;
1439 typename ClientMarshal<A3>::type a3;
1440 typename ClientMarshal<A4>::type a4;
1441 typename ClientMarshal<A5>::type a5;
1442 typename ClientMarshal<A6>::type a6;
1443 typename ClientMarshal<A7>::type a7;
1444 typename ClientMarshal<A8>::type a8;
1445 typename ClientMarshal<A9>::type a9;
1446 typename ClientMarshal<A10>::type a10;
1447 typename ClientMarshal<A11>::type a11;
1448 typename ClientMarshal<A12>::type a12;
1449 typename ClientMarshal<A13>::type a13;
1450 typename ClientMarshal<A14>::type a14;
1451 typename ClientMarshal<A15>::type a15;
1471 class AllocateClientParameters
1475 typedef typename RemoveOut<A1 >::type A1_;
1476 typedef typename RemoveOut<A2 >::type A2_;
1477 typedef typename RemoveOut<A3 >::type A3_;
1478 typedef typename RemoveOut<A4 >::type A4_;
1479 typedef typename RemoveOut<A5 >::type A5_;
1480 typedef typename RemoveOut<A6 >::type A6_;
1481 typedef typename RemoveOut<A7 >::type A7_;
1482 typedef typename RemoveOut<A8 >::type A8_;
1483 typedef typename RemoveOut<A9 >::type A9_;
1484 typedef typename RemoveOut<A10>::type A10_;
1485 typedef typename RemoveOut<A11>::type A11_;
1486 typedef typename RemoveOut<A12>::type A12_;
1487 typedef typename RemoveOut<A13>::type A13_;
1488 typedef typename RemoveOut<A14>::type A14_;
1489 typedef typename RemoveOut<A15>::type A15_;
1491 typedef typename ReferenceTo<A1_ >::type A1Ref;
1492 typedef typename ReferenceTo<A2_ >::type A2Ref;
1493 typedef typename ReferenceTo<A3_ >::type A3Ref;
1494 typedef typename ReferenceTo<A4_ >::type A4Ref;
1495 typedef typename ReferenceTo<A5_ >::type A5Ref;
1496 typedef typename ReferenceTo<A6_ >::type A6Ref;
1497 typedef typename ReferenceTo<A7_ >::type A7Ref;
1498 typedef typename ReferenceTo<A8_ >::type A8Ref;
1499 typedef typename ReferenceTo<A9_ >::type A9Ref;
1500 typedef typename ReferenceTo<A10_>::type A10Ref;
1501 typedef typename ReferenceTo<A11_>::type A11Ref;
1502 typedef typename ReferenceTo<A12_>::type A12Ref;
1503 typedef typename ReferenceTo<A13_>::type A13Ref;
1504 typedef typename ReferenceTo<A14_>::type A14Ref;
1505 typedef typename ReferenceTo<A15_>::type A15Ref;
1507 typedef ClientParameters<
1509 A1, A2, A3, A4, A5, A6, A7, A8,
1510 A9, A10, A11, A12, A13, A14, A15> ParametersT;
1513 ParametersT &operator()(
1514 ClientStub &clientStub,
1531 CurrentClientStubSentry sentry(clientStub);
1533 clientStub.clearParameters();
1535 clientStub.mParametersVec.resize(
sizeof(ParametersT));
1537 clientStub.mpParameters =
new ( &clientStub.mParametersVec[0] )
1539 a1,a2,a3,a4,a5,a6,a7,a8,
1540 a9,a10,a11,a12,a13,a14,a15);
1542 if (!clientStub.mpParameters)
1544 Exception e(_RcfError_ClientStubParms());
1548 return static_cast<ParametersT &
>(*clientStub.mpParameters);
1563 typename A10 = Void,
1564 typename A11 = Void,
1565 typename A12 = Void,
1566 typename A13 = Void,
1567 typename A14 = Void,
1568 typename A15 = Void>
1569 class ServerParameters :
public I_Parameters
1573 ServerParameters(RcfSession &session) :
1574 r(session.mParmsVec[0]),
1575 a1(session.mParmsVec[1]),
1576 a2(session.mParmsVec[2]),
1577 a3(session.mParmsVec[3]),
1578 a4(session.mParmsVec[4]),
1579 a5(session.mParmsVec[5]),
1580 a6(session.mParmsVec[6]),
1581 a7(session.mParmsVec[7]),
1582 a8(session.mParmsVec[8]),
1583 a9(session.mParmsVec[9]),
1584 a10(session.mParmsVec[10]),
1585 a11(session.mParmsVec[11]),
1586 a12(session.mParmsVec[12]),
1587 a13(session.mParmsVec[13]),
1588 a14(session.mParmsVec[14]),
1589 a15(session.mParmsVec[15])
1594 void read(SerializationProtocolIn &in)
1596 if (IsInParameter<A1 >::value) a1.read(in);
1597 if (IsInParameter<A2 >::value) a2.read(in);
1598 if (IsInParameter<A3 >::value) a3.read(in);
1599 if (IsInParameter<A4 >::value) a4.read(in);
1600 if (IsInParameter<A5 >::value) a5.read(in);
1601 if (IsInParameter<A6 >::value) a6.read(in);
1602 if (IsInParameter<A7 >::value) a7.read(in);
1603 if (IsInParameter<A8 >::value) a8.read(in);
1604 if (IsInParameter<A9 >::value) a9.read(in);
1605 if (IsInParameter<A10>::value) a10.read(in);
1606 if (IsInParameter<A11>::value) a11.read(in);
1607 if (IsInParameter<A12>::value) a12.read(in);
1608 if (IsInParameter<A13>::value) a13.read(in);
1609 if (IsInParameter<A14>::value) a14.read(in);
1610 if (IsInParameter<A15>::value) a15.read(in);
1613 void write(SerializationProtocolOut &out)
1615 if (IsReturnValue<R>::value) r.write(out);
1616 if (IsOutParameter<A1>::value) a1.write(out);
1617 if (IsOutParameter<A2>::value) a2.write(out);
1618 if (IsOutParameter<A3>::value) a3.write(out);
1619 if (IsOutParameter<A4>::value) a4.write(out);
1620 if (IsOutParameter<A5>::value) a5.write(out);
1621 if (IsOutParameter<A6>::value) a6.write(out);
1622 if (IsOutParameter<A7>::value) a7.write(out);
1623 if (IsOutParameter<A8>::value) a8.write(out);
1624 if (IsOutParameter<A9>::value) a9.write(out);
1625 if (IsOutParameter<A10>::value) a10.write(out);
1626 if (IsOutParameter<A11>::value) a11.write(out);
1627 if (IsOutParameter<A12>::value) a12.write(out);
1628 if (IsOutParameter<A13>::value) a13.write(out);
1629 if (IsOutParameter<A14>::value) a14.write(out);
1630 if (IsOutParameter<A15>::value) a15.write(out);
1634 bool enrolFutures(RCF::ClientStub *)
1640 typename ServerMarshalRet<R>::type r;
1641 typename ServerMarshal<A1>::type a1;
1642 typename ServerMarshal<A2>::type a2;
1643 typename ServerMarshal<A3>::type a3;
1644 typename ServerMarshal<A4>::type a4;
1645 typename ServerMarshal<A5>::type a5;
1646 typename ServerMarshal<A6>::type a6;
1647 typename ServerMarshal<A7>::type a7;
1648 typename ServerMarshal<A8>::type a8;
1649 typename ServerMarshal<A9>::type a9;
1650 typename ServerMarshal<A10>::type a10;
1651 typename ServerMarshal<A11>::type a11;
1652 typename ServerMarshal<A12>::type a12;
1653 typename ServerMarshal<A13>::type a13;
1654 typename ServerMarshal<A14>::type a14;
1655 typename ServerMarshal<A15>::type a15;
1658 typedef boost::shared_ptr<I_Parameters> ParametersPtr;
1671 typename A10 = Void,
1672 typename A11 = Void,
1673 typename A12 = Void,
1674 typename A13 = Void,
1675 typename A14 = Void,
1676 typename A15 = Void>
1677 class AllocateServerParameters
1680 typedef ServerParameters<
1682 A1, A2, A3, A4, A5, A6, A7, A8,
1683 A9, A10, A11, A12, A13, A14, A15> ParametersT;
1685 ParametersT &operator()(RcfSession &session)
const
1687 session.clearParameters();
1689 session.mParametersVec.resize(
sizeof(ParametersT));
1691 session.mpParameters =
new
1692 ( &session.mParametersVec[0] )
1693 ParametersT(session);
1695 if (!session.mpParameters)
1697 Exception e(_RcfError_ServerStubParms());
1701 return static_cast<ParametersT &
>(*session.mpParameters);
1707 RCF_EXPORT
void convertRcfSessionToRcfClient(
1708 OnCallbackConnectionCreated func,
1709 RemoteCallSemantics rcs = RCF::Twoway);
1712 RCF_EXPORT RcfSessionPtr convertRcfClientToRcfSession(
1713 ClientStub & clientStub,
1714 ServerTransport & serverTransport,
1715 bool keepClientConnection =
false);
1717 RCF_EXPORT RcfSessionPtr convertRcfClientToRcfSession(
1718 ClientStub & clientStub,
1720 bool keepClientConnection =
false);
1723 template<
typename RcfClientT>
1724 inline RcfSessionPtr convertRcfClientToRcfSession(
1725 RcfClientT & client,
1727 bool keepClientConnection =
false)
1729 return convertRcfClientToRcfSession(
1730 client.getClientStub(),
1732 keepClientConnection);
1735 template<
typename RcfClientT>
1736 inline RcfSessionPtr convertRcfClientToRcfSession(
1737 RcfClientT & client,
1738 ServerTransport & serverTransport,
1739 bool keepClientConnection =
false)
1741 return convertRcfClientToRcfSession(
1742 client.getClientStub(),
1744 keepClientConnection);
1749 RCF_EXPORT
void createCallbackConnectionImpl(
1750 ClientStub & client,
1751 ServerTransport & callbackServer);
1753 RCF_EXPORT
void createCallbackConnectionImpl_Legacy(
1754 ClientStub & client,
1755 ServerTransport & callbackServer);
1757 RCF_EXPORT
void createCallbackConnectionImpl(
1758 ClientStub & client,
1759 RcfServer & callbackServer);
1763 template<
typename RcfClientT>
1764 void createCallbackConnection(
1765 RcfClientT & client,
1766 RcfServer & callbackServer)
1768 createCallbackConnectionImpl(
1769 client.getClientStub(),
1773 template<
typename RcfClientT>
1774 void createCallbackConnectionImpl(
1775 RcfClientT & client,
1776 ServerTransport & callbackServer)
1778 createCallbackConnection(
1779 client.getClientStub(),
1785 #endif // ! INCLUDE_RCF_MARSHAL_HPP