comparison OrthancFramework/Sources/HttpServer/IWebDavBucket.h @ 4226:7bd5eab3ba25

prototyping IWebDavBucket
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sun, 04 Oct 2020 13:23:53 +0200
parents
children 7fff7e683d65
comparison
equal deleted inserted replaced
4225:81f2d1484886 4226:7bd5eab3ba25
1 /**
2 * Orthanc - A Lightweight, RESTful DICOM Store
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
4 * Department, University Hospital of Liege, Belgium
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium
6 *
7 * This program is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public License
9 * as published by the Free Software Foundation, either version 3 of
10 * the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this program. If not, see
19 * <http://www.gnu.org/licenses/>.
20 **/
21
22
23 #pragma once
24
25 #if !defined(ORTHANC_ENABLE_PUGIXML)
26 # error The macro ORTHANC_ENABLE_PUGIXML must be defined
27 #endif
28
29 #if ORTHANC_ENABLE_PUGIXML != 1
30 # error XML support is required to use this file
31 #endif
32
33 #include "../Compatibility.h"
34 #include "../Enumerations.h"
35
36 #include <boost/date_time/posix_time/posix_time.hpp>
37 #include <boost/noncopyable.hpp>
38 #include <pugixml.hpp>
39
40 #include <list>
41
42 namespace Orthanc
43 {
44 class IWebDavBucket : public boost::noncopyable
45 {
46 public:
47 class Resource : public boost::noncopyable
48 {
49 private:
50 std::string name_;
51 bool hasModificationTime_;
52 boost::posix_time::ptime creationTime_;
53 boost::posix_time::ptime modificationTime_;
54
55 protected:
56 void SetNameInternal(const std::string& name);
57
58 public:
59 Resource();
60
61 virtual ~Resource()
62 {
63 }
64
65 void SetCreationTime(const boost::posix_time::ptime& t);
66
67 void SetModificationTime(const boost::posix_time::ptime& t);
68
69 const std::string& GetName() const
70 {
71 return name_;
72 }
73
74 const boost::posix_time::ptime& GetCreationTime() const
75 {
76 return creationTime_;
77 }
78
79 const boost::posix_time::ptime& GetModificationTime() const
80 {
81 return modificationTime_;
82 }
83
84 virtual void Format(pugi::xml_node& node,
85 const std::string& parentPath) const;
86 };
87
88
89 class File : public Resource
90 {
91 private:
92 uint64_t contentLength_;
93 MimeType mime_;
94
95 public:
96 File(const std::string& name);
97
98 void SetContentLength(uint64_t contentLength)
99 {
100 contentLength_ = contentLength;
101 }
102
103 void SetMimeType(MimeType mime)
104 {
105 mime_ = mime;
106 }
107
108 uint64_t GetContentLength() const
109 {
110 return contentLength_;
111 }
112
113 MimeType GetMimeType() const
114 {
115 return mime_;
116 }
117
118 virtual void Format(pugi::xml_node& node,
119 const std::string& parentPath) const ORTHANC_OVERRIDE;
120 };
121
122
123 class Folder : public Resource
124 {
125 public:
126 Folder(const std::string& name)
127 {
128 SetNameInternal(name);
129 }
130
131 virtual void Format(pugi::xml_node& node,
132 const std::string& parentPath) const ORTHANC_OVERRIDE;
133 };
134
135
136 class Collection : public boost::noncopyable
137 {
138 private:
139 std::list<Resource*> resources_;
140
141 public:
142 ~Collection();
143
144 void AddResource(Resource* resource); // Takes ownership
145
146 void Format(std::string& target,
147 const std::string& parentPath) const;
148 };
149
150
151 virtual ~IWebDavBucket()
152 {
153 }
154
155 virtual bool ListCollection(Collection& collection,
156 const std::vector<std::string>& path) = 0;
157
158 virtual bool GetFileContent(std::string& content,
159 const std::vector<std::string>& path) = 0;
160 };
161 }