NorMIT-nav  22.09
An IGT application
cxActiveData.h
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 
12 #ifndef CXACTIVEDATA_H
13 #define CXACTIVEDATA_H
14 
15 #include "cxResourceExport.h"
16 #include <QObject>
17 #include <QList>
18 #include "boost/shared_ptr.hpp"
20 
21 namespace cx
22 {
23 typedef boost::shared_ptr<class ActiveData> ActiveDataPtr;
24 typedef boost::shared_ptr<class Data> DataPtr;
25 typedef boost::shared_ptr<class Image> ImagePtr;
26 typedef boost::shared_ptr<class PatientStorage> PatientStoragePtr;
27 
35 class cxResource_EXPORT ActiveData : public QObject
36 {
37  Q_OBJECT
38 public:
39  ActiveData(PatientModelServicePtr patientModelService, SessionStorageServicePtr sessionStorageService);
40  virtual QList<DataPtr> getActiveDataHistory() const;
41  virtual DataPtr getActive() const;
42  virtual DataPtr getActiveUsingRegexp(QString typeRegexp) const;
43  template <class DATA>
44  boost::shared_ptr<DATA> getActive() const;
45  virtual ImagePtr getDerivedActiveImage() const;
46  virtual void setActive(DataPtr activeData);
47  virtual void setActive(QString uid);
48  virtual QString getActiveImageUid();
49  virtual void remove(DataPtr dataToBeRemoved);
50 
51  static ActiveDataPtr getNullObject();
52  virtual bool isNull() const { return false;}
53 signals:
54  void activeImageChanged(const QString& uId);
55  void activeDataChanged(const QString& uId);
56 
57 private:
58  QList<DataPtr> mActiveData;
59  PatientStoragePtr mStorage;
60  PatientModelServicePtr mPatientModelService;
61  static ActiveDataPtr mNull;
62 
63  void emitSignals(DataPtr activeData);
64  void emitActiveDataChanged();
65  void emitActiveImageChanged();
66  QString getChangedUid(DataPtr activeData) const;
67  QList<DataPtr> getActiveDataHistory(QString typeRegexp) const;
68  QString getStringToSave() const;
69  QStringList getActiveDataStringList() const;
70  void loadFromString(const QString activeDatas);
71 };
72 
73 template <class DATA>
74 boost::shared_ptr<DATA> ActiveData::getActive() const
75 {
76  boost::shared_ptr<DATA> retval;
77  QList<DataPtr> activeDataList = this->getActiveDataHistory();
78  for(int i = activeDataList.size() - 1; i >= 0; --i)
79  {
80  retval = boost::dynamic_pointer_cast<DATA>(activeDataList.at(i));
81  if(retval)
82  return retval;
83  }
84  return retval;
85 }
86 
87 
88 } //cx
89 
90 #endif // CXACTIVEDATA_H
cx
Namespace for all CustusX production code.
Definition: cx_dev_group_definitions.h:13
cx::PatientStoragePtr
boost::shared_ptr< class PatientStorage > PatientStoragePtr
Definition: cxVBWidget.h:34
cxSessionStorageService.h
cx::ActiveData::isNull
virtual bool isNull() const
Definition: cxActiveData.h:52
cx::ActiveData::getActive
virtual DataPtr getActive() const
Definition: cxActiveData.cpp:121
cx::SessionStorageServicePtr
boost::shared_ptr< class SessionStorageService > SessionStorageServicePtr
Definition: cxLogicManager.h:30
cx::ActiveData
Provides the last active data of warious types.
Definition: cxActiveData.h:35
cx::PatientModelServicePtr
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
Definition: cxLogicManager.h:25
cx::DataPtr
boost::shared_ptr< class Data > DataPtr
Definition: cxRegistrationApplicator.h:22
cx::ImagePtr
boost::shared_ptr< class Image > ImagePtr
Definition: cxDicomWidget.h:27
cx::ActiveDataPtr
boost::shared_ptr< class ActiveData > ActiveDataPtr
Definition: cxColorWidget.h:21
cx::ActiveData::getActiveDataHistory
virtual QList< DataPtr > getActiveDataHistory() const
Definition: cxActiveData.cpp:116