0029195: OCAF - ensure thread safety for different documents.
[occt.git] / src / CDM / CDM_Application.cxx
CommitLineData
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>
42cf5bc1 20#include <CDM_MetaData.hxx>
42cf5bc1 21#include <CDM_Reference.hxx>
22#include <Resource_Manager.hxx>
bc73b006 23#include <Standard_Dump.hxx>
42cf5bc1 24#include <Standard_Type.hxx>
25#include <TCollection_ExtendedString.hxx>
83ae3591 26#include <Message.hxx>
27#include <Message_Messenger.hxx>
7fd59977 28
92efcf78 29IMPLEMENT_STANDARD_RTTIEXT(CDM_Application,Standard_Transient)
30
7fd59977 31//=======================================================================
d9d03f10 32//function : Constructor
33//purpose :
34//=======================================================================
35CDM_Application::CDM_Application()
36{
37 myMessenger = new Message_Messenger;
38}
39//=======================================================================
7fd59977 40//function : SetDocumentVersion
41//purpose :
42//=======================================================================
7fd59977 43void 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
55void 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
83ae3591 67Handle(Message_Messenger) CDM_Application::MessageDriver()
7fd59977 68{
d9d03f10 69 return myMessenger;
7fd59977 70}
71
72//=======================================================================
73//function : Write
74//purpose :
75//=======================================================================
76
77void CDM_Application::Write(const Standard_ExtString aString)
78{
83ae3591 79 MessageDriver()->Send(aString);
7fd59977 80}
81
82//=======================================================================
83//function : BeginOfUpdate
84//purpose :
85//=======================================================================
86
d9d03f10 87void CDM_Application::BeginOfUpdate (const Handle(CDM_Document)& /*aDocument*/)
7fd59977 88{
d9d03f10 89 TCollection_ExtendedString updating("Updating: ");
90 updating += "Document";
7fd59977 91 Write(updating.ToExtString());
92}
93
94//=======================================================================
95//function : EndOfUpdate
96//purpose :
97//=======================================================================
98
99void CDM_Application::EndOfUpdate
d9d03f10 100 (const Handle(CDM_Document)& /*aDocument*/,
9fd2d2c3 101 const Standard_Boolean theStatus,
7fd59977 102 const TCollection_ExtendedString& /*ErrorString*/)
103{
104 TCollection_ExtendedString message;
9fd2d2c3 105 if (theStatus)
d9d03f10 106 message="Updated: ";
7fd59977 107 else
d9d03f10 108 message="Error during updating: ";
7fd59977 109
d9d03f10 110 message+="Document";
7fd59977 111 Write(message.ToExtString());
112}
fe21f796
BB
113
114//=======================================================================
115//function : Name
116//purpose : returns the application name
117//=======================================================================
118
119TCollection_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
130TCollection_AsciiString CDM_Application::Version() const
131{
132 // Default: empty
133 return TCollection_AsciiString();
134}
bc73b006 135
136//=======================================================================
d9d03f10 137//function : MetaDataLookUpTable
138//purpose : returns the MetaData LookUpTable
139//=======================================================================
140CDM_MetaDataLookUpTable* CDM_Application::MetaDataLookUpTable()
141{
142 return &myMetaDataLookUpTable;
143}
144
145//=======================================================================
bc73b006 146//function : DumpJson
147//purpose :
148//=======================================================================
149void CDM_Application::DumpJson (Standard_OStream& theOStream, Standard_Integer /*theDepth*/) const
150{
151 OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
152}