summaryrefslogtreecommitdiff
path: root/src/CDF/CDF_Session.cxx
blob: 3bf191f3ec30cf6a493cbff68b3687cdfaaf6276 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
// File:	CDF_Session.cxx
// Created:	Fri Aug  8 11:04:07 1997
// Author:	Jean-Louis Frenkel
//		<rmi@frilox.paris1.matra-dtv.fr>


#include <CDF_Session.ixx>
#include <TCollection_ExtendedString.hxx>
#include <CDF_MetaDataDriverFactory.hxx>
#include <Plugin.hxx>
#include <Standard_GUID.hxx>
#include <PCDM.hxx>
#include <PCDM_Reader.hxx>
#include <Standard_ErrorHandler.hxx>
#include <Standard_Failure.hxx>

static Handle(CDF_Session) CS;

//=======================================================================
//function : 
//purpose  : 
//=======================================================================
CDF_Session::CDF_Session () : myHasCurrentApplication(Standard_False)
{  
  Standard_MultiplyDefined_Raise_if(!CS.IsNull()," a session already exists");
  myDirectory = new CDF_Directory();
  CS = this;
}

//=======================================================================
//function : Exists
//purpose  : 
//=======================================================================
Standard_Boolean CDF_Session::Exists() {
  return !CS.IsNull();
}

//=======================================================================
//function : Directory
//purpose  : 
//=======================================================================
Handle(CDF_Directory) CDF_Session::Directory() const {
  
  return CS->myDirectory;
}

//=======================================================================
//function : CurrentSession
//purpose  : 
//=======================================================================
Handle(CDF_Session) CDF_Session::CurrentSession() {
  Standard_NoSuchObject_Raise_if(CS.IsNull(), "no session has been created");
  return CS;
}

//=======================================================================
//function : HasCurrentApplication
//purpose  : 
//=======================================================================
Standard_Boolean CDF_Session::HasCurrentApplication() const {
  return myHasCurrentApplication;
}

//=======================================================================
//function : CurrentApplication
//purpose  : 
//=======================================================================
Handle(CDF_Application) CDF_Session::CurrentApplication() const {
  Standard_NoSuchObject_Raise_if(!myHasCurrentApplication,"there is no current application in the session");
  return myCurrentApplication;
}

//=======================================================================
//function : SetCurrentApplication
//purpose  : 
//=======================================================================
void CDF_Session::SetCurrentApplication(const Handle(CDF_Application)& anApplication) {
  myCurrentApplication  = anApplication;
  myHasCurrentApplication = Standard_True;
}

//=======================================================================
//function : UnsetCurrentApplication
//purpose  : 
//=======================================================================
void CDF_Session::UnsetCurrentApplication() {
  myHasCurrentApplication = Standard_False;
  myCurrentApplication.Nullify();
}

//=======================================================================
//function : MetaDataDriver
//purpose  : 
//=======================================================================
Handle(CDF_MetaDataDriver) CDF_Session::MetaDataDriver() const {
  Standard_NoSuchObject_Raise_if(myMetaDataDriver.IsNull(),"no metadatadriver has been provided; this session is not able to store or retrieve files.");
  return myMetaDataDriver;
}

//=======================================================================
//function : LoadDriver
//purpose  : 
//=======================================================================
void CDF_Session::LoadDriver() {
   myMetaDataDriver=Handle(CDF_MetaDataDriverFactory)::DownCast(Plugin::Load(Standard_GUID("a148e300-5740-11d1-a904-080036aaa103")))->Build();
}