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