Fraxinus  16.5.0-fx-rc5
An IGT application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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) 2008-2014, SINTEF Department of Medical Technology
5 All rights reserved.
6 
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
9 
10 1. Redistributions of source code must retain the above copyright notice,
11  this list of conditions and the following disclaimer.
12 
13 2. Redistributions in binary form must reproduce the above copyright notice,
14  this list of conditions and the following disclaimer in the documentation
15  and/or other materials provided with the distribution.
16 
17 3. Neither the name of the copyright holder nor the names of its contributors
18  may be used to endorse or promote products derived from this software
19  without specific prior written permission.
20 
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 =========================================================================*/
32 
33 #ifndef CXACTIVEDATA_H
34 #define CXACTIVEDATA_H
35 
36 #include "cxResourceExport.h"
37 #include <QObject>
38 #include <QList>
39 #include "boost/shared_ptr.hpp"
41 
42 namespace cx
43 {
44 typedef boost::shared_ptr<class ActiveData> ActiveDataPtr;
45 typedef boost::shared_ptr<class Data> DataPtr;
46 typedef boost::shared_ptr<class Image> ImagePtr;
47 typedef boost::shared_ptr<class PatientStorage> PatientStoragePtr;
48 
56 class cxResource_EXPORT ActiveData : public QObject
57 {
58  Q_OBJECT
59 public:
61  virtual QList<DataPtr> getActiveDataHistory() const;
62  virtual DataPtr getActive() const;
63  virtual DataPtr getActiveUsingRegexp(QString typeRegexp) const;
64  template <class DATA>
65  boost::shared_ptr<DATA> getActive() const;
66  virtual ImagePtr getDerivedActiveImage() const;
67  virtual void setActive(DataPtr activeData);
68  virtual void setActive(QString uid);
69  virtual QString getActiveImageUid();
70  virtual void remove(DataPtr dataToBeRemoved);
71 
72  static ActiveDataPtr getNullObject();
73  virtual bool isNull() const { return false;}
74 signals:
75  void activeImageChanged(const QString& uId);
76  void activeDataChanged(const QString& uId);
77 
78 private:
79  QList<DataPtr> mActiveData;
80  PatientStoragePtr mStorage;
81  PatientModelServicePtr mPatientModelService;
82  static ActiveDataPtr mNull;
83 
84  void emitSignals(DataPtr activeData);
85  void emitActiveDataChanged();
86  void emitActiveImageChanged();
87  QString getChangedUid(DataPtr activeData) const;
88  QList<DataPtr> getActiveDataHistory(QString typeRegexp) const;
89  QString getStringToSave() const;
90  QStringList getActiveDataStringList() const;
91  void loadFromString(const QString activeDatas);
92 };
93 
94 template <class DATA>
95 boost::shared_ptr<DATA> ActiveData::getActive() const
96 {
97  boost::shared_ptr<DATA> retval;
98  QList<DataPtr> activeDataList = this->getActiveDataHistory();
99  for(int i = activeDataList.size() - 1; i >= 0; --i)
100  {
101  retval = boost::dynamic_pointer_cast<DATA>(activeDataList.at(i));
102  if(retval)
103  return retval;
104  }
105  return retval;
106 }
107 
108 
109 } //cx
110 
111 #endif // CXACTIVEDATA_H
virtual QList< DataPtr > getActiveDataHistory() const
Provides the last active data of warious types.
Definition: cxActiveData.h:56
boost::shared_ptr< class Image > ImagePtr
Definition: cxDicomWidget.h:48
boost::shared_ptr< class ActiveData > ActiveDataPtr
Definition: cxColorWidget.h:42
virtual bool isNull() const
Definition: cxActiveData.h:73
boost::shared_ptr< class Data > DataPtr
virtual DataPtr getActive() const
cxLogicManager_EXPORT SessionStorageServicePtr sessionStorageService()
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
boost::shared_ptr< class PatientStorage > PatientStoragePtr
Definition: cxVBWidget.h:54
boost::shared_ptr< class SessionStorageService > SessionStorageServicePtr