serialization library - reloading objects
Hello, All! Are there any way to load existing objects by base class pointer without creating new? Examination of input archives source code does not give me any idea how I can achieve it. I think I need some mechanism for runtime switching archive object tracking behaviour in that way so all objects will interpreted as already created (or per-object tracking registration without actual object loading to pre-register pointer to object as already created before object loading). With best regards, Sergey.
Hmmm - I've considered that in the past in order to implement a "memento archive" that could be used for do/undo functionality. This wouldn't be too hard as it would be an derivation from any existing archive which specializes the archive save/load member templates for pointers. In considering this, a couple of quesions come to mind like: a) for collections, what if members are added/deleted between the save and load. b) This would basically replace the deep class assignment capability which is often already built-in. Its not clear that using the serialization is any better. Robert Ramey "Sergey Skorniakov" <s.skorniakov@megaputer.ru> wrote in message news:copc31$q23$1@sea.gmane.org...
Hello, All!
Are there any way to load existing objects by base class pointer without creating new? Examination of input archives source code does not give me any idea how I can achieve it. I think I need some mechanism for runtime switching archive object tracking behaviour in that way so all objects will interpreted as already created (or per-object tracking registration without actual object loading to pre-register pointer to object as already created before object loading).
With best regards, Sergey.
Hello, Robert! You wrote on Fri, 3 Dec 2004 08:25:02 -0800: RR> Hmmm - I've considered that in the past in order to implement a RR> "memento archive" that could be used for do/undo functionality. This RR> wouldn't be too hard as it would be an derivation from any existing RR> archive which specializes the archive save/load member templates for RR> pointers. Thanks, I'll try to do it. RR> In considering this, a couple of quesions come to mind like: RR> a) for collections, what if members are added/deleted between the save RR> and load. In my case, it is impossible. I'm writing custom RPC and has difficulties with returning function arguments by reference or pointer. RR> b) This would basically replace the deep class assignment capability RR> which is often already built-in. Its not clear that using the RR> serialization is any better. Yes, I need exactly such a replacement. RR> Robert Ramey RR> "Sergey Skorniakov" <s.skorniakov@megaputer.ru> wrote in message RR> news:copc31$q23$1@sea.gmane.org... ??>> Hello, All! ??>> ??>> Are there any way to load existing objects by base class pointer ??>> without creating new? Examination of input archives source code does ??>> not give me any idea how I can achieve it. I think I need some ??>> mechanism for runtime switching RR> archive ??>> object tracking behaviour in that way so all objects will interpreted ??>> as already created (or per-object tracking registration without actual ??>> object loading to pre-register pointer to object as already created ??>> before object loading). With best regards, Sergey. With best regards, Sergey.
Hello, Robert! You wrote on Fri, 3 Dec 2004 08:25:02 -0800: RR> Hmmm - I've considered that in the past in order to implement a RR> "memento archive" that could be used for do/undo functionality. This RR> wouldn't be too hard as it would be an derivation from any existing RR> archive which specializes the archive save/load member templates for RR> pointers. Its look like that I need to reimplement the whole basic_iarchive_impl. Am I right? With best regards, Sergey.
Note: the following is just speculation on my part - take with a grain of salt. "Sergey Skorniakov" <s.skorniakov@megaputer.ru> wrote in message news:cp20fa$kbh$1@sea.gmane.org...
Hello, Robert! You wrote on Fri, 3 Dec 2004 08:25:02 -0800:
RR> Hmmm - I've considered that in the past in order to implement a RR> "memento archive" that could be used for do/undo functionality. This RR> wouldn't be too hard as it would be an derivation from any existing RR> archive which specializes the archive save/load member templates for RR> pointers.
Its look like that I need to reimplement the whole basic_iarchive_impl. Am I right?
I don't think that would be necessary nor would it be desirable. The way I would go about is to make an "memento_iarchive" class as an "archive adaptor". This template would be used to alter the function of any other existing archive to convert it into a "memento" archive. See attached sample. This sample adapts any existing archive class to a "memento" equivalent by overriding the serialization of pointers to simple copy of the de-referenced data. The attached sample does compile on two compilers. Good Luck Robert Ramey begin 666 memento_iarchive.hpp M+R\@;65M96YT;R!A<F-H:79E(&%D87!T;W(N("!#;VYV97)T<R!A;GD@87)C M:&EV92!I;G1O(&$@;65M96YT;PT*+R\@87)C:&EV92!W:&EC:"!J=7-T(&-O M<&EE<R!P;VEN=&5R(&1A=&$@<F%T:&5R('1H86X@<F5C<F5A=&EN9PT*+R\@ M=&AE(&]B:F5C=',@<&]I;G1E9"!T;SH-"@T*+R\@=&AI<R!I;7!L96UE;G1A M=&EO;B!A<W-U;65S('1H870@=&AE(&-O;7!I;&5R('-U<'!O<G1S#0HO+R!P M87)T:6%L(&9U;F-T:6]N('1E;7!L871E(&]R9&5R:6YG+B @02!M;W)E(&=E M;F5R86P@:6UP;&5M96YT#0HO+R!W;W5L9"!H879E('1O(&)E(&$@;&ET=&QE M(&UO<F4@96QA8F]R871E#0IT96UP;&%T93QC;&%S<R!"87-E07)C:&EV93X- M"F-L87-S(&UE;65N=&]?:6%R8VAI=F4@.@T*(" @('!U8FQI8R!"87-E07)C M:&EV90T*>PT*<'5B;&EC.@T*(" @("\O('-P96-I86P@<')O8V5S<VEN9R!F M;W(@<&]I;G1E<G,-"B @("!T96UP;&%T93QC;&%S<R!4/@T*(" @('9O:60@ M;&]A9%]O=F5R<FED92A4("H@)B!T+" O*D)/3U-47U!&5$\J+R!I;G0I>PT* M(" @(" @(" O+R!J=7-T(&1E+7-E<FEA;&EZ92!T:&4@9&4M<F5F97)E;F-E M9"!P;VEN=&5R#0H@(" @(" @("IT:&ES(#X^("IT.PT*(" @('T-"@T*(" @ M("\O(&1E9F%U;'0@<')O8V5S<VEN9R M(&IU<W0@<&%S<R!T;R!T:&4@0F%S M92!!<F-H:79E#0H@(" @=&5M<&QA=&4\8VQA<W,@5#X-"B @("!V;VED(&QO M861?;W9E<G)I9&4H5" F('0L("\J0D]/4U1?4$943RHO(&EN="!V97)S:6]N M*7L-"B @(" @(" @0F%S94%R8VAI=F4Z.FQO861?;W9E<G)I9&4H="P@=F5R M<VEO;BD[#0H@(" @?0T*(" @("\O(&-O;G-T<G5C=&]R#0H@(" @=&5M<&QA M=&4\8VQA<W,@4W1R96%M/@T*(" @(&UE;65N=&]?:6%R8VAI=F4H4W1R96%M M("9S+"!U;G-I9VYE9"!I;G0@9FQA9W,@/2 P*2 Z#0H@(" @(" @($)A<V5! M<F-H:79E*',L(&9L86=S*0T*(" @('M]#0I].PT*#0HC:6YC;'5D92 \:7-T M<F5A;3X-"B-I;F-L=61E(#QB;V]S="]A<F-H:79E+W1E>'1?:6%R8VAI=F4N M:'!P/@T*#0HO+R!I9&5A;&QY('=E('=O=6QD(&IU<W0@9&\@=&AE(&9O;&QO M=VEN9SH-"B\O#0HO+R!T>7!E9&5F(&UE;65N=&]?:6%R8VAI=F4\8F]O<W0Z M.F%R8VAI=F4Z.G1E>'1?:6%R8VAI=F5?:6UP;#QM96UE;G1O7W1E>'1?:6%R M8VAI=F4^(#X-"B\O(" @("!M96UE;G1O7W1E>'1?:6%R8VAI=F4[#0HO+PT* M+R\@8G5T('1H97)E(&ES(&YO('-U8V@@=&AI;F<@87,@<V5L9B!R969E<F5N M8VEN9R!T>7!E9&5F+B!3;R!D969I;F4@=&AE(&9O;&QO=VEN9PT*+R\@87,@ M86X@97%U:79A;&5N="!S=6)S=&ET=71E+B @1&]N)W0@=7-E('1H:7,@9F]R M(&9U<G1H97(@9&5R:79A=&EO;B A#0IC;&%S<R!M96UE;G1O7W1E>'1?:6%R M8VAI=F4@.B -"B @("!P=6)L:6,@;65M96YT;U]I87)C:&EV93QB;V]S=#HZ M87)C:&EV93HZ=&5X=%]I87)C:&EV95]I;7!L/&UE;65N=&]?=&5X=%]I87)C M:&EV93X@/@T*>PT*<'5B;&EC.@T*(" @(&UE;65N=&]?=&5X=%]I87)C:&EV M92AS=&0Z.FES=')E86T@)B!I<RP@=6YS:6=N960@:6YT(&9L86=S(#T@,"D@ M.@T*(" @(" @("!M96UE;G1O7VEA<F-H:79E/&)O;W-T.CIA<F-H:79E.CIT M97AT7VEA<F-H:79E7VEM<&P\;65M96YT;U]T97AT7VEA<F-H:79E/B ^#0H@ M(" @(" @(" @(" H:7,L(&9L86=S*0T*(" @('M]#0I].PT*#0HO+R!T97-T M.B!D;V5S('1H:7,@870@;&5A<W0@8V]M<&EL93\-"B-I;F-L=61E(#QF<W1R M96%M/@T*#0II;G0@;6%I;B@I>PT*(" @('-T9#HZ:69S=')E86T@:7,H(G1E M<W1?9FEL92(I.PT*(" @(&UE;65N=&]?=&5X=%]I87)C:&EV92!M:6$H:7,L M(# I.PT*(" @(&EN="!X.PT*(" @(&EN=" J>'!T<B ]("9X.PT*(" @(&UI @82 ^/B!X.PT*(" @(&UI82 ^/B!X<'1R.PT*?0T*#0H` ` end
Hello, Robert! You wrote on Mon, 6 Dec 2004 10:25:07 -0800: ??>> ??>> Its look like that I need to reimplement the whole ??>> basic_iarchive_impl. Am RR> I ??>> right? ??>> RR> I don't think that would be necessary nor would it be desirable. RR> The way I would go about is to make an "memento_iarchive" class as an RR> "archive adaptor". This template would be used to alter the function RR> of any other existing archive to convert it into a "memento" archive. RR> See attached sample. This sample adapts any existing archive class to RR> a "memento" equivalent by overriding the serialization of pointers to RR> simple copy of the de-referenced data. Thanks, Robert. This great! No one can say why I tried to override load_pointer member. If I already know real object types, I can just create special output archive and load objects with incompatible input archives, without worring about tracking and object creation stuff. This works fine. With best regards, Sergey.
Hello, Sergey! You wrote to Robert Ramey on Tue, 7 Dec 2004 12:42:01 +0300: SS> Thanks, Robert. This great! No one can say why I tried to override SS> load_pointer member. If I already know real object types, I can just SS> create special output archive and load objects with incompatible input SS> archives, without worring about tracking and object creation stuff. SS> This works fine. Unfortunately, I was to hasty with conlusions - this solution doesn't work when objects serialized by base class pointers. With best regards, Sergey.
As usual, things turn out to be more complex than first meets the eye. I believe this could be addressed by making our implementation of memento_iarchive adaptor a little more elaborate. Perhaps this could be done by overloading the following from iserializer.hpp "Sergey Skorniakov" <s.skorniakov@megaputer.ru> wrote in message news:cp4hbt$vqm$1@sea.gmane.org...
Hello, Sergey! You wrote to Robert Ramey on Tue, 7 Dec 2004 12:42:01 +0300:
SS> Thanks, Robert. This great! No one can say why I tried to override SS> load_pointer member. If I already know real object types, I can just SS> create special output archive and load objects with incompatible input SS> archives, without worring about tracking and object creation stuff. SS> This works fine.
Unfortunately, I was to hasty with conlusions - this solution doesn't work when objects serialized by base class pointers.
With best regards, Sergey.
Ahhh - everything is more involved that it first appears. I believe the same basic approach could be made two work. Perhaps overloading pointer_iserializer::load_object_ptr from iserializer.hpp could be made to work. I did play around a little with this but couldn't make it work without investing too much effort. Sorry I don't have a complete solution. Let me know when you find one. Robert Ramey "Sergey Skorniakov" <s.skorniakov@megaputer.ru> wrote in message news:cp4hbt$vqm$1@sea.gmane.org...
Hello, Sergey! You wrote to Robert Ramey on Tue, 7 Dec 2004 12:42:01 +0300:
SS> Thanks, Robert. This great! No one can say why I tried to override SS> load_pointer member. If I already know real object types, I can just SS> create special output archive and load objects with incompatible input SS> archives, without worring about tracking and object creation stuff. SS> This works fine.
Unfortunately, I was to hasty with conlusions - this solution doesn't work when objects serialized by base class pointers.
With best regards, Sergey.
participants (2)
-
Robert Ramey
-
Sergey Skorniakov