|
Boost Users : |
From: Robert Ramey (ramey_at_[hidden])
Date: 2004-12-06 13:25:07
Note: the following is just speculation on my part - take with a grain of
salt.
"Sergey Skorniakov" <s.skorniakov_at_[hidden]> wrote in message
news:cp20fa$kbh$1_at_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_at_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_at_96QA8F]R871E#0IT96UP;&%T93QC;&%S<R!"87-E07)C:&EV93X-
M"F-L87-S(&UE;65N=&]?:6%R8VAI=F4_at_.@T*(" @('!U8FQI8R!"87-E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>'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_at_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_at_.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._at_T*(" @(&UE;65N=&]?=&5X=%]I87)C:&EV
M92AS=&0Z.FES=')E86T@)B!I<RP@=6YS:6=N960@:6YT(&9L86=S(#T@,"D@
M._at_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_at_8V]M<&EL93\-"B-I;F-L=61E(#QF<W1R
M96%M/@T*#0II;G0@;6%I;B_at_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
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net