7fd59977 |
1 | // File: TObj_CheckModel.hxx |
2 | // Created: 17.04.2007 |
3 | // Author: Michael Sazonov |
4 | // Copyright: Open CASCADE 2007 |
5 | // The original implementation Copyright: (C) RINA S.p.A |
6 | |
7 | #ifndef TObj_CheckModel_HeaderFile |
8 | #define TObj_CheckModel_HeaderFile |
9 | |
10 | #include <TObj_Common.hxx> |
11 | #include <TObj_Model.hxx> |
12 | #include <Message_Algorithm.hxx> |
13 | |
14 | /** |
15 | * This class provides consistency check of the TObj model. |
16 | * It collects all inconsistencies in the status bits and prepaires |
17 | * messages to be sent using SendStatusMessages (SendMessages) method. |
18 | * It supports also the fix mode, in which some inconsistencies are |
19 | * corrected. |
20 | */ |
21 | |
22 | class TObj_CheckModel: public Message_Algorithm |
23 | { |
24 | public: |
25 | //! Initialize checker by model |
26 | TObj_CheckModel(const Handle(TObj_Model)& theModel) |
27 | : myModel (theModel), |
28 | myToFix (Standard_False) |
29 | {} |
30 | |
31 | //! Sets flag allowing fixing inconsistencies |
32 | void SetToFix(const Standard_Boolean theToFix) |
33 | { myToFix = theToFix; } |
34 | |
35 | //! Returns true if it is allowed to fix inconsistencies |
36 | Standard_Boolean IsToFix() const |
37 | { return myToFix; } |
38 | |
39 | //! Returns the checked model |
40 | const Handle(TObj_Model)& GetModel() const |
41 | { return myModel; } |
42 | |
43 | //! Empty virtual destructor |
44 | virtual ~TObj_CheckModel () {} |
45 | |
46 | //! Performs all checks. Descendants should call parent method before |
47 | //! doing own checks. |
48 | //! This implementation checks OCAF references and back references |
49 | //! between objects of the model. |
50 | //! Returns true if no inconsistencies found. |
51 | virtual Standard_EXPORT Standard_Boolean Perform(); |
52 | |
53 | private: |
54 | //! Check References (and back references in model). |
55 | //! This method just tries to find object to that this reference is indicate and |
56 | //! test if that object is not null or not deleted. Also it test if that object has back |
57 | //! reference to correct object (object that has forward reference). |
58 | Standard_EXPORT Standard_Boolean checkReferences(); |
59 | |
60 | private: |
61 | Handle(TObj_Model) myModel; |
62 | Standard_Boolean myToFix; |
63 | |
64 | public: |
65 | //! Declaration of CASCADE RTTI |
66 | DEFINE_STANDARD_RTTI (TObj_CheckModel) |
67 | }; |
68 | |
69 | //! Definition of HANDLE object using Standard_DefineHandle.hxx |
70 | DEFINE_STANDARD_HANDLE (TObj_CheckModel,Message_Algorithm) |
71 | |
72 | #endif |
73 | |
74 | #ifdef _MSC_VER |
75 | #pragma once |
76 | #endif |