b311480e |
1 | // Created on: 1997-08-08 |
2 | // Created by: Jean-Louis Frenkel |
3 | // Copyright (c) 1997-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
d5f74e42 |
8 | // This library is free software; you can redistribute it and/or modify it under |
9 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
10 | // by the Free Software Foundation, with special exception defined in the file |
11 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
12 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
7fd59977 |
16 | |
42cf5bc1 |
17 | |
18 | #include <CDF_Application.hxx> |
19 | #include <CDF_Directory.hxx> |
b6c0b841 |
20 | #include <CDF_FWOSDriver.hxx> |
42cf5bc1 |
21 | #include <CDF_MetaDataDriver.hxx> |
22 | #include <CDF_MetaDataDriverFactory.hxx> |
23 | #include <CDF_Session.hxx> |
7fd59977 |
24 | #include <PCDM.hxx> |
25 | #include <PCDM_Reader.hxx> |
42cf5bc1 |
26 | #include <Plugin.hxx> |
7fd59977 |
27 | #include <Standard_ErrorHandler.hxx> |
28 | #include <Standard_Failure.hxx> |
42cf5bc1 |
29 | #include <Standard_GUID.hxx> |
30 | #include <Standard_MultiplyDefined.hxx> |
31 | #include <Standard_NoSuchObject.hxx> |
32 | #include <Standard_Type.hxx> |
33 | #include <TCollection_ExtendedString.hxx> |
7fd59977 |
34 | |
92efcf78 |
35 | IMPLEMENT_STANDARD_RTTIEXT(CDF_Session,Standard_Transient) |
36 | |
7fd59977 |
37 | static Handle(CDF_Session) CS; |
38 | |
39 | //======================================================================= |
40 | //function : |
41 | //purpose : |
42 | //======================================================================= |
43 | CDF_Session::CDF_Session () : myHasCurrentApplication(Standard_False) |
44 | { |
45 | Standard_MultiplyDefined_Raise_if(!CS.IsNull()," a session already exists"); |
46 | myDirectory = new CDF_Directory(); |
47 | CS = this; |
48 | } |
49 | |
50 | //======================================================================= |
51 | //function : Exists |
52 | //purpose : |
53 | //======================================================================= |
54 | Standard_Boolean CDF_Session::Exists() { |
55 | return !CS.IsNull(); |
56 | } |
57 | |
58 | //======================================================================= |
59 | //function : Directory |
60 | //purpose : |
61 | //======================================================================= |
62 | Handle(CDF_Directory) CDF_Session::Directory() const { |
63 | |
64 | return CS->myDirectory; |
65 | } |
66 | |
67 | //======================================================================= |
68 | //function : CurrentSession |
69 | //purpose : |
70 | //======================================================================= |
71 | Handle(CDF_Session) CDF_Session::CurrentSession() { |
72 | Standard_NoSuchObject_Raise_if(CS.IsNull(), "no session has been created"); |
73 | return CS; |
74 | } |
75 | |
76 | //======================================================================= |
77 | //function : HasCurrentApplication |
78 | //purpose : |
79 | //======================================================================= |
80 | Standard_Boolean CDF_Session::HasCurrentApplication() const { |
81 | return myHasCurrentApplication; |
82 | } |
83 | |
84 | //======================================================================= |
85 | //function : CurrentApplication |
86 | //purpose : |
87 | //======================================================================= |
88 | Handle(CDF_Application) CDF_Session::CurrentApplication() const { |
89 | Standard_NoSuchObject_Raise_if(!myHasCurrentApplication,"there is no current application in the session"); |
90 | return myCurrentApplication; |
91 | } |
92 | |
93 | //======================================================================= |
94 | //function : SetCurrentApplication |
95 | //purpose : |
96 | //======================================================================= |
97 | void CDF_Session::SetCurrentApplication(const Handle(CDF_Application)& anApplication) { |
98 | myCurrentApplication = anApplication; |
99 | myHasCurrentApplication = Standard_True; |
100 | } |
101 | |
102 | //======================================================================= |
103 | //function : UnsetCurrentApplication |
104 | //purpose : |
105 | //======================================================================= |
106 | void CDF_Session::UnsetCurrentApplication() { |
107 | myHasCurrentApplication = Standard_False; |
108 | myCurrentApplication.Nullify(); |
109 | } |
110 | |
111 | //======================================================================= |
112 | //function : MetaDataDriver |
113 | //purpose : |
114 | //======================================================================= |
115 | Handle(CDF_MetaDataDriver) CDF_Session::MetaDataDriver() const { |
116 | Standard_NoSuchObject_Raise_if(myMetaDataDriver.IsNull(),"no metadatadriver has been provided; this session is not able to store or retrieve files."); |
117 | return myMetaDataDriver; |
118 | } |
119 | |
120 | //======================================================================= |
121 | //function : LoadDriver |
122 | //purpose : |
123 | //======================================================================= |
124 | void CDF_Session::LoadDriver() { |
b6c0b841 |
125 | if (myMetaDataDriver.IsNull()) { |
6fe96f84 |
126 | // for compatibility with old code, initialize useless driver directly |
127 | // instead of loading it as plugin |
b6c0b841 |
128 | Handle(CDF_MetaDataDriverFactory) aFactory; |
6fe96f84 |
129 | myMetaDataDriver = new CDF_FWOSDriver; |
b6c0b841 |
130 | } |
7fd59977 |
131 | } |