NorMIT-nav  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
cx::null_deleter
Definition: cxNullDeleter.h:8
cx::SessionStorageServiceNull::clear
virtual void clear()
Definition: cxSessionStorageService.cpp:35
cx::SessionStorageServiceNull::load
virtual void load(QString dir)
load session from dir, or create new session in this location if none exist
Definition: cxSessionStorageService.cpp:33
cx::SessionStorageServiceNull::~SessionStorageServiceNull
virtual ~SessionStorageServiceNull()
Definition: cxSessionStorageService.cpp:32
cx
Namespace for all CustusX production code.
Definition: cx_dev_group_definitions.h:13
cx::SessionStorageService::getNullObject
static SessionStorageServicePtr getNullObject()
Definition: cxSessionStorageService.cpp:42
cxSessionStorageService.h
cx::SessionStorageServiceNull::isNull
virtual bool isNull() const
Definition: cxSessionStorageService.cpp:39
cx::SessionStorageService::SessionStorageService
SessionStorageService()
Definition: cxSessionStorageService.cpp:19
cx::SessionStorageService
Definition: cxSessionStorageService.h:42
cx::SessionStorageServicePtr
boost::shared_ptr< class SessionStorageService > SessionStorageServicePtr
Definition: cxLogicManager.h:30
cxNullDeleter.h
cx::SessionStorageServiceNull::isValid
virtual bool isValid() const
Definition: cxSessionStorageService.cpp:36
cx::SessionStorageServiceNull
Definition: cxSessionStorageService.cpp:29
cx::SessionStorageServiceNull::save
virtual void save()
Save all application data to XML file.
Definition: cxSessionStorageService.cpp:34
cx::SessionStorageServiceNull::getRootFolder
virtual QString getRootFolder() const
Definition: cxSessionStorageService.cpp:37
cx::SessionStorageService::getRootFolder
virtual QString getRootFolder() const =0
cx::SessionStorageService::getSubFolder
QString getSubFolder(QString relative)
return and create a folder/path relative to root. Created if necessary.
Definition: cxSessionStorageService.cpp:50
cx::SessionStorageService::~SessionStorageService
virtual ~SessionStorageService()
Definition: cxSessionStorageService.cpp:24