b311480e |
1 | // Created on: 1997-10-22 |
2 | // Created by: Jean-Louis Frenkel |
3 | // Copyright (c) 1997-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
d5f74e42 |
8 | // This library is free software; you can redistribute it and/or modify it under |
9 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
10 | // by the Free Software Foundation, with special exception defined in the file |
11 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
12 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
7fd59977 |
16 | |
42cf5bc1 |
17 | |
18 | #include <CDM_Application.hxx> |
19 | #include <CDM_Document.hxx> |
20 | #include <CDM_MessageDriver.hxx> |
21 | #include <CDM_MetaData.hxx> |
7fd59977 |
22 | #include <CDM_NullMessageDriver.hxx> |
42cf5bc1 |
23 | #include <CDM_Reference.hxx> |
24 | #include <Resource_Manager.hxx> |
25 | #include <Standard_Type.hxx> |
26 | #include <TCollection_ExtendedString.hxx> |
7fd59977 |
27 | |
92efcf78 |
28 | IMPLEMENT_STANDARD_RTTIEXT(CDM_Application,Standard_Transient) |
29 | |
7fd59977 |
30 | //======================================================================= |
31 | //function : SetDocumentVersion |
32 | //purpose : |
33 | //======================================================================= |
7fd59977 |
34 | void CDM_Application::SetDocumentVersion |
35 | (const Handle(CDM_Document)& aDocument, |
36 | const Handle(CDM_MetaData)& aMetaData) const |
37 | { |
38 | aDocument->SetModifications(aMetaData->DocumentVersion(this)); |
39 | } |
40 | |
41 | //======================================================================= |
42 | //function : SetReferenceCounter |
43 | //purpose : |
44 | //======================================================================= |
45 | |
46 | void CDM_Application::SetReferenceCounter |
47 | (const Handle(CDM_Document)& aDocument, |
48 | const Standard_Integer aReferenceCounter) |
49 | { |
50 | aDocument->SetReferenceCounter(aReferenceCounter); |
51 | } |
52 | |
53 | //======================================================================= |
54 | //function : MessageDriver |
55 | //purpose : |
56 | //======================================================================= |
57 | |
58 | Handle(CDM_MessageDriver) CDM_Application::MessageDriver() |
59 | { |
60 | static Handle(CDM_NullMessageDriver) theMessageDriver |
61 | =new CDM_NullMessageDriver; |
62 | return theMessageDriver; |
63 | } |
64 | |
65 | //======================================================================= |
66 | //function : Write |
67 | //purpose : |
68 | //======================================================================= |
69 | |
70 | void CDM_Application::Write(const Standard_ExtString aString) |
71 | { |
72 | MessageDriver()->Write(aString); |
73 | } |
74 | |
75 | //======================================================================= |
76 | //function : BeginOfUpdate |
77 | //purpose : |
78 | //======================================================================= |
79 | |
80 | void CDM_Application::BeginOfUpdate (const Handle(CDM_Document)& aDocument) |
81 | { |
82 | TCollection_ExtendedString updating("Updating:"); |
83 | updating+=aDocument->Presentation(); |
84 | Write(updating.ToExtString()); |
85 | } |
86 | |
87 | //======================================================================= |
88 | //function : EndOfUpdate |
89 | //purpose : |
90 | //======================================================================= |
91 | |
92 | void CDM_Application::EndOfUpdate |
93 | (const Handle(CDM_Document)& aDocument, |
94 | const Standard_Boolean Status, |
95 | const TCollection_ExtendedString& /*ErrorString*/) |
96 | { |
97 | TCollection_ExtendedString message; |
98 | if (Status) |
99 | message="Updated:"; |
100 | else |
101 | message="Error during updating:"; |
102 | |
103 | message+=aDocument->Presentation(); |
104 | Write(message.ToExtString()); |
105 | } |