Integration of OCCT 6.5.0 from SVN
[occt.git] / src / PCDM / PCDM.cxx
CommitLineData
7fd59977 1// File: PCDM.cxx
2// Created: Wed Nov 5 11:53:15 1997
3// Author: Jean-Louis Frenkel
4// <rmi@frilox.paris1.matra-dtv.fr>
5
6
7#include <PCDM.ixx>
8#include <Plugin.hxx>
9#include <Standard_SStream.hxx>
10#include <Standard_NoSuchObject.hxx>
11#include <Resource_Manager.hxx>
12#include <Standard_GUID.hxx>
13#include <UTL.hxx>
14#include <FSD_CmpFile.hxx>
15#include <FSD_File.hxx>
16#include <FSD_BinaryFile.hxx>
17
18//=======================================================================
19//function : StorageDriver
20//purpose : gets in the EuclidDesktop resource the plugin
21// identifier of the driver plugs the driver.
22//=======================================================================
23
24Handle(PCDM_StorageDriver) PCDM::StorageDriver(const Handle(CDM_Document)& aDocument) {
25
26 if(!PCDM::FindStorageDriver(aDocument)) {
27 Standard_SStream aMsg; aMsg << "could not find the storage driver plugin resource for the format: " << aDocument->StorageFormat()<<(char) 0;
28 Standard_NoSuchObject::Raise(aMsg);
29 }
30 //return Handle(PCDM_StorageDriver)::DownCast(Plugin::Load(aDocument->StoragePlugin()));
31 Handle(PCDM_StorageDriver) DRIVER =
32 Handle(PCDM_StorageDriver)::DownCast(Plugin::Load(aDocument->StoragePlugin()));
33 if (!DRIVER.IsNull()) DRIVER->SetFormat(aDocument->StorageFormat());
34 return DRIVER;
35}
36
37//=======================================================================
38//function : FindStorageDriver
39//purpose :
40//=======================================================================
41
42Standard_Boolean PCDM::FindStorageDriver(const Handle(CDM_Document)& aDocument) {
43
44 return aDocument->FindStoragePlugin();
45}
46
47//=======================================================================
48//function : Schema
49//purpose : returns a schema to be used during a Store or Retrieve
50// operation.
51// Schema will plug the schema defined by
52// the SchemaName method.
53//=======================================================================
54
55Handle(Storage_Schema) PCDM::Schema(const TCollection_ExtendedString& aSchemaName, const Handle(CDM_Application)& anApplication) {
56
57 Handle(Resource_Manager) r = anApplication->Resources();
58 if(!UTL::Find(r,aSchemaName)) {
59 Standard_SStream aMsg; aMsg << "could not find the plugin resource for the schema: " << TCollection_ExtendedString(aSchemaName) << (char)0;
60 Standard_NoSuchObject::Raise(aMsg);
61 }
62 Handle(Standard_Transient) t = Plugin::Load(UTL::GUID(UTL::Value(r,aSchemaName)));
63 return *((Handle(Storage_Schema)*)&t);
64
65}
66
67//=======================================================================
68//function : FileDriverType
69//purpose :
70//=======================================================================
71
72PCDM_TypeOfFileDriver PCDM::FileDriverType(const TCollection_AsciiString& aFileName, PCDM_BaseDriverPointer& aBaseDriver) {
73 if(FSD_CmpFile::IsGoodFileType(aFileName) == Storage_VSOk) {
74 aBaseDriver=new FSD_CmpFile;
75 return PCDM_TOFD_CmpFile;
76 }
77 else if(FSD_File::IsGoodFileType(aFileName) == Storage_VSOk) {
78 aBaseDriver=new FSD_File;
79 return PCDM_TOFD_File;
80 }
81 else if(FSD_BinaryFile::IsGoodFileType(aFileName) == Storage_VSOk) {
82 aBaseDriver=new FSD_BinaryFile;
83 return PCDM_TOFD_File;
84 }
85 else {
86 aBaseDriver=NULL;
87 return PCDM_TOFD_Unknown;
88 }
89}