CTK  0.1.0
The Common Toolkit is a community effort to provide support code for medical image analysis, surgical navigation, and related projects.
ctkXnatObject.h
Go to the documentation of this file.
1 /*=============================================================================
2 
3  Library: XNAT/Core
4 
5  Copyright (c) University College London,
6  Centre for Medical Image Computing
7 
8  Licensed under the Apache License, Version 2.0 (the "License");
9  you may not use this file except in compliance with the License.
10  You may obtain a copy of the License at
11 
12  http://www.apache.org/licenses/LICENSE-2.0
13 
14  Unless required by applicable law or agreed to in writing, software
15  distributed under the License is distributed on an "AS IS" BASIS,
16  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  See the License for the specific language governing permissions and
18  limitations under the License.
19 
20 =============================================================================*/
21 
22 #ifndef ctkXnatObject_h
23 #define ctkXnatObject_h
24 
25 #include "ctkXNATCoreExport.h"
26 
27 #include "ctkException.h"
28 
29 #include <QList>
30 #include <QObject>
31 #include <QString>
32 #include <QMetaType>
33 
34 class ctkXnatResource;
35 class ctkXnatSession;
36 class ctkXnatObjectPrivate;
37 
44 class CTK_XNAT_CORE_EXPORT ctkXnatObject
45 {
46 
47 public:
48 
50  virtual ~ctkXnatObject();
51 
53  virtual QString id() const;
54 
57  virtual void setId(const QString& id);
58 
61  virtual QString resourceUri() const = 0;
62 
64  virtual QString name() const;
65 
67  virtual void setName(const QString& name);
68 
70  QString description() const;
71 
73  void setDescription(const QString& description);
74 
76  QString property(const QString& name) const;
77 
79  void setProperty(const QString& name, const QVariant& value);
80 
82  virtual QDateTime lastModifiedTimeOnServer();
83 
85  void setLastModifiedTime(const QDateTime& lastModifiedTime);
86 
88  const QMap<QString, QString>& properties() const;
89 
93  ctkXnatObject* parent() const;
94 
96  void setParent(ctkXnatObject* parent);
97 
99  QList<ctkXnatObject*> children() const;
100 
102  void add(ctkXnatObject* child);
103 
105  void remove(ctkXnatObject* child);
106 
108  bool isFetched() const;
109 
110  QString schemaType() const;
111 
113  virtual QString childDataType() const;
114 
117  virtual void reset();
118 
120  void fetch(bool forceFetch = false);
121 
123  bool exists() const;
124 
128  void save(bool overwrite = true);
129 
131  void erase();
132 
133  void download(const QString&);
134 
142  virtual ctkXnatResource* addResourceFolder(QString foldername,
143  QString format = "", QString content = "", QString tags = "");
144 
145  //QObject* asyncObject() const;
146 
147  // *********************
148  // Add signals for async API
149  //Q_SIGNAL downloadFinished(const QString&);
150 
151  // *********************
152  // SLOTS for async error handling
153  //Q_SLOT serverError(XnatError errorType, const QString& message);
154 
155  // *********************
156  // Add blocking methods
157  // throws ctkXnatTimeoutException
158  //bool waitForDownloadFinished(const QString&);
159 
160  static const QString ID;
161  static const QString NAME;
162  static const QString LABEL;
163  static const QString URI;
164  static const QString XSI_SCHEMA_TYPE;
165 
166 protected:
167 
169 
171  ctkXnatObject(ctkXnatObject* parent = 0, const QString& schemaType = QString::null);
172 
174  ctkXnatObject(ctkXnatObjectPrivate& dd, ctkXnatObject* parent = 0, const QString& schemaType = QString::null);
175 
178  ctkXnatSession* session() const;
179 
181  virtual void fetchResources(const QString &path = "/resources");
182 
184  const QScopedPointer<ctkXnatObjectPrivate> d_ptr;
185 
186 private:
187 
188  friend class ctkXnatSessionPrivate;
189 
190  void setSchemaType(const QString& schemaType);
191 
193  virtual void fetchImpl() = 0;
194 
196  virtual void downloadImpl(const QString&) = 0;
197 
202  virtual void saveImpl(bool overwrite = true);
203 
204  Q_DECLARE_PRIVATE(ctkXnatObject)
205 };
206 
208 
209 #endif
static const QString LABEL
The ctkXnatSession class reprents a session object associated with a specific XNAT connection...
Q_DECLARE_METATYPE(ctkDICOMPersonName)
static const QString XSI_SCHEMA_TYPE
const QScopedPointer< ctkXnatObjectPrivate > d_ptr
The private implementation part of the object.
static const QString NAME
static const QString URI
static const QString ID