26 #ifndef SUIT_TREESYNC_H
27 #define SUIT_TREESYNC_H
41 template <
class SrcItem,
class TrgItem>
53 template <
class SrcItem,
class TrgItem,
class TreeData>
54 TrgItem
synchronize(
const SrcItem&,
const TrgItem&,
const TreeData& );
56 template <
class SrcItem,
class TrgItem,
class TreeData>
61 template <
class SrcItem,
class TrgItem,
class TreeData>
62 TrgItem
createSubTree(
const SrcItem&,
const TrgItem&,
const TrgItem&,
const TreeData& );
64 template <
class SrcItem,
class TrgItem,
class TreeData>
117 template <
class SrcItem,
class TrgItem,
class TreeData>
118 TrgItem
synchronize(
const SrcItem& r1,
const TrgItem& r2,
const TreeData& td )
120 if ( td.isEqual( r1, r2 ) ) {
122 td.updateItem( r1, r2 );
128 TrgItem lastItem = td.nullTrg();
130 for ( ; anIt != aLast; anIt++ ) {
132 if ( item.
mySrc == td.nullSrc() ) {
133 if ( item.
myTrg == td.nullTrg() )
134 qDebug(
"error: both null" );
137 td.deleteItemWithChildren( item.
myTrg );
140 if ( item.
myTrg == td.nullTrg() ) {
143 if ( nitem != td.nullTrg() )
149 lastItem = item.
myTrg;
156 TrgItem new_r2 = td.nullTrg();
157 if ( r1 != td.nullSrc() ) {
161 if ( r2 != td.nullTrg() ) {
163 td.deleteItemWithChildren( r2 );
179 template <
class SrcItem,
class TrgItem,
class TreeData>
186 for ( ; cur != last; cur++ ) {
187 if ( td.isEqual( it, *cur ) )
201 template <
class SrcItem,
class TrgItem,
class TreeData>
216 for ( ; src_it != src_last; src_it++ ) {
218 findEqual<SrcItem, TrgItem, TreeData>( *src_it, cur, trg_last, td );
219 if ( f != trg_last ) {
224 ndiff.
mySrc = td.nullSrc();
230 ndiff.
mySrc = *src_it;
238 ndiff.
mySrc = *src_it;
239 ndiff.
myTrg = td.nullTrg();
244 for ( ; cur != trg_last; cur++ ) {
246 ndiff.
mySrc = td.nullSrc();
263 template <
class SrcItem,
class TrgItem,
class TreeData>
265 const TrgItem& after,
const TreeData& td )
267 if ( src == td.nullSrc() )
270 TrgItem nitem = td.createItem( src, parent, after );
271 if ( nitem == td.nullTrg() )
276 TrgItem last = td.nullTrg();
277 for( ; anIt != aLast; anIt++ )
283 #endif // SUIT_TREESYNC_H