1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-05-31 11:15:31 +03:00
occt/src/TObj/TObj_Application.hxx
abv 6fe96f8416 0025812: Replace dynamic loading mechanism of OCAF persistence with dynamic-link one
Fields to store cached instances of reader and writer drivers for each format are added in CDF_Application.
Method DefineFormat() is added in TDocStd_Application, allowing defining format completely by single call, including drivers to be used for persistence.
All OCAF driver packages provide static method DefineFormat() that defines standard OCAF persistence format supported by corresponding package; these methods are called in DRAW to enable all persistence by default.

DRAW commands (except TObj-specific ones) now use single instance of OCAF Application, returned by DDocStd::GetApplication(). Other instances are eliminated, as well as method DDocStd::Find(const Handle(TDocStd_Application)&).
Method MessageDriver() and relevant field are moved to TDocStd_Application from its descendants.

Method CDF_Application::ReaderFromFormat() is made virtual to allow its redefinition in descendants.
Creation of storage driver is moved from PCDM::StorageDriver() to new virtual method CDF_Application::WriterFromFormat().
The code loading driver as plugin is retained in both these methods for compatibility.

Test command OCC24925 is converted to use virtual methods instead of defining plugin resource.

Migration table for old OCAF types is hard-coded in Storage_Schema::CheckTypeMigration().

Removed obsolete and unused items:
- FWOSPlugin library (driver is created directly)
- Methods in classes CDM_Document dealing with unused parameters of format
- DRAW command OCC23010 for testing non-reproducible issue #23010
- Methods PCDM::StorageDriver(), PCDM::FindStorageDriver()
- Method Formats() from CDF_Application and descendants
- Methods LoadExtensions and SchemaName from PCDM_StorageDriver
- Method Plugin::AdditionalPluginMap()
- Method BinLDrivers_DocumentStorageDriver::SchemaName()
- Method CDF_Application::DefaultExtension(), Reader(), FindReader(), FindReaderFromFormat()
- Method CDF_Store::Check()
2016-06-23 19:14:31 +03:00

124 lines
3.7 KiB
C++

// Created on: 2004-11-23
// Created by: Pavel TELKOV
// Copyright (c) 2004-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
// The original implementation Copyright: (C) RINA S.p.A
#ifndef TObj_Application_HeaderFile
#define TObj_Application_HeaderFile
#include <TDocStd_Application.hxx>
#include <TObj_Common.hxx>
#include <Message_Gravity.hxx>
#include <Message_Messenger.hxx>
#include <TColStd_SequenceOfExtendedString.hxx>
//!
//! This is a base class for OCAF based TObj models
//! with declared virtual methods
//!
class TObj_Application : public TDocStd_Application
{
public:
//! Returns static instance of the application
Standard_EXPORT static Handle(TObj_Application) GetInstance();
//! Returns reference to associated messenger handle
Standard_EXPORT Handle(Message_Messenger) &Messenger() { return myMessenger; }
public:
/**
* Load/Save support
*/
//! Saving the OCAF document to a file
virtual Standard_EXPORT Standard_Boolean SaveDocument
(const Handle(TDocStd_Document)& theSourceDoc,
const char* theTargetFile);
//! Loading the OCAF document from a file
virtual Standard_EXPORT Standard_Boolean LoadDocument
(const char* theSourceFile,
Handle(TDocStd_Document)& theTargetDoc);
//! Create the OCAF document from scratch
virtual Standard_EXPORT Standard_Boolean CreateNewDocument
(Handle(TDocStd_Document)& theDoc,
const TCollection_ExtendedString& theFormat);
//! Signal error during Load or Save
//! Default imiplementation is empty
virtual Standard_EXPORT void ErrorMessage
(const TCollection_ExtendedString &theMsg,
const Message_Gravity theLevel);
//! Signal error during Load or Save
//! Default imiplementation invoke previous declaration with 0
virtual Standard_EXPORT void ErrorMessage
(const TCollection_ExtendedString &theMsg)
{ ErrorMessage( theMsg, Message_Alarm ); }
//! Sets the verbose flag, meaning that load/save models should show
//! CPU and elapsed times
void SetVerbose (const Standard_Boolean isVerbose)
{ myIsVerbose = isVerbose; }
//! Returns the verbose flag
Standard_Boolean IsVerbose () const
{ return myIsVerbose; }
public:
/**
* Redefined OCAF methods
*/
//! Return name of resource (i.e. "TObj")
virtual Standard_EXPORT Standard_CString ResourcesName() Standard_OVERRIDE;
protected:
/**
* Constructor
*/
//! Constructor is protected. Use method GetInstance() method to obtain
//! the static instance of the object (or derive your own application)
Standard_EXPORT TObj_Application();
private:
/**
* Fields
*/
Standard_Boolean myIsError; //!< error flag
Standard_Boolean myIsVerbose; //!< verbose flag
Handle(Message_Messenger) myMessenger; //!< messenger
public:
//! CASCADE RTTI
DEFINE_STANDARD_RTTIEXT(TObj_Application,TDocStd_Application)
};
//! Define handle class
DEFINE_STANDARD_HANDLE(TObj_Application,TDocStd_Application)
#endif
#ifdef _MSC_VER
#pragma once
#endif