Test for 0022778: Bug in BRepMesh
[occt.git] / src / CDF / CDF_Session.cxx
CommitLineData
b311480e 1// Created on: 1997-08-08
2// Created by: Jean-Louis Frenkel
3// Copyright (c) 1997-1999 Matra Datavision
4// Copyright (c) 1999-2012 OPEN CASCADE SAS
5//
6// The content of this file is subject to the Open CASCADE Technology Public
7// License Version 6.5 (the "License"). You may not use the content of this file
8// except in compliance with the License. Please obtain a copy of the License
9// at http://www.opencascade.org and read it completely before using this file.
10//
11// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13//
14// The Original Code and all software distributed under the License is
15// distributed on an "AS IS" basis, without warranty of any kind, and the
16// Initial Developer hereby disclaims all such warranties, including without
17// limitation, any warranties of merchantability, fitness for a particular
18// purpose or non-infringement. Please see the License for the specific terms
19// and conditions governing the rights and limitations under the License.
20
7fd59977 21
22
23#include <CDF_Session.ixx>
24#include <TCollection_ExtendedString.hxx>
25#include <CDF_MetaDataDriverFactory.hxx>
26#include <Plugin.hxx>
27#include <Standard_GUID.hxx>
28#include <PCDM.hxx>
29#include <PCDM_Reader.hxx>
30#include <Standard_ErrorHandler.hxx>
31#include <Standard_Failure.hxx>
32
33static Handle(CDF_Session) CS;
34
35//=======================================================================
36//function :
37//purpose :
38//=======================================================================
39CDF_Session::CDF_Session () : myHasCurrentApplication(Standard_False)
40{
41 Standard_MultiplyDefined_Raise_if(!CS.IsNull()," a session already exists");
42 myDirectory = new CDF_Directory();
43 CS = this;
44}
45
46//=======================================================================
47//function : Exists
48//purpose :
49//=======================================================================
50Standard_Boolean CDF_Session::Exists() {
51 return !CS.IsNull();
52}
53
54//=======================================================================
55//function : Directory
56//purpose :
57//=======================================================================
58Handle(CDF_Directory) CDF_Session::Directory() const {
59
60 return CS->myDirectory;
61}
62
63//=======================================================================
64//function : CurrentSession
65//purpose :
66//=======================================================================
67Handle(CDF_Session) CDF_Session::CurrentSession() {
68 Standard_NoSuchObject_Raise_if(CS.IsNull(), "no session has been created");
69 return CS;
70}
71
72//=======================================================================
73//function : HasCurrentApplication
74//purpose :
75//=======================================================================
76Standard_Boolean CDF_Session::HasCurrentApplication() const {
77 return myHasCurrentApplication;
78}
79
80//=======================================================================
81//function : CurrentApplication
82//purpose :
83//=======================================================================
84Handle(CDF_Application) CDF_Session::CurrentApplication() const {
85 Standard_NoSuchObject_Raise_if(!myHasCurrentApplication,"there is no current application in the session");
86 return myCurrentApplication;
87}
88
89//=======================================================================
90//function : SetCurrentApplication
91//purpose :
92//=======================================================================
93void CDF_Session::SetCurrentApplication(const Handle(CDF_Application)& anApplication) {
94 myCurrentApplication = anApplication;
95 myHasCurrentApplication = Standard_True;
96}
97
98//=======================================================================
99//function : UnsetCurrentApplication
100//purpose :
101//=======================================================================
102void CDF_Session::UnsetCurrentApplication() {
103 myHasCurrentApplication = Standard_False;
104 myCurrentApplication.Nullify();
105}
106
107//=======================================================================
108//function : MetaDataDriver
109//purpose :
110//=======================================================================
111Handle(CDF_MetaDataDriver) CDF_Session::MetaDataDriver() const {
112 Standard_NoSuchObject_Raise_if(myMetaDataDriver.IsNull(),"no metadatadriver has been provided; this session is not able to store or retrieve files.");
113 return myMetaDataDriver;
114}
115
116//=======================================================================
117//function : LoadDriver
118//purpose :
119//=======================================================================
120void CDF_Session::LoadDriver() {
121 myMetaDataDriver=Handle(CDF_MetaDataDriverFactory)::DownCast(Plugin::Load(Standard_GUID("a148e300-5740-11d1-a904-080036aaa103")))->Build();
122}