0030773: Application Framework - To allow to inherit existing attributes to reuse...
[occt.git] / src / TDF / TDF_ComparisonTool.hxx
1 // Created by: DAUTRY Philippe
2 // Copyright (c) 1997-1999 Matra Datavision
3 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 #ifndef _TDF_ComparisonTool_HeaderFile
17 #define _TDF_ComparisonTool_HeaderFile
18
19 #include <Standard.hxx>
20 #include <Standard_DefineAlloc.hxx>
21 #include <Standard_Handle.hxx>
22
23 #include <Standard_Boolean.hxx>
24 #include <Standard_Integer.hxx>
25 class TDF_DataSet;
26 class TDF_IDFilter;
27 class TDF_RelocationTable;
28 class TDF_Label;
29
30
31 //! This class provides services to compare sets of
32 //! information. The use of this tool can works after
33 //! a copy, acted by a CopyTool.
34 //!
35 //! * Compare(...) compares two DataSet and returns
36 //! the result.
37 //!
38 //! * SourceUnbound(...) builds the difference between
39 //! a relocation dictionnary and a source set of
40 //! information.
41 //!
42 //! * TargetUnbound(...) does the same between a
43 //! relocation dictionnary and a target set of
44 //! information.
45 //!
46 //! * Cut(aDataSet, anLabel) removes a set of
47 //! attributes.
48 //!
49 //! * IsSelfContained(...) returns true if all the
50 //! labels of the attributes of the given DataSet are
51 //! descendant of the given label.
52 class TDF_ComparisonTool 
53 {
54 public:
55
56   DEFINE_STANDARD_ALLOC
57
58   
59   //! Compares <aSourceDataSet> with <aTargetDataSet>,
60   //! updating <aRelocationTable> with labels and
61   //! attributes found in both sets.
62   Standard_EXPORT static void Compare (const Handle(TDF_DataSet)& aSourceDataSet, const Handle(TDF_DataSet)& aTargetDataSet, const TDF_IDFilter& aFilter, const Handle(TDF_RelocationTable)& aRelocationTable);
63   
64   //! Finds from <aRefDataSet> all the keys not bound
65   //! into <aRelocationTable> and put them into
66   //! <aDiffDataSet>. Returns True if the difference
67   //! contains at least one key. (A key is a source
68   //! object).
69   //!
70   //! <anOption> may take the following values:
71   //! 1 : labels treatment only;
72   //! 2 : attributes treatment only (default value);
73   //! 3 : both labels & attributes treatment.
74   Standard_EXPORT static Standard_Boolean SourceUnbound (const Handle(TDF_DataSet)& aRefDataSet, const Handle(TDF_RelocationTable)& aRelocationTable, const TDF_IDFilter& aFilter, const Handle(TDF_DataSet)& aDiffDataSet, const Standard_Integer anOption = 2);
75   
76   //! Substracts from <aRefDataSet> all the items bound
77   //! into <aRelocationTable>. The result is put into
78   //! <aDiffDataSet>. Returns True if the difference
79   //! contains at least one item. (An item is a target
80   //! object).
81   //!
82   //! <anOption> may take the following values:
83   //! 1 : labels treatment only;
84   //! 2 : attributes treatment  only(default value);
85   //! 3 : both labels & attributes treatment.
86   Standard_EXPORT static Standard_Boolean TargetUnbound (const Handle(TDF_DataSet)& aRefDataSet, const Handle(TDF_RelocationTable)& aRelocationTable, const TDF_IDFilter& aFilter, const Handle(TDF_DataSet)& aDiffDataSet, const Standard_Integer anOption = 2);
87   
88   //! Removes attributes from <aDataSet>.
89   Standard_EXPORT static void Cut (const Handle(TDF_DataSet)& aDataSet);
90   
91   //! Returns true if all the labels of <aDataSet> are
92   //! descendant of <aLabel>.
93   Standard_EXPORT static Standard_Boolean IsSelfContained (const TDF_Label& aLabel, const Handle(TDF_DataSet)& aDataSet);
94
95
96
97
98 protected:
99
100
101
102
103
104 private:
105
106   
107   //! Internal comparison method used by Compare(...).
108   Standard_EXPORT static void Compare (const TDF_Label& aSrcLabel, const TDF_Label& aTrgLabel, const Handle(TDF_DataSet)& aSourceDataSet, const Handle(TDF_DataSet)& aTargetDataSet, const TDF_IDFilter& aFilter, const Handle(TDF_RelocationTable)& aRelocationTable);
109   
110   //! Internal function used by SourceUnbound() and
111   //! TargetUnbound().
112   Standard_EXPORT static Standard_Boolean Unbound (const Handle(TDF_DataSet)& aRefDataSet, const Handle(TDF_RelocationTable)& aRelocationTable, const TDF_IDFilter& aFilter, const Handle(TDF_DataSet)& aDiffDataSet, const Standard_Integer anOption, const Standard_Boolean theSource);
113
114
115
116
117 };
118
119
120
121
122
123
124
125 #endif // _TDF_ComparisonTool_HeaderFile