0031785: [REGRESSION] Application Framework - application crashes on reading XBF...
[occt.git] / src / CDM / CDM_Application.cxx
1 // Created on: 1997-10-22
2 // Created by: Jean-Louis Frenkel
3 // Copyright (c) 1997-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
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
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17
18 #include <CDM_Application.hxx>
19 #include <CDM_Document.hxx>
20 #include <CDM_MetaData.hxx>
21 #include <CDM_Reference.hxx>
22 #include <Resource_Manager.hxx>
23 #include <Standard_Dump.hxx>
24 #include <Standard_Type.hxx>
25 #include <TCollection_ExtendedString.hxx>
26 #include <Message.hxx>
27 #include <Message_Messenger.hxx>
28
29 IMPLEMENT_STANDARD_RTTIEXT(CDM_Application,Standard_Transient)
30
31 //=======================================================================
32 //function : Constructor
33 //purpose  : 
34 //=======================================================================
35 CDM_Application::CDM_Application()
36 {
37   myMessenger = new Message_Messenger;
38 }
39 //=======================================================================
40 //function : SetDocumentVersion
41 //purpose  : 
42 //=======================================================================
43 void CDM_Application::SetDocumentVersion
44                         (const Handle(CDM_Document)& aDocument,
45                          const Handle(CDM_MetaData)& aMetaData) const
46 {
47   aDocument->SetModifications(aMetaData->DocumentVersion(this));
48 }
49
50 //=======================================================================
51 //function : SetReferenceCounter
52 //purpose  : 
53 //=======================================================================
54
55 void CDM_Application::SetReferenceCounter
56                         (const Handle(CDM_Document)& aDocument,
57                          const Standard_Integer aReferenceCounter)
58 {
59   aDocument->SetReferenceCounter(aReferenceCounter);
60 }
61
62 //=======================================================================
63 //function : MessageDriver
64 //purpose  : 
65 //=======================================================================
66
67 Handle(Message_Messenger) CDM_Application::MessageDriver()
68 {
69   return myMessenger;
70 }
71
72 //=======================================================================
73 //function : Write
74 //purpose  : 
75 //=======================================================================
76
77 void CDM_Application::Write(const Standard_ExtString aString)
78 {
79   MessageDriver()->Send(aString);
80 }
81
82 //=======================================================================
83 //function : BeginOfUpdate
84 //purpose  : 
85 //=======================================================================
86
87 void CDM_Application::BeginOfUpdate (const Handle(CDM_Document)& /*aDocument*/)
88 {
89   TCollection_ExtendedString updating("Updating: ");
90   updating += "Document";
91   Write(updating.ToExtString());
92 }
93
94 //=======================================================================
95 //function : EndOfUpdate
96 //purpose  : 
97 //=======================================================================
98
99 void CDM_Application::EndOfUpdate
100                         (const Handle(CDM_Document)&       /*aDocument*/,
101                          const Standard_Boolean            theStatus,
102                          const TCollection_ExtendedString& /*ErrorString*/)
103 {
104   TCollection_ExtendedString message;
105   if (theStatus)
106     message="Updated: ";
107   else
108     message="Error during updating: ";
109       
110   message+="Document";
111   Write(message.ToExtString());
112 }
113
114 //=======================================================================
115 //function : Name
116 //purpose  : returns the application name
117 //=======================================================================
118
119 TCollection_ExtendedString CDM_Application::Name() const
120 {
121   // Default: empty
122   return TCollection_ExtendedString();
123 }
124
125 //=======================================================================
126 //function : Version
127 //purpose  : returns the application version
128 //=======================================================================
129
130 TCollection_AsciiString CDM_Application::Version() const
131 {
132   // Default: empty
133   return TCollection_AsciiString();
134 }
135
136 //=======================================================================
137 //function : MetaDataLookUpTable
138 //purpose  : returns the MetaData LookUpTable
139 //=======================================================================
140 CDM_MetaDataLookUpTable& CDM_Application::MetaDataLookUpTable()
141 {
142   return myMetaDataLookUpTable;
143 }
144
145 //=======================================================================
146 //function : DumpJson
147 //purpose  : 
148 //=======================================================================
149 void CDM_Application::DumpJson (Standard_OStream& theOStream, Standard_Integer /*theDepth*/) const
150 {
151   OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
152 }