b311480e |
1 | // Created on: 2001-07-09 |
2 | // Created by: Julia DOROVSKIKH |
973c2be1 |
3 | // Copyright (c) 2001-2014 OPEN CASCADE SAS |
b311480e |
4 | // |
973c2be1 |
5 | // This file is part of Open CASCADE Technology software library. |
b311480e |
6 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
12 | // |
973c2be1 |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
7fd59977 |
15 | |
7fd59977 |
16 | |
42cf5bc1 |
17 | #include <CDM_MessageDriver.hxx> |
18 | #include <Plugin_Macro.hxx> |
19 | #include <Standard_GUID.hxx> |
6fe96f84 |
20 | #include <TDocStd_Application.hxx> |
42cf5bc1 |
21 | #include <TCollection_AsciiString.hxx> |
22 | #include <XmlLDrivers.hxx> |
7fd59977 |
23 | #include <XmlLDrivers_DocumentRetrievalDriver.hxx> |
42cf5bc1 |
24 | #include <XmlLDrivers_DocumentStorageDriver.hxx> |
7fd59977 |
25 | #include <XmlMDataStd.hxx> |
42cf5bc1 |
26 | #include <XmlMDF.hxx> |
27 | #include <XmlMDF_ADriverTable.hxx> |
7fd59977 |
28 | #include <XmlMDocStd.hxx> |
29 | #include <XmlMFunction.hxx> |
7fd59977 |
30 | |
31 | #include <locale.h> |
32 | #include <time.h> |
7fd59977 |
33 | static Standard_GUID XmlLStorageDriver ("13a56820-8269-11d5-aab2-0050044b1af1"); |
34 | static Standard_GUID XmlLRetrievalDriver("13a56822-8269-11d5-aab2-0050044b1af1"); |
c2f5b821 |
35 | |
36 | static int CURRENT_DOCUMENT_VERSION(9); |
7fd59977 |
37 | |
38 | //======================================================================= |
39 | //function : Factory |
40 | //purpose : PLUGIN FACTORY |
41 | //======================================================================= |
ce8b059a |
42 | const Handle(Standard_Transient)& XmlLDrivers::Factory(const Standard_GUID& theGUID) |
7fd59977 |
43 | { |
44 | if (theGUID == XmlLStorageDriver) |
45 | { |
0797d9d3 |
46 | #ifdef OCCT_DEBUG |
7fd59977 |
47 | cout << "XmlLDrivers : Storage Plugin" << endl; |
63c629aa |
48 | #endif |
4796758e |
49 | static Handle(Standard_Transient) model_sd = |
7fd59977 |
50 | new XmlLDrivers_DocumentStorageDriver |
51 | ("Copyright: Open Cascade, 2001-2002"); // default copyright |
52 | return model_sd; |
53 | } |
54 | |
55 | if (theGUID == XmlLRetrievalDriver) |
56 | { |
0797d9d3 |
57 | #ifdef OCCT_DEBUG |
7fd59977 |
58 | cout << "XmlLDrivers : Retrieval Plugin" << endl; |
63c629aa |
59 | #endif |
4796758e |
60 | static Handle (Standard_Transient) model_rd = |
7fd59977 |
61 | new XmlLDrivers_DocumentRetrievalDriver (); |
62 | return model_rd; |
63 | } |
64 | |
9775fa61 |
65 | throw Standard_Failure("XmlLDrivers : unknown GUID"); |
7fd59977 |
66 | } |
67 | |
68 | #define SLENGTH 80 |
69 | //======================================================================= |
70 | //function : CreationDate |
71 | //purpose : mm/dd/yy |
72 | //======================================================================= |
73 | TCollection_AsciiString XmlLDrivers::CreationDate () |
74 | { |
7fd59977 |
75 | Standard_Character nowstr[SLENGTH]; |
76 | time_t nowbin; |
77 | struct tm *nowstruct; |
78 | |
79 | if (time(&nowbin) == (time_t) - 1) |
63c629aa |
80 | { |
0797d9d3 |
81 | #ifdef OCCT_DEBUG |
7fd59977 |
82 | cerr << "Storage ERROR : Could not get time of day from time()" << endl; |
63c629aa |
83 | #endif |
84 | } |
7fd59977 |
85 | |
86 | nowstruct = localtime(&nowbin); |
87 | |
88 | if (strftime(nowstr, SLENGTH, "%Y-%m-%d", nowstruct) == (size_t) 0) |
63c629aa |
89 | { |
0797d9d3 |
90 | #ifdef OCCT_DEBUG |
7fd59977 |
91 | cerr << "Storage ERROR : Could not get string from strftime()" << endl; |
63c629aa |
92 | #endif |
93 | } |
7fd59977 |
94 | |
7fd59977 |
95 | return nowstr; |
96 | } |
97 | |
98 | //======================================================================= |
6fe96f84 |
99 | //function : DefineFormat |
100 | //purpose : |
101 | //======================================================================= |
102 | void XmlLDrivers::DefineFormat (const Handle(TDocStd_Application)& theApp) |
103 | { |
104 | theApp->DefineFormat ("XmlLOcaf", "Xml Lite OCAF Document", "xmll", |
105 | new XmlLDrivers_DocumentRetrievalDriver, |
106 | new XmlLDrivers_DocumentStorageDriver ("Copyright: Open Cascade, 2001-2002")); |
107 | } |
108 | |
109 | //======================================================================= |
7fd59977 |
110 | //function : AttributeDrivers |
111 | //purpose : |
112 | //======================================================================= |
113 | Handle(XmlMDF_ADriverTable) XmlLDrivers::AttributeDrivers |
857ffd5e |
114 | (const Handle(CDM_MessageDriver)& theMessageDriver) |
7fd59977 |
115 | { |
116 | Handle(XmlMDF_ADriverTable) aTable = new XmlMDF_ADriverTable(); |
117 | // |
118 | XmlMDF ::AddDrivers (aTable, theMessageDriver); |
119 | XmlMDataStd ::AddDrivers (aTable, theMessageDriver); |
120 | XmlMFunction ::AddDrivers (aTable, theMessageDriver); |
121 | XmlMDocStd ::AddDrivers (aTable, theMessageDriver); |
122 | // |
123 | return aTable; |
124 | } |
125 | |
126 | //======================================================================= |
127 | //function : StorageVersion |
128 | //purpose : Document storage version |
129 | //======================================================================= |
130 | |
c2f5b821 |
131 | int XmlLDrivers::StorageVersion() |
132 | { |
133 | return CURRENT_DOCUMENT_VERSION; |
134 | } |
135 | void XmlLDrivers::SetStorageVersion(const int version) |
7fd59977 |
136 | { |
c2f5b821 |
137 | CURRENT_DOCUMENT_VERSION = version; |
7fd59977 |
138 | } |
139 | |
140 | // Declare entry point PLUGINFACTORY |
141 | PLUGIN(XmlLDrivers) |