mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-14 13:30:48 +03:00
0029220: Application Framework - replace CDM_MessageDriver interface by Message_Messenger.
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
|
||||
#include <CDM_MessageDriver.hxx>
|
||||
#include <Message_Messenger.hxx>
|
||||
#include <Plugin_Macro.hxx>
|
||||
#include <Standard_GUID.hxx>
|
||||
#include <TDocStd_Application.hxx>
|
||||
@@ -111,7 +111,7 @@ void XmlLDrivers::DefineFormat (const Handle(TDocStd_Application)& theApp)
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Handle(XmlMDF_ADriverTable) XmlLDrivers::AttributeDrivers
|
||||
(const Handle(CDM_MessageDriver)& theMessageDriver)
|
||||
(const Handle(Message_Messenger)& theMessageDriver)
|
||||
{
|
||||
Handle(XmlMDF_ADriverTable) aTable = new XmlMDF_ADriverTable();
|
||||
//
|
||||
|
@@ -22,7 +22,7 @@ class Standard_Transient;
|
||||
class Standard_GUID;
|
||||
class TCollection_AsciiString;
|
||||
class XmlMDF_ADriverTable;
|
||||
class CDM_MessageDriver;
|
||||
class Message_Messenger;
|
||||
class XmlLDrivers_DocumentStorageDriver;
|
||||
class XmlLDrivers_DocumentRetrievalDriver;
|
||||
class XmlLDrivers_NamespaceDef;
|
||||
@@ -40,7 +40,7 @@ public:
|
||||
//! in the specified application
|
||||
Standard_EXPORT static void DefineFormat (const Handle(TDocStd_Application)& theApp);
|
||||
|
||||
Standard_EXPORT static Handle(XmlMDF_ADriverTable) AttributeDrivers (const Handle(CDM_MessageDriver)& theMsgDriver);
|
||||
Standard_EXPORT static Handle(XmlMDF_ADriverTable) AttributeDrivers (const Handle(Message_Messenger)& theMsgDriver);
|
||||
|
||||
Standard_EXPORT static int StorageVersion();
|
||||
Standard_EXPORT static void SetStorageVersion (const int version);
|
||||
|
@@ -16,7 +16,7 @@
|
||||
|
||||
#include <CDM_Application.hxx>
|
||||
#include <CDM_Document.hxx>
|
||||
#include <CDM_MessageDriver.hxx>
|
||||
#include <Message_Messenger.hxx>
|
||||
#include <CDM_MetaData.hxx>
|
||||
#include <LDOM_DocumentType.hxx>
|
||||
#include <LDOM_LDOMImplementation.hxx>
|
||||
@@ -60,7 +60,7 @@ IMPLEMENT_STANDARD_RTTIEXT(XmlLDrivers_DocumentRetrievalDriver,PCDM_RetrievalDri
|
||||
|
||||
//#define TAKE_TIMES
|
||||
static void take_time (const Standard_Integer, const char *,
|
||||
const Handle(CDM_MessageDriver)&)
|
||||
const Handle(Message_Messenger)&)
|
||||
#ifdef TAKE_TIMES
|
||||
;
|
||||
#else
|
||||
@@ -196,7 +196,7 @@ void XmlLDrivers_DocumentRetrievalDriver::Read
|
||||
TCollection_ExtendedString aMsg = TCollection_ExtendedString("Error: the file ") +
|
||||
theFileName + " cannot be opened for reading";
|
||||
|
||||
theApplication->MessageDriver()->Write (aMsg.ToExtString());
|
||||
theApplication->MessageDriver()->Send (aMsg.ToExtString(), Message_Fail);
|
||||
throw Standard_Failure("File cannot be opened for reading");
|
||||
}
|
||||
}
|
||||
@@ -210,7 +210,7 @@ void XmlLDrivers_DocumentRetrievalDriver::Read (Standard_IStream& t
|
||||
const Handle(CDM_Document)& theNewDocument,
|
||||
const Handle(CDM_Application)& theApplication)
|
||||
{
|
||||
Handle(CDM_MessageDriver) aMessageDriver = theApplication -> MessageDriver();
|
||||
Handle(Message_Messenger) aMessageDriver = theApplication -> MessageDriver();
|
||||
::take_time (~0, " +++++ Start RETRIEVE procedures ++++++", aMessageDriver);
|
||||
|
||||
// 1. Read DOM_Document from file
|
||||
@@ -245,7 +245,7 @@ void XmlLDrivers_DocumentRetrievalDriver::ReadFromDomDocument
|
||||
const Handle(CDM_Document)& theNewDocument,
|
||||
const Handle(CDM_Application)& theApplication)
|
||||
{
|
||||
const Handle(CDM_MessageDriver) aMsgDriver =
|
||||
const Handle(Message_Messenger) aMsgDriver =
|
||||
theApplication -> MessageDriver();
|
||||
// 1. Read info // to be done
|
||||
TCollection_AsciiString anAbsoluteDirectory = GetDirFromFile(myFileName);
|
||||
@@ -262,7 +262,7 @@ void XmlLDrivers_DocumentRetrievalDriver::ReadFromDomDocument
|
||||
TCollection_ExtendedString ("Cannot retrieve the current Document version"
|
||||
" attribute as \"") + aDocVerStr + "\"";
|
||||
if(!aMsgDriver.IsNull())
|
||||
aMsgDriver->Write(aMsg.ToExtString());
|
||||
aMsgDriver->Send(aMsg.ToExtString(), Message_Fail);
|
||||
}
|
||||
|
||||
// oan: OCC22305 - check a document verison and if it's greater than
|
||||
@@ -275,7 +275,7 @@ void XmlLDrivers_DocumentRetrievalDriver::ReadFromDomDocument
|
||||
XmlLDrivers::StorageVersion();
|
||||
myReaderStatus = PCDM_RS_NoVersion;
|
||||
if(!aMsgDriver.IsNull())
|
||||
aMsgDriver->Write(aMsg.ToExtString());
|
||||
aMsgDriver->Send(aMsg.ToExtString(), Message_Fail);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -302,7 +302,7 @@ void XmlLDrivers_DocumentRetrievalDriver::ReadFromDomDocument
|
||||
TCollection_ExtendedString aMsg("Warning: ");
|
||||
aMsg = aMsg.Cat("could not read the reference counter").Cat("\0");
|
||||
if(!aMsgDriver.IsNull())
|
||||
aMsgDriver->Write(aMsg.ToExtString());
|
||||
aMsgDriver->Send(aMsg.ToExtString(), Message_Warning);
|
||||
}
|
||||
}
|
||||
else if (anInfo.Search(MODIFICATION_COUNTER) != -1) {
|
||||
@@ -316,7 +316,7 @@ void XmlLDrivers_DocumentRetrievalDriver::ReadFromDomDocument
|
||||
catch (Standard_Failure) {
|
||||
TCollection_ExtendedString aMsg("Warning: could not read the modification counter\0");
|
||||
if(!aMsgDriver.IsNull())
|
||||
aMsgDriver->Write(aMsg.ToExtString());
|
||||
aMsgDriver->Send(aMsg.ToExtString(), Message_Warning);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -348,9 +348,9 @@ void XmlLDrivers_DocumentRetrievalDriver::ReadFromDomDocument
|
||||
}
|
||||
if(!aMsgDriver.IsNull()) {
|
||||
// cout << "reference found; ReferenceIdentifier: " << theReferenceIdentifier << "; File:" << thePath << ", version:" << theDocumentVersion;
|
||||
TCollection_ExtendedString aMsg("Warning: ");
|
||||
aMsg = aMsg.Cat("reference found; ReferenceIdentifier: ").Cat(aRefId).Cat("; File:").Cat(aPath).Cat(", version:").Cat(aDocumentVersion).Cat("\0");
|
||||
aMsgDriver->Write(aMsg.ToExtString());
|
||||
TCollection_ExtendedString aMsg("Warning: ");
|
||||
aMsg = aMsg.Cat("reference found; ReferenceIdentifier: ").Cat(aRefId).Cat("; File:").Cat(aPath).Cat(", version:").Cat(aDocumentVersion).Cat("\0");
|
||||
aMsgDriver->Send(aMsg.ToExtString(), Message_Warning);
|
||||
}
|
||||
// Add new ref!
|
||||
/////////////
|
||||
@@ -444,7 +444,7 @@ void XmlLDrivers_DocumentRetrievalDriver::ReadFromDomDocument
|
||||
OCC_CATCH_SIGNALS
|
||||
#ifdef OCCT_DEBUG
|
||||
TCollection_ExtendedString aMessage ("PasteDocument");
|
||||
aMsgDriver -> Write (aMessage.ToExtString());
|
||||
aMsgDriver ->Send (aMessage.ToExtString(), Message_Trace);
|
||||
#endif
|
||||
if (!MakeDocument(theElement, theNewDocument))
|
||||
myReaderStatus = PCDM_RS_MakeFailure;
|
||||
@@ -454,7 +454,7 @@ void XmlLDrivers_DocumentRetrievalDriver::ReadFromDomDocument
|
||||
catch (Standard_Failure const& anException)
|
||||
{
|
||||
TCollection_ExtendedString anErrorString (anException.GetMessageString());
|
||||
aMsgDriver -> Write (anErrorString.ToExtString());
|
||||
aMsgDriver ->Send (anErrorString.ToExtString(), Message_Fail);
|
||||
}
|
||||
|
||||
// Wipe off the shapes written to the <shapes> section
|
||||
@@ -495,7 +495,7 @@ Standard_Boolean XmlLDrivers_DocumentRetrievalDriver::MakeDocument
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Handle(XmlMDF_ADriverTable) XmlLDrivers_DocumentRetrievalDriver::AttributeDrivers
|
||||
(const Handle(CDM_MessageDriver)& theMessageDriver)
|
||||
(const Handle(Message_Messenger)& theMessageDriver)
|
||||
{
|
||||
return XmlLDrivers::AttributeDrivers (theMessageDriver);
|
||||
}
|
||||
@@ -516,7 +516,7 @@ extern "C" int ftime (struct timeb *tp);
|
||||
extern struct timeb tmbuf0;
|
||||
|
||||
static void take_time (const Standard_Integer isReset, const char * aHeader,
|
||||
const Handle(CDM_MessageDriver)& aMessageDriver)
|
||||
const Handle(Message_Messenger)& aMessageDriver)
|
||||
{
|
||||
struct timeb tmbuf;
|
||||
ftime (&tmbuf);
|
||||
@@ -549,7 +549,7 @@ void XmlLDrivers_DocumentRetrievalDriver::PropagateDocumentVersion(
|
||||
//=======================================================================
|
||||
Handle(XmlMDF_ADriver) XmlLDrivers_DocumentRetrievalDriver::ReadShapeSection(
|
||||
const XmlObjMgt_Element& /*theElement*/,
|
||||
const Handle(CDM_MessageDriver)& /*aMsgDriver*/)
|
||||
const Handle(Message_Messenger)& /*aMsgDriver*/)
|
||||
{
|
||||
Handle(XmlMDF_ADriver) aDriver;
|
||||
//empty; to be redefined
|
||||
|
@@ -31,7 +31,7 @@ class TCollection_ExtendedString;
|
||||
class PCDM_Document;
|
||||
class CDM_Document;
|
||||
class CDM_Application;
|
||||
class CDM_MessageDriver;
|
||||
class Message_Messenger;
|
||||
class XmlMDF_ADriver;
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ public:
|
||||
const Handle(CDM_Document)& theDoc,
|
||||
const Handle(CDM_Application)& theApplication) Standard_OVERRIDE;
|
||||
|
||||
Standard_EXPORT virtual Handle(XmlMDF_ADriverTable) AttributeDrivers (const Handle(CDM_MessageDriver)& theMsgDriver);
|
||||
Standard_EXPORT virtual Handle(XmlMDF_ADriverTable) AttributeDrivers (const Handle(Message_Messenger)& theMsgDriver);
|
||||
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ protected:
|
||||
|
||||
Standard_EXPORT virtual Standard_Boolean MakeDocument (const XmlObjMgt_Element& thePDoc, const Handle(CDM_Document)& theTDoc);
|
||||
|
||||
Standard_EXPORT virtual Handle(XmlMDF_ADriver) ReadShapeSection (const XmlObjMgt_Element& thePDoc, const Handle(CDM_MessageDriver)& theMsgDriver);
|
||||
Standard_EXPORT virtual Handle(XmlMDF_ADriver) ReadShapeSection (const XmlObjMgt_Element& thePDoc, const Handle(Message_Messenger)& theMsgDriver);
|
||||
|
||||
Standard_EXPORT virtual void ShapeSetCleaning (const Handle(XmlMDF_ADriver)& theDriver);
|
||||
|
||||
|
@@ -16,8 +16,8 @@
|
||||
|
||||
#include <CDM_Application.hxx>
|
||||
#include <CDM_Document.hxx>
|
||||
#include <CDM_MessageDriver.hxx>
|
||||
#include <CDM_NullMessageDriver.hxx>
|
||||
#include <Message.hxx>
|
||||
#include <Message_Messenger.hxx>
|
||||
#include <LDOM_DocumentType.hxx>
|
||||
#include <LDOM_LDOMImplementation.hxx>
|
||||
#include <LDOM_XmlWriter.hxx>
|
||||
@@ -56,7 +56,7 @@ IMPLEMENT_STANDARD_RTTIEXT(XmlLDrivers_DocumentStorageDriver,PCDM_StorageDriver)
|
||||
|
||||
//#define TAKE_TIMES
|
||||
static void take_time (const Standard_Integer, const char *,
|
||||
const Handle(CDM_MessageDriver)&)
|
||||
const Handle(Message_Messenger)&)
|
||||
#ifdef TAKE_TIMES
|
||||
;
|
||||
#else
|
||||
@@ -111,7 +111,7 @@ void XmlLDrivers_DocumentStorageDriver::Write (const Handle(CDM_Document)&
|
||||
TCollection_ExtendedString aMsg = TCollection_ExtendedString("Error: the file ") +
|
||||
theFileName + " cannot be opened for writing";
|
||||
|
||||
theDocument->Application()->MessageDriver()->Write (aMsg.ToExtString());
|
||||
theDocument->Application()->MessageDriver()->Send (aMsg.ToExtString(), Message_Fail);
|
||||
throw Standard_Failure("File cannot be opened for writing");
|
||||
}
|
||||
}
|
||||
@@ -123,7 +123,7 @@ void XmlLDrivers_DocumentStorageDriver::Write (const Handle(CDM_Document)&
|
||||
Standard_EXPORT void XmlLDrivers_DocumentStorageDriver::Write (const Handle(CDM_Document)& theDocument,
|
||||
Standard_OStream& theOStream)
|
||||
{
|
||||
Handle(CDM_MessageDriver) aMessageDriver = theDocument->Application()->MessageDriver();
|
||||
Handle(Message_Messenger) aMessageDriver = theDocument->Application()->MessageDriver();
|
||||
::take_time (~0, " +++++ Start STORAGE procedures ++++++", aMessageDriver);
|
||||
|
||||
// Create new DOM_Document
|
||||
@@ -148,7 +148,7 @@ Standard_EXPORT void XmlLDrivers_DocumentStorageDriver::Write (const Handle(CDM_
|
||||
|
||||
TCollection_ExtendedString aMsg = TCollection_ExtendedString("Error: the stream is bad and") +
|
||||
" cannot be used for writing";
|
||||
theDocument->Application()->MessageDriver()->Write (aMsg.ToExtString());
|
||||
theDocument->Application()->MessageDriver()->Send (aMsg.ToExtString(), Message_Fail);
|
||||
|
||||
throw Standard_Failure("File cannot be opened for writing");
|
||||
}
|
||||
@@ -168,7 +168,7 @@ Standard_Boolean XmlLDrivers_DocumentStorageDriver::WriteToDomDocument (const Ha
|
||||
XmlObjMgt_Element& theElement)
|
||||
{
|
||||
SetIsError(Standard_False);
|
||||
Handle(CDM_MessageDriver) aMessageDriver =
|
||||
Handle(Message_Messenger) aMessageDriver =
|
||||
theDocument -> Application() -> MessageDriver();
|
||||
// 1. Write header information
|
||||
Standard_Integer i;
|
||||
@@ -210,12 +210,12 @@ Standard_Boolean XmlLDrivers_DocumentStorageDriver::WriteToDomDocument (const Ha
|
||||
aResourceDir += "/src/XmlOcafResource" ;
|
||||
aToSetCSFVariable = Standard_True; //CSF variable to be set later
|
||||
}
|
||||
#ifdef OCCT_DEBUG
|
||||
#ifdef OCCT_DEBUGXML
|
||||
else {
|
||||
TCollection_ExtendedString aWarn = FAILSTR "Neither ";
|
||||
aWarn = (aWarn + aCSFVariable[0] + ", nor " + aCSFVariable[1]
|
||||
+ " variables have been set");
|
||||
aMessageDriver->Write (aWarn.ToExtString());
|
||||
aMessageDriver->Send (aWarn.ToExtString(), Message_Warning);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -228,24 +228,24 @@ Standard_Boolean XmlLDrivers_DocumentStorageDriver::WriteToDomDocument (const Ha
|
||||
if (aToSetCSFVariable) {
|
||||
OSD_Environment aCSFVarEnv ( aCSFVariable[0], aResourceDir );
|
||||
aCSFVarEnv.Build();
|
||||
#ifdef OCCT_DEBUG
|
||||
#ifdef OCCT_DEBUGXML
|
||||
TCollection_ExtendedString aWarn1 = "Variable ";
|
||||
aWarn1 = (aWarn1 + aCSFVariable[0]
|
||||
+ " has not been explicitly defined. Set to " + aResourceDir);
|
||||
aMessageDriver->Write (aWarn1.ToExtString());
|
||||
aMessageDriver->Send (aWarn1.ToExtString(), Message_Warning);
|
||||
#endif
|
||||
if ( aCSFVarEnv.Failed() ) {
|
||||
TCollection_ExtendedString aWarn = FAILSTR "Failed to initialize ";
|
||||
aWarn = aWarn + aCSFVariable[0] + " with " + aResourceDir;
|
||||
aMessageDriver->Write (aWarn.ToExtString());
|
||||
aMessageDriver->Send (aWarn.ToExtString(), Message_Fail);
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifdef OCCT_DEBUG
|
||||
#ifdef OCCT_DEBUGXML
|
||||
else {
|
||||
TCollection_ExtendedString aWarn = FAILSTR "Schema definition file ";
|
||||
aWarn += (aResourceFileName + " was not found");
|
||||
aMessageDriver->Write (aWarn.ToExtString());
|
||||
aMessageDriver->Send (aWarn.ToExtString(), Message_Warning);
|
||||
}
|
||||
#endif
|
||||
anHTTP = anHTTP + ' ' + aResourceFileName;
|
||||
@@ -317,14 +317,14 @@ Standard_Boolean XmlLDrivers_DocumentStorageDriver::WriteToDomDocument (const Ha
|
||||
SetIsError (Standard_True);
|
||||
SetStoreStatus(PCDM_SS_Failure);
|
||||
TCollection_ExtendedString anErrorString (anException.GetMessageString());
|
||||
aMessageDriver -> Write (anErrorString.ToExtString());
|
||||
aMessageDriver ->Send (anErrorString.ToExtString(), Message_Fail);
|
||||
}
|
||||
}
|
||||
if (anObjNb <= 0 && IsError() == Standard_False) {
|
||||
SetIsError (Standard_True);
|
||||
SetStoreStatus(PCDM_SS_No_Obj);
|
||||
TCollection_ExtendedString anErrorString ("error occurred");
|
||||
aMessageDriver -> Write (anErrorString.ToExtString());
|
||||
aMessageDriver ->Send (anErrorString.ToExtString(), Message_Fail);
|
||||
}
|
||||
// 2b. Write number of objects into the info section
|
||||
anInfoElem.setAttribute("objnb", anObjNb);
|
||||
@@ -359,18 +359,20 @@ Standard_Integer XmlLDrivers_DocumentStorageDriver::MakeDocument
|
||||
|
||||
// Find MessageDriver and pass it to AttributeDrivers()
|
||||
Handle(CDM_Application) anApplication= theTDoc -> Application();
|
||||
Handle(CDM_MessageDriver) aMessageDriver;
|
||||
if (anApplication.IsNull())
|
||||
aMessageDriver = new CDM_NullMessageDriver;
|
||||
Handle(Message_Messenger) aMessageDriver;
|
||||
if (anApplication.IsNull()) {
|
||||
aMessageDriver = Message::DefaultMessenger();
|
||||
aMessageDriver->ChangePrinters().Clear();
|
||||
}
|
||||
else
|
||||
aMessageDriver = anApplication -> MessageDriver();
|
||||
if (myDrivers.IsNull()) myDrivers = AttributeDrivers (aMessageDriver);
|
||||
|
||||
// Retrieve from DOM_Document
|
||||
XmlMDF::FromTo (aTDF, theElement, myRelocTable, myDrivers);
|
||||
#ifdef OCCT_DEBUG
|
||||
#ifdef OCCT_DEBUGXML
|
||||
aMessage = "First step successfull";
|
||||
aMessageDriver -> Write (aMessage.ToExtString());
|
||||
aMessageDriver -> Send (aMessage.ToExtString(), Message_Warning);
|
||||
#endif
|
||||
return myRelocTable.Extent();
|
||||
}
|
||||
@@ -385,7 +387,7 @@ Standard_Integer XmlLDrivers_DocumentStorageDriver::MakeDocument
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Handle(XmlMDF_ADriverTable) XmlLDrivers_DocumentStorageDriver::AttributeDrivers
|
||||
(const Handle(CDM_MessageDriver)& theMessageDriver)
|
||||
(const Handle(Message_Messenger)& theMessageDriver)
|
||||
{
|
||||
return XmlLDrivers::AttributeDrivers (theMessageDriver);
|
||||
}
|
||||
@@ -406,7 +408,7 @@ extern "C" int ftime (struct timeb *tp);
|
||||
struct timeb tmbuf0;
|
||||
|
||||
static void take_time (const Standard_Integer isReset, const char * aHeader,
|
||||
const Handle(CDM_MessageDriver)& aMessageDriver)
|
||||
const Handle(Message_Messenger)& aMessageDriver)
|
||||
{
|
||||
struct timeb tmbuf;
|
||||
ftime (&tmbuf);
|
||||
@@ -419,7 +421,7 @@ static void take_time (const Standard_Integer isReset, const char * aHeader,
|
||||
double(tmbuf.millitm - tmbuf0.millitm)/1000.);
|
||||
aMessage += take_tm_buf;
|
||||
}
|
||||
aMessageDriver -> Write (aMessage.ToExtString());
|
||||
aMessageDriver ->Send (aMessage.ToExtString(), Message_Trace);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@@ -30,7 +30,7 @@ class XmlMDF_ADriverTable;
|
||||
class TCollection_ExtendedString;
|
||||
class CDM_Document;
|
||||
class TCollection_AsciiString;
|
||||
class CDM_MessageDriver;
|
||||
class Message_Messenger;
|
||||
|
||||
|
||||
class XmlLDrivers_DocumentStorageDriver;
|
||||
@@ -49,7 +49,7 @@ public:
|
||||
|
||||
Standard_EXPORT virtual void Write (const Handle(CDM_Document)& theDocument, Standard_OStream& theOStream) Standard_OVERRIDE;
|
||||
|
||||
Standard_EXPORT virtual Handle(XmlMDF_ADriverTable) AttributeDrivers (const Handle(CDM_MessageDriver)& theMsgDriver);
|
||||
Standard_EXPORT virtual Handle(XmlMDF_ADriverTable) AttributeDrivers (const Handle(Message_Messenger)& theMsgDriver);
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user