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 
94 
96  void setParent(ctkXnatObject* parent);
97 
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 
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
QList< ctkXnatObject * > children() const
Gets the children of the object.
void setParent(ctkXnatObject *parent)
Sets the parent of the object in the data hierarchy.
ctkXnatObject(const ctkXnatObject &)
QString schemaType() const
virtual QString id() const
Gets the global ID of the object.
static const QString ID
virtual QString resourceUri() const =0
void setProperty(const QString &name, const QVariant &value)
Sets the value of the property with the given name.
QString property(const QString &name) const
Gets the value of the property with the given name.
ctkXnatObject(ctkXnatObject *parent=0, const QString &schemaType=QString::null)
Constructs the ctkXnatObject.
void setLastModifiedTime(const QDateTime &lastModifiedTime)
Sets the last modfication time on the server.
ctkXnatObject(ctkXnatObjectPrivate &dd, ctkXnatObject *parent=0, const QString &schemaType=QString::null)
Constructs the ctkXnatObject with the given private part.
virtual QString childDataType() const
Gets a human readable name of the child object type.
ctkXnatObject * parent() const
void fetch(bool forceFetch=false)
Fetches the children and the properties of the object.
virtual void setName(const QString &name)
Sets the name of the object.
static const QString XSI_SCHEMA_TYPE
ctkXnatSession * session() const
void add(ctkXnatObject *child)
Adds an object to the children of the current one.
void setDescription(const QString &description)
Sets the description of the object.
virtual QString name() const
Gets the name of the object.
const QMap< QString, QString > & properties() const
Gets the properties of the object.
void remove(ctkXnatObject *child)
Removes the object from the children of the current object.
void download(const QString &)
virtual void fetchResources(const QString &path="/resources")
Fetches the resources of the object.
virtual QDateTime lastModifiedTimeOnServer()
Gets the last modification time from the server.
static const QString NAME
static const QString LABEL
virtual void reset()
bool isFetched() const
Tells if the children and the properties of the objects have been fetched.
bool exists() const
Checks if the object exists on the XNAT server.
void save(bool overwrite=true)
virtual ctkXnatResource * addResourceFolder(QString foldername, QString format="", QString content="", QString tags="")
static const QString URI
virtual ~ctkXnatObject()
Destructs the ctkXnatObject.
void erase()
Deletes the object on the XNAT server and removes it from its parent.
virtual void setId(const QString &id)
QString description() const
Gets the description of the object.
const QScopedPointer< ctkXnatObjectPrivate > d_ptr
The private implementation part of the object.
The ctkXnatSession class reprents a session object associated with a specific XNAT connection.
Q_DECLARE_METATYPE(ctkDICOMPersonName)