0027111: Add generalized copy constructor in handle class for old compilers
[occt.git] / src / XmlLDrivers / XmlLDrivers.cxx
CommitLineData
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>
20#include <Standard_Transient.hxx>
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 33static Standard_GUID XmlLStorageDriver ("13a56820-8269-11d5-aab2-0050044b1af1");
34static Standard_GUID XmlLRetrievalDriver("13a56822-8269-11d5-aab2-0050044b1af1");
f47afe53 35#define CURRENT_DOCUMENT_VERSION 8
7fd59977 36
37//=======================================================================
38//function : Factory
39//purpose : PLUGIN FACTORY
40//=======================================================================
ce8b059a 41const Handle(Standard_Transient)& XmlLDrivers::Factory(const Standard_GUID& theGUID)
7fd59977 42{
43 if (theGUID == XmlLStorageDriver)
44 {
0797d9d3 45#ifdef OCCT_DEBUG
7fd59977 46 cout << "XmlLDrivers : Storage Plugin" << endl;
63c629aa 47#endif
4796758e 48 static Handle(Standard_Transient) model_sd =
7fd59977 49 new XmlLDrivers_DocumentStorageDriver
50 ("Copyright: Open Cascade, 2001-2002"); // default copyright
51 return model_sd;
52 }
53
54 if (theGUID == XmlLRetrievalDriver)
55 {
0797d9d3 56#ifdef OCCT_DEBUG
7fd59977 57 cout << "XmlLDrivers : Retrieval Plugin" << endl;
63c629aa 58#endif
4796758e 59 static Handle (Standard_Transient) model_rd =
7fd59977 60 new XmlLDrivers_DocumentRetrievalDriver ();
61 return model_rd;
62 }
63
64 Standard_Failure::Raise ("XmlLDrivers : unknown GUID");
ce8b059a 65 static Handle(Standard_Transient) aNullHandle;
66 return aNullHandle;
7fd59977 67}
68
69#define SLENGTH 80
70//=======================================================================
71//function : CreationDate
72//purpose : mm/dd/yy
73//=======================================================================
74TCollection_AsciiString XmlLDrivers::CreationDate ()
75{
7fd59977 76 Standard_Character nowstr[SLENGTH];
77 time_t nowbin;
78 struct tm *nowstruct;
79
80 if (time(&nowbin) == (time_t) - 1)
63c629aa 81 {
0797d9d3 82#ifdef OCCT_DEBUG
7fd59977 83 cerr << "Storage ERROR : Could not get time of day from time()" << endl;
63c629aa 84#endif
85 }
7fd59977 86
87 nowstruct = localtime(&nowbin);
88
89 if (strftime(nowstr, SLENGTH, "%Y-%m-%d", nowstruct) == (size_t) 0)
63c629aa 90 {
0797d9d3 91#ifdef OCCT_DEBUG
7fd59977 92 cerr << "Storage ERROR : Could not get string from strftime()" << endl;
63c629aa 93#endif
94 }
7fd59977 95
7fd59977 96 return nowstr;
97}
98
99//=======================================================================
100//function : AttributeDrivers
101//purpose :
102//=======================================================================
103Handle(XmlMDF_ADriverTable) XmlLDrivers::AttributeDrivers
857ffd5e 104 (const Handle(CDM_MessageDriver)& theMessageDriver)
7fd59977 105{
106 Handle(XmlMDF_ADriverTable) aTable = new XmlMDF_ADriverTable();
107 //
108 XmlMDF ::AddDrivers (aTable, theMessageDriver);
109 XmlMDataStd ::AddDrivers (aTable, theMessageDriver);
110 XmlMFunction ::AddDrivers (aTable, theMessageDriver);
111 XmlMDocStd ::AddDrivers (aTable, theMessageDriver);
112 //
113 return aTable;
114}
115
116//=======================================================================
117//function : StorageVersion
118//purpose : Document storage version
119//=======================================================================
120
121TCollection_AsciiString XmlLDrivers::StorageVersion()
122{
123 TCollection_AsciiString aVersionStr (CURRENT_DOCUMENT_VERSION);
124 return aVersionStr;
125}
126
127// Declare entry point PLUGINFACTORY
128PLUGIN(XmlLDrivers)