0025418: Debug output to be limited to OCC development environment
[occt.git] / src / XmlLDrivers / XmlLDrivers.cxx
1 // Created on: 2001-07-09
2 // Created by: Julia DOROVSKIKH
3 // Copyright (c) 2001-2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
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.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 #include <XmlLDrivers.ixx>
17
18 #include <XmlLDrivers_DocumentStorageDriver.hxx>
19 #include <XmlLDrivers_DocumentRetrievalDriver.hxx>
20 #include <XmlMDF_ADriverTable.hxx>
21 #include <XmlMDF.hxx>
22 #include <XmlMDataStd.hxx>
23 #include <XmlMDocStd.hxx>
24 #include <XmlMFunction.hxx>
25 #include <Standard_GUID.hxx>
26
27 #include <locale.h>
28 #include <time.h>
29 #include <Plugin_Macro.hxx>
30
31 static Standard_GUID XmlLStorageDriver  ("13a56820-8269-11d5-aab2-0050044b1af1");
32 static Standard_GUID XmlLRetrievalDriver("13a56822-8269-11d5-aab2-0050044b1af1");
33 #define CURRENT_DOCUMENT_VERSION 7
34
35 //=======================================================================
36 //function : Factory
37 //purpose  : PLUGIN FACTORY
38 //=======================================================================
39 Handle(Standard_Transient) XmlLDrivers::Factory(const Standard_GUID& theGUID)
40 {
41   if (theGUID == XmlLStorageDriver)
42   {
43 #ifdef OCCT_DEBUG
44     cout << "XmlLDrivers : Storage Plugin" << endl;
45 #endif
46     static Handle(XmlLDrivers_DocumentStorageDriver) model_sd =
47       new XmlLDrivers_DocumentStorageDriver
48         ("Copyright: Open Cascade, 2001-2002"); // default copyright
49     return model_sd;
50   }
51
52   if (theGUID == XmlLRetrievalDriver)
53   {
54 #ifdef OCCT_DEBUG
55     cout << "XmlLDrivers : Retrieval Plugin" << endl;
56 #endif
57     static Handle (XmlLDrivers_DocumentRetrievalDriver) model_rd =
58       new XmlLDrivers_DocumentRetrievalDriver ();
59     return model_rd;
60   }
61  
62   Standard_Failure::Raise ("XmlLDrivers : unknown GUID");
63   return NULL;
64 }
65
66 #define SLENGTH 80
67 //=======================================================================
68 //function : CreationDate
69 //purpose  : mm/dd/yy
70 //=======================================================================
71 TCollection_AsciiString XmlLDrivers::CreationDate ()
72 {
73   Standard_Character nowstr[SLENGTH];
74   time_t nowbin;
75   struct tm *nowstruct;
76
77   if (time(&nowbin) == (time_t) - 1)
78   {
79 #ifdef OCCT_DEBUG
80     cerr << "Storage ERROR : Could not get time of day from time()" << endl;
81 #endif
82   }
83   
84   nowstruct = localtime(&nowbin);
85   
86   if (strftime(nowstr, SLENGTH, "%Y-%m-%d", nowstruct) == (size_t) 0)
87   {
88 #ifdef OCCT_DEBUG
89     cerr << "Storage ERROR : Could not get string from strftime()" << endl;
90 #endif
91   }
92
93   return nowstr;
94 }
95
96 //=======================================================================
97 //function : AttributeDrivers
98 //purpose  : 
99 //=======================================================================
100 Handle(XmlMDF_ADriverTable) XmlLDrivers::AttributeDrivers
101                 (const Handle(CDM_MessageDriver)& theMessageDriver)
102 {
103   Handle(XmlMDF_ADriverTable) aTable = new XmlMDF_ADriverTable();
104   //
105   XmlMDF        ::AddDrivers (aTable, theMessageDriver);
106   XmlMDataStd   ::AddDrivers (aTable, theMessageDriver);
107   XmlMFunction  ::AddDrivers (aTable, theMessageDriver);
108   XmlMDocStd    ::AddDrivers (aTable, theMessageDriver); 
109   //
110   return aTable;
111 }
112
113 //=======================================================================
114 //function : StorageVersion
115 //purpose  : Document storage version
116 //=======================================================================
117
118 TCollection_AsciiString XmlLDrivers::StorageVersion()
119 {
120   TCollection_AsciiString aVersionStr (CURRENT_DOCUMENT_VERSION);
121   return aVersionStr;
122 }
123
124 #ifdef _MSC_VER
125 #pragma warning(disable:4190) /* disable warning on C++ type returned by C function; should be OK for C++ usage */
126 #endif
127
128 // Declare entry point PLUGINFACTORY
129 PLUGIN(XmlLDrivers)