1 // Created on: 2001-07-09
2 // Created by: Julia DOROVSKIKH
3 // Copyright (c) 2001-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
17 #include <Message_Messenger.hxx>
18 #include <Plugin_Macro.hxx>
19 #include <Standard_GUID.hxx>
20 #include <TDocStd_Application.hxx>
21 #include <TCollection_AsciiString.hxx>
22 #include <XmlLDrivers.hxx>
23 #include <XmlLDrivers_DocumentRetrievalDriver.hxx>
24 #include <XmlLDrivers_DocumentStorageDriver.hxx>
25 #include <XmlMDataStd.hxx>
27 #include <XmlMDF_ADriverTable.hxx>
28 #include <XmlMDocStd.hxx>
29 #include <XmlMFunction.hxx>
33 static Standard_GUID XmlLStorageDriver ("13a56820-8269-11d5-aab2-0050044b1af1");
34 static Standard_GUID XmlLRetrievalDriver("13a56822-8269-11d5-aab2-0050044b1af1");
36 static int CURRENT_DOCUMENT_VERSION(9);
38 //=======================================================================
40 //purpose : PLUGIN FACTORY
41 //=======================================================================
42 const Handle(Standard_Transient)& XmlLDrivers::Factory(const Standard_GUID& theGUID)
44 if (theGUID == XmlLStorageDriver)
47 std::cout << "XmlLDrivers : Storage Plugin" << std::endl;
49 static Handle(Standard_Transient) model_sd =
50 new XmlLDrivers_DocumentStorageDriver
51 ("Copyright: Open Cascade, 2001-2002"); // default copyright
55 if (theGUID == XmlLRetrievalDriver)
58 std::cout << "XmlLDrivers : Retrieval Plugin" << std::endl;
60 static Handle (Standard_Transient) model_rd =
61 new XmlLDrivers_DocumentRetrievalDriver ();
65 throw Standard_Failure("XmlLDrivers : unknown GUID");
69 //=======================================================================
70 //function : CreationDate
72 //=======================================================================
73 TCollection_AsciiString XmlLDrivers::CreationDate ()
75 Standard_Character nowstr[SLENGTH];
79 if (time(&nowbin) == (time_t) - 1)
82 std::cerr << "Storage ERROR : Could not get time of day from time()" << std::endl;
86 nowstruct = localtime(&nowbin);
88 if (strftime(nowstr, SLENGTH, "%Y-%m-%d", nowstruct) == (size_t) 0)
91 std::cerr << "Storage ERROR : Could not get string from strftime()" << std::endl;
98 //=======================================================================
99 //function : DefineFormat
101 //=======================================================================
102 void XmlLDrivers::DefineFormat (const Handle(TDocStd_Application)& theApp)
104 theApp->DefineFormat ("XmlLOcaf", "Xml Lite OCAF Document", "xmll",
105 new XmlLDrivers_DocumentRetrievalDriver,
106 new XmlLDrivers_DocumentStorageDriver ("Copyright: Open Cascade, 2001-2002"));
109 //=======================================================================
110 //function : AttributeDrivers
112 //=======================================================================
113 Handle(XmlMDF_ADriverTable) XmlLDrivers::AttributeDrivers
114 (const Handle(Message_Messenger)& theMessageDriver)
116 Handle(XmlMDF_ADriverTable) aTable = new XmlMDF_ADriverTable();
118 XmlMDF ::AddDrivers (aTable, theMessageDriver);
119 XmlMDataStd ::AddDrivers (aTable, theMessageDriver);
120 XmlMFunction ::AddDrivers (aTable, theMessageDriver);
121 XmlMDocStd ::AddDrivers (aTable, theMessageDriver);
126 //=======================================================================
127 //function : StorageVersion
128 //purpose : Document storage version
129 //=======================================================================
131 int XmlLDrivers::StorageVersion()
133 return CURRENT_DOCUMENT_VERSION;
136 // Declare entry point PLUGINFACTORY