Fraxinus  2023.01.05-dev+develop.0da12
An IGT application
cxSessionStorageService.cpp
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) SINTEF Department of Medical Technology.
5 All rights reserved.
6 
7 CustusX is released under a BSD 3-Clause license.
8 
9 See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt) for details.
10 =========================================================================*/
11 
13 #include "cxNullDeleter.h"
14 #include <QDir>
15 
16 namespace cx
17 {
18 
20 {
21 
22 }
23 
25 {
26 
27 }
28 
30 {
31 public:
33  virtual void load(QString dir) {}
34  virtual void save() {}
35  virtual void clear() {}
36  virtual bool isValid() const { return false; }
37  virtual QString getRootFolder() const { return ""; }
38 
39  virtual bool isNull() const { return true; }
40 };
41 
43 {
44  static SessionStorageServicePtr mNull;
45  if (!mNull)
46  mNull.reset(new SessionStorageServiceNull, null_deleter());
47  return mNull;
48 }
49 
50 QString SessionStorageService::getSubFolder(QString relative)
51 {
52  QString root = this->getRootFolder();
53  if (root.isEmpty())
54  return "";
55 
56  QString path = root + "/" + relative;
57  QDir dir(path);
58  if (!dir.exists())
59  dir.mkpath(path);
60  return path;
61 }
62 
63 
64 } // cx
virtual void load(QString dir)
load session from dir, or create new session in this location if none exist
QString getSubFolder(QString relative)
return and create a folder/path relative to root. Created if necessary.
virtual QString getRootFolder() const =0
virtual void save()
Save all application data to XML file.
virtual QString getRootFolder() const
static SessionStorageServicePtr getNullObject()
boost::shared_ptr< class SessionStorageService > SessionStorageServicePtr
Namespace for all CustusX production code.