diff --git a/doxygen/_azure_image_layer_8h_source.html b/doxygen/_azure_image_layer_8h_source.html index 3d06dc27..46039dc5 100644 --- a/doxygen/_azure_image_layer_8h_source.html +++ b/doxygen/_azure_image_layer_8h_source.html @@ -85,7 +85,7 @@
19  {
20  public:
22  AzureImageLayer();
-
23  AzureImageLayer(const JSON&);
+
23  AzureImageLayer(const std::string& JSON, const IOOptions& io);
24 
26  virtual ~AzureImageLayer() { }
27 
@@ -101,7 +101,7 @@
39 
40  private:
41 
-
42  void construct(const JSON&);
+
42  void construct(const std::string& JSON, const IOOptions& io);
43  };
44 }
45 
diff --git a/doxygen/_bing_elevation_layer_8h_source.html b/doxygen/_bing_elevation_layer_8h_source.html index aafc65c7..614b559b 100644 --- a/doxygen/_bing_elevation_layer_8h_source.html +++ b/doxygen/_bing_elevation_layer_8h_source.html @@ -87,7 +87,7 @@
21  {
22  public:
24  BingElevationLayer();
-
25  BingElevationLayer(const JSON&);
+
25  BingElevationLayer(const std::string& JSON, const IOOptions& io);
26 
28  virtual ~BingElevationLayer() { }
29 
@@ -105,7 +105,7 @@
43 
44 
45  private:
-
46  void construct(const JSON&);
+
46  void construct(const std::string& JSON, const IOOptions& io);
47  };
48 }
49 
diff --git a/doxygen/_bing_image_layer_8h_source.html b/doxygen/_bing_image_layer_8h_source.html index d7bc9050..62f111bf 100644 --- a/doxygen/_bing_image_layer_8h_source.html +++ b/doxygen/_bing_image_layer_8h_source.html @@ -86,7 +86,7 @@
20  {
21  public:
23  BingImageLayer();
-
24  BingImageLayer(const JSON&);
+
24  BingImageLayer(const std::string& JSON, const IOOptions& io);
25 
27  virtual ~BingImageLayer() { }
28 
@@ -106,7 +106,7 @@
44 
45  private:
46 
-
47  void construct(const JSON&);
+
47  void construct(const std::string& JSON, const IOOptions& io);
48  };
49 }
50 
diff --git a/doxygen/_elevation_layer_8h_source.html b/doxygen/_elevation_layer_8h_source.html index b3e46200..c8e2602c 100644 --- a/doxygen/_elevation_layer_8h_source.html +++ b/doxygen/_elevation_layer_8h_source.html @@ -125,7 +125,7 @@
85 
87  ElevationLayer();
88 
-
90  explicit ElevationLayer(const JSON&);
+
90  explicit ElevationLayer(const std::string& JSON, const IOOptions& io);
91 
93  Result<GeoHeightfield> createHeightfieldInKeyProfile(
94  const TileKey& key,
@@ -154,7 +154,7 @@
121  optional<float> _maxValidValue = FLT_MAX;
122 
123  private:
-
124  void construct(const JSON&);
+
124  void construct(const std::string& JSON, const IOOptions& io);
125 
126  shared_ptr<Heightfield> assembleHeightfield(
127  const TileKey& key,
diff --git a/doxygen/_g_d_a_l_elevation_layer_8h_source.html b/doxygen/_g_d_a_l_elevation_layer_8h_source.html index e51d2951..97eb449a 100644 --- a/doxygen/_g_d_a_l_elevation_layer_8h_source.html +++ b/doxygen/_g_d_a_l_elevation_layer_8h_source.html @@ -86,9 +86,9 @@
20  public:
22  GDALElevationLayer();
23 
-
25  GDALElevationLayer(const JSON&);
+
25  GDALElevationLayer(const std::string& JSON, const IOOptions& io);
26 
-
28  JSON to_json() const override;
+
28  std::string to_json() const override;
29 
30  protected:
31 
@@ -102,7 +102,7 @@
42 
43  private:
44 
-
46  void construct(const JSON&);
+
46  void construct(const std::string& JSON, const IOOptions& io);
47 
48  mutable util::ThreadLocal<shared_ptr<GDAL::Driver>> _drivers;
49  friend class GDAL::Driver;
diff --git a/doxygen/_g_d_a_l_image_layer_8h_source.html b/doxygen/_g_d_a_l_image_layer_8h_source.html index 02410900..610f9982 100644 --- a/doxygen/_g_d_a_l_image_layer_8h_source.html +++ b/doxygen/_g_d_a_l_image_layer_8h_source.html @@ -86,9 +86,9 @@
20  public:
22  GDALImageLayer();
23 
-
25  GDALImageLayer(const JSON&);
+
25  GDALImageLayer(const std::string& JSON, const IOOptions& io);
26 
-
28  JSON to_json() const override;
+
28  std::string to_json() const override;
29 
30  protected: // Layer
31 
@@ -102,7 +102,7 @@
42 
43  private:
44 
-
46  void construct(const JSON&);
+
46  void construct(const std::string& JSON, const IOOptions& io);
47 
48  mutable util::ThreadLocal<shared_ptr<GDAL::Driver>> _drivers;
49  friend class GDAL::Driver;
diff --git a/doxygen/_i_o_types_8h_source.html b/doxygen/_i_o_types_8h_source.html index 00e47f32..7e018f0a 100644 --- a/doxygen/_i_o_types_8h_source.html +++ b/doxygen/_i_o_types_8h_source.html @@ -80,258 +80,262 @@
11 #include <rocky/Units.h>
12 #include <rocky/Threading.h>
13 #include <rocky/LRUCache.h>
-
14 
-
18 namespace ROCKY_NAMESPACE
-
19 {
-
20  class IOOptions;
-
21  class Image;
-
22  class Layer;
-
23 
-
25  class Cache : public Inherit<Object, Cache>
-
26  {
-
27  };
-
28 
-
30  using ReadImageURIService = std::function<
-
31  Result<shared_ptr<Image>>(const std::string& location, const IOOptions&)>;
-
32 
-
33  using ReadImageStreamService = std::function<
-
34  Result<shared_ptr<Image>>(std::istream& stream, std::string contentType, const IOOptions& io)>;
-
35 
-
36  using WriteImageStreamService = std::function<
-
37  Status(shared_ptr<Image> image, std::ostream& stream, std::string contentType, const IOOptions& io)>;
-
38 
-
40  using CacheImpl = void*; // todo.
-
41  using CacheService = std::function<shared_ptr<CacheImpl>()>;
-
42 
-
44  class DataInterface {
-
45  public:
-
46  virtual shared_ptr<Layer> findLayerByName(const std::string& name) const = 0;
-
47  };
-
48  using DataService = std::function<DataInterface&()>;
-
49 
-
50  struct Content {
-
51  std::string contentType;
-
52  std::string data;
-
53  };
-
54 
-
55  using ContentCache = rocky::util::LRUCache<std::string, Result<Content>>;
-
56 
-
57  class ROCKY_EXPORT Services
-
58  {
-
59  public:
-
60  Services();
-
61  ReadImageURIService readImageFromURI;
-
62  ReadImageStreamService readImageFromStream;
-
63  WriteImageStreamService writeImageToStream;
-
64  CacheService cache;
-
65  shared_ptr<ContentCache> contentCache = std::make_shared<ContentCache>(128);
-
66  std::shared_ptr<util::Gate<std::string>> uriGate = std::make_shared<util::Gate<std::string>>();
-
67  };
-
68 
-
69  // User options passed along with an IO context.
-
70  class ROCKY_EXPORT IOOptions : public Cancelable
-
71  {
-
72  public:
-
73  IOOptions();
-
74  IOOptions(const IOOptions& rhs);
-
75  IOOptions(Cancelable& p);
-
76  IOOptions(const IOOptions& rhs, Cancelable& p);
-
77 
-
79  Services services;
-
80 
-
82  inline std::string property(const std::string& name) const;
-
83  inline std::string& property(const std::string& name);
+
14 #include <optional>
+
15 
+
19 namespace ROCKY_NAMESPACE
+
20 {
+
21  class IOOptions;
+
22  class Image;
+
23  class Layer;
+
24 
+
26  class Cache : public Inherit<Object, Cache>
+
27  {
+
28  };
+
29 
+
31  using ReadImageURIService = std::function<
+
32  Result<shared_ptr<Image>>(const std::string& location, const IOOptions&)>;
+
33 
+
35  using ReadImageStreamService = std::function<
+
36  Result<shared_ptr<Image>>(std::istream& stream, std::string contentType, const IOOptions& io)>;
+
37 
+
39  using WriteImageStreamService = std::function<
+
40  Status(shared_ptr<Image> image, std::ostream& stream, std::string contentType, const IOOptions& io)>;
+
41 
+
43  using CacheImpl = void*; // todo.
+
44  using CacheService = std::function<shared_ptr<CacheImpl>()>;
+
45 
+
47  class DataInterface {
+
48  public:
+
49  virtual shared_ptr<Layer> findLayerByName(const std::string& name) const = 0;
+
50  };
+
51  using DataService = std::function<DataInterface&()>;
+
52 
+
53  struct Content {
+
54  std::string contentType;
+
55  std::string data;
+
56  };
+
57 
+
58  using ContentCache = rocky::util::LRUCache<std::string, Result<Content>>;
+
59 
+
60  class ROCKY_EXPORT Services
+
61  {
+
62  public:
+
63  Services();
+
64  ReadImageURIService readImageFromURI;
+
65  ReadImageStreamService readImageFromStream;
+
66  WriteImageStreamService writeImageToStream;
+
67  CacheService cache;
+
68  shared_ptr<ContentCache> contentCache = std::make_shared<ContentCache>(128);
+
69  std::shared_ptr<util::Gate<std::string>> uriGate = std::make_shared<util::Gate<std::string>>();
+
70  };
+
71 
+
72  // User options passed along with an IO context.
+
73  class ROCKY_EXPORT IOOptions : public Cancelable
+
74  {
+
75  public:
+
76  IOOptions() = default;
+
77  IOOptions(const IOOptions& rhs);
+
78  IOOptions(Cancelable& p);
+
79  IOOptions(const IOOptions& rhs, Cancelable& p);
+
80  IOOptions(const std::string& referrer);
+
81 
+
83  Services services;
84 
-
86  unsigned maxNetworkAttempts = 4u;
-
87 
-
89  inline bool canceled() const override;
-
90 
-
91  public:
-
92  IOOptions& operator = (const IOOptions& rhs);
-
93 
-
94  private:
-
95  Cancelable* _cancelable;
-
96  std::unordered_map<std::string, std::string> _properties;
-
97  };
-
98 
-
99 
-
100  class ROCKY_EXPORT CachePolicy
-
101  {
-
102  public:
-
103  enum class Usage
-
104  {
-
105  READ_WRITE = 0, // read/write to the cache if one exists.
-
106  CACHE_ONLY = 1, // treat the cache as the ONLY source of data.
-
107  READ_ONLY = 2, // read from the cache, but don't write new data to it.
-
108  NO_CACHE = 3 // neither read from or write to the cache
-
109  };
-
110 
-
111  optional<Usage> usage = Usage::READ_WRITE;
-
112  optional<Duration> maxAge = Duration(DBL_MAX, Units::SECONDS);
-
113  optional<DateTime> minTime = DateTime(0);
-
114 
-
116  static CachePolicy DEFAULT;
+
86  inline std::string property(const std::string& name) const;
+
87  inline std::string& property(const std::string& name);
+
88 
+
90  unsigned maxNetworkAttempts = 4u;
+
91 
+
93  std::optional<std::string> referrer;
+
94 
+
96  inline bool canceled() const override;
+
97 
+
98  public:
+
99  IOOptions& operator = (const IOOptions& rhs);
+
100 
+
101  private:
+
102  Cancelable* _cancelable = nullptr;
+
103  std::unordered_map<std::string, std::string> _properties;
+
104  };
+
105 
+
106 
+
107  class ROCKY_EXPORT CachePolicy
+
108  {
+
109  public:
+
110  enum class Usage
+
111  {
+
112  READ_WRITE = 0, // read/write to the cache if one exists.
+
113  CACHE_ONLY = 1, // treat the cache as the ONLY source of data.
+
114  READ_ONLY = 2, // read from the cache, but don't write new data to it.
+
115  NO_CACHE = 3 // neither read from or write to the cache
+
116  };
117 
-
119  static CachePolicy NO_CACHE;
-
120 
-
122  static CachePolicy CACHE_ONLY;
-
123 
-
124  public:
-
126  CachePolicy();
+
118  optional<Usage> usage = Usage::READ_WRITE;
+
119  optional<Duration> maxAge = Duration(DBL_MAX, Units::SECONDS);
+
120  optional<DateTime> minTime = DateTime(0);
+
121 
+
123  static CachePolicy DEFAULT;
+
124 
+
126  static CachePolicy NO_CACHE;
127 
-
129  CachePolicy(const Usage&);
+
129  static CachePolicy CACHE_ONLY;
130 
-
132  //CachePolicy(const JSON& conf);
-
133 
-
135  void mergeAndOverride(const CachePolicy& rhs);
-
136  void mergeAndOverride(const optional<CachePolicy>& rhs);
+
131  public:
+
133  CachePolicy();
+
134 
+
136  CachePolicy(const Usage&);
137 
-
139  DateTime getMinAcceptTime() const;
+
139  //CachePolicy(const JSON& conf);
140 
-
142  bool isExpired(TimeStamp lastModified) const;
-
143 
-
144  public: // convenience functions.
-
145 
-
146  bool isCacheEnabled() const {
-
147  return isCacheReadable() || isCacheWriteable();
-
148  }
-
149 
-
150  bool isCacheDisabled() const {
-
151  return !isCacheEnabled();
-
152  }
-
153 
-
154  bool isCacheReadable() const {
-
155  return
-
156  usage.value() == Usage::READ_WRITE ||
-
157  usage.value() == Usage::CACHE_ONLY ||
-
158  usage.value() == Usage::READ_ONLY;
+
142  void mergeAndOverride(const CachePolicy& rhs);
+
143  void mergeAndOverride(const optional<CachePolicy>& rhs);
+
144 
+
146  DateTime getMinAcceptTime() const;
+
147 
+
149  bool isExpired(TimeStamp lastModified) const;
+
150 
+
151  public: // convenience functions.
+
152 
+
153  bool isCacheEnabled() const {
+
154  return isCacheReadable() || isCacheWriteable();
+
155  }
+
156 
+
157  bool isCacheDisabled() const {
+
158  return !isCacheEnabled();
159  }
160 
-
161  bool isCacheWriteable() const {
-
162  return usage.value() == Usage::READ_WRITE;
-
163  }
-
164 
-
165  bool isCacheOnly() const {
-
166  return usage.value() == Usage::CACHE_ONLY;
-
167  }
-
168 
-
169  bool operator == (const CachePolicy& rhs) const;
-
170 
-
171  bool operator != (const CachePolicy& rhs) const {
-
172  return !operator==(rhs);
-
173  }
-
174 
-
175  CachePolicy& operator = (const CachePolicy& rhs);
-
176 
-
177  // returns a readable string describing usage
-
178  std::string usageString() const;
-
179  };
-
180 
-
184  class ROCKY_EXPORT ProxySettings
-
185  {
-
186  public:
-
187  std::string hostname;
-
188  int port = -1;
-
189  std::string username;
-
190  std::string password;
-
191  };
-
192 
-
193  using Headers = std::unordered_map<std::string,std::string>;
-
194 
-
198  struct ROCKY_EXPORT IOMetadata
-
199  {
-
200  static const std::string CONTENT_TYPE;
-
201  };
-
202 
-
206  template<typename T>
-
207  struct IOResult : public Result<T>
-
208  {
-
210  enum IOCode
-
211  {
-
212  RESULT_OK,
-
213  RESULT_CANCELED,
-
214  RESULT_NOT_FOUND,
-
215  RESULT_EXPIRED,
-
216  RESULT_SERVER_ERROR,
-
217  RESULT_TIMEOUT,
-
218  RESULT_NO_READER,
-
219  RESULT_READER_ERROR,
-
220  RESULT_UNKNOWN_ERROR,
-
221  RESULT_NOT_IMPLEMENTED,
-
222  RESULT_NOT_MODIFIED
-
223  };
-
224 
-
225  unsigned ioCode = RESULT_OK;
-
226  TimeStamp lastModifiedTime = 0;
-
227  Duration duration;
-
228  bool fromCache = false;
-
229  JSON metadata;
-
230 
-
231  IOResult(const T& result) :
-
232  Result<T>(result) { }
-
233 
-
235  IOResult(const Status& s) :
-
236  Result<T>(s),
-
237  ioCode(s.ok() ? RESULT_OK : RESULT_NOT_FOUND) { }
+
161  bool isCacheReadable() const {
+
162  return
+
163  usage.value() == Usage::READ_WRITE ||
+
164  usage.value() == Usage::CACHE_ONLY ||
+
165  usage.value() == Usage::READ_ONLY;
+
166  }
+
167 
+
168  bool isCacheWriteable() const {
+
169  return usage.value() == Usage::READ_WRITE;
+
170  }
+
171 
+
172  bool isCacheOnly() const {
+
173  return usage.value() == Usage::CACHE_ONLY;
+
174  }
+
175 
+
176  bool operator == (const CachePolicy& rhs) const;
+
177 
+
178  bool operator != (const CachePolicy& rhs) const {
+
179  return !operator==(rhs);
+
180  }
+
181 
+
182  CachePolicy& operator = (const CachePolicy& rhs);
+
183 
+
184  // returns a readable string describing usage
+
185  std::string usageString() const;
+
186  };
+
187 
+
191  class ROCKY_EXPORT ProxySettings
+
192  {
+
193  public:
+
194  std::string hostname;
+
195  int port = -1;
+
196  std::string username;
+
197  std::string password;
+
198  };
+
199 
+
203  struct ROCKY_EXPORT IOMetadata
+
204  {
+
205  static const std::string CONTENT_TYPE;
+
206  };
+
207 
+
211  template<typename T>
+
212  struct IOResult : public Result<T>
+
213  {
+
215  enum IOCode
+
216  {
+
217  RESULT_OK,
+
218  RESULT_CANCELED,
+
219  RESULT_NOT_FOUND,
+
220  RESULT_EXPIRED,
+
221  RESULT_SERVER_ERROR,
+
222  RESULT_TIMEOUT,
+
223  RESULT_NO_READER,
+
224  RESULT_READER_ERROR,
+
225  RESULT_UNKNOWN_ERROR,
+
226  RESULT_NOT_IMPLEMENTED,
+
227  RESULT_NOT_MODIFIED
+
228  };
+
229 
+
230  unsigned ioCode = RESULT_OK;
+
231  TimeStamp lastModifiedTime = 0;
+
232  Duration duration;
+
233  bool fromCache = false;
+
234  JSON metadata;
+
235 
+
236  IOResult(const T& result) :
+
237  Result<T>(result) { }
238 
-
239  template<typename RHS>
-
240  static IOResult<T> propagate(const IOResult<RHS>& rhs) {
-
241  IOResult<T> lhs(rhs.status);
-
242  lhs.ioCode = rhs.ioCode;
-
243  lhs.metadata = rhs.metadata;
-
244  lhs.fromCache = rhs.fromCache;
-
245  lhs.lastModifiedTime = rhs.lastModifiedTime;
-
246  lhs.duration = rhs.duration;
-
247  return lhs;
-
248  }
-
249 
-
251  static std::string getResultCodeString(unsigned code)
-
252  {
-
253  return
-
254  code == RESULT_OK ? "OK" :
-
255  code == RESULT_CANCELED ? "Read canceled" :
-
256  code == RESULT_NOT_FOUND ? "Target not found" :
-
257  code == RESULT_SERVER_ERROR ? "Server reported error" :
-
258  code == RESULT_TIMEOUT ? "Read timed out" :
-
259  code == RESULT_NO_READER ? "No suitable ReaderWriter found" :
-
260  code == RESULT_READER_ERROR ? "ReaderWriter error" :
-
261  code == RESULT_NOT_IMPLEMENTED ? "Not implemented" :
-
262  code == RESULT_NOT_MODIFIED ? "Not modified" :
-
263  "Unknown error";
-
264  }
-
265 
-
266  std::string getResultCodeString() const
-
267  {
-
268  return getResultCodeString(ioCode);
+
240  IOResult(const Status& s) :
+
241  Result<T>(s),
+
242  ioCode(s.ok() ? RESULT_OK : RESULT_NOT_FOUND) { }
+
243 
+
244  template<typename RHS>
+
245  static IOResult<T> propagate(const IOResult<RHS>& rhs) {
+
246  IOResult<T> lhs(rhs.status);
+
247  lhs.ioCode = rhs.ioCode;
+
248  lhs.metadata = rhs.metadata;
+
249  lhs.fromCache = rhs.fromCache;
+
250  lhs.lastModifiedTime = rhs.lastModifiedTime;
+
251  lhs.duration = rhs.duration;
+
252  return lhs;
+
253  }
+
254 
+
256  static std::string getResultCodeString(unsigned code)
+
257  {
+
258  return
+
259  code == RESULT_OK ? "OK" :
+
260  code == RESULT_CANCELED ? "Read canceled" :
+
261  code == RESULT_NOT_FOUND ? "Target not found" :
+
262  code == RESULT_SERVER_ERROR ? "Server reported error" :
+
263  code == RESULT_TIMEOUT ? "Read timed out" :
+
264  code == RESULT_NO_READER ? "No suitable ReaderWriter found" :
+
265  code == RESULT_READER_ERROR ? "ReaderWriter error" :
+
266  code == RESULT_NOT_IMPLEMENTED ? "Not implemented" :
+
267  code == RESULT_NOT_MODIFIED ? "Not modified" :
+
268  "Unknown error";
269  }
-
270  };
-
271 
-
272  std::string IOOptions::property(const std::string& name) const {
-
273  auto i = _properties.find(name);
-
274  return i != _properties.end() ? i->second : "";
-
275  }
+
270 
+
271  std::string getResultCodeString() const
+
272  {
+
273  return getResultCodeString(ioCode);
+
274  }
+
275  };
276 
-
277  std::string& IOOptions::property(const std::string& name) {
-
278  return _properties[name];
-
279  }
-
280 
-
281  bool IOOptions::canceled() const {
-
282  return _cancelable ? _cancelable->canceled() : false;
-
283  }
-
284 }
-
ROCKY_NAMESPACE::Cache
Base class for a cache.
Definition: IOTypes.h:26
-
ROCKY_NAMESPACE::DataInterface
Service for accessing other data.
Definition: IOTypes.h:44
-
ROCKY_NAMESPACE::ProxySettings
Definition: IOTypes.h:185
+
277  std::string IOOptions::property(const std::string& name) const {
+
278  auto i = _properties.find(name);
+
279  return i != _properties.end() ? i->second : "";
+
280  }
+
281 
+
282  std::string& IOOptions::property(const std::string& name) {
+
283  return _properties[name];
+
284  }
+
285 
+
286  bool IOOptions::canceled() const {
+
287  return _cancelable ? _cancelable->canceled() : false;
+
288  }
+
289 }
+
ROCKY_NAMESPACE::Cache
Base class for a cache.
Definition: IOTypes.h:27
+
ROCKY_NAMESPACE::DataInterface
Service for accessing other data.
Definition: IOTypes.h:47
+
ROCKY_NAMESPACE::ProxySettings
Definition: IOTypes.h:192
ROCKY_NAMESPACE
Definition: Callbacks.h:16
-
ROCKY_NAMESPACE::ReadImageURIService
std::function< Result< shared_ptr< Image > >(const std::string &location, const IOOptions &)> ReadImageURIService
Service for reading an image from a URL.
Definition: IOTypes.h:31
+
ROCKY_NAMESPACE::ReadImageURIService
std::function< Result< shared_ptr< Image > >(const std::string &location, const IOOptions &)> ReadImageURIService
Service for reading an image from a URI.
Definition: IOTypes.h:32
+
ROCKY_NAMESPACE::WriteImageStreamService
std::function< Status(shared_ptr< Image > image, std::ostream &stream, std::string contentType, const IOOptions &io)> WriteImageStreamService
Service for writing an image to a stream.
Definition: IOTypes.h:40
ROCKY_NAMESPACE::JSON
std::string JSON
json serialization type
Definition: Common.h:48
-
ROCKY_NAMESPACE::CacheImpl
void * CacheImpl
Service for caching data.
Definition: IOTypes.h:40
+
ROCKY_NAMESPACE::CacheImpl
void * CacheImpl
Service for caching data.
Definition: IOTypes.h:43
+
ROCKY_NAMESPACE::ReadImageStreamService
std::function< Result< shared_ptr< Image > >(std::istream &stream, std::string contentType, const IOOptions &io)> ReadImageStreamService
Service fro reading an image from a stream.
Definition: IOTypes.h:36
ROCKY_NAMESPACE::TimeStamp
::time_t TimeStamp
Definition: DateTime.h:17
-
ROCKY_NAMESPACE::IOMetadata
Definition: IOTypes.h:199
-
ROCKY_NAMESPACE::IOResult
Definition: IOTypes.h:208
-
ROCKY_NAMESPACE::IOResult::getResultCodeString
static std::string getResultCodeString(unsigned code)
Definition: IOTypes.h:251
-
ROCKY_NAMESPACE::IOResult::IOResult
IOResult(const Status &s)
Definition: IOTypes.h:235
-
ROCKY_NAMESPACE::IOResult::IOCode
IOCode
Definition: IOTypes.h:211
+
ROCKY_NAMESPACE::IOMetadata
Definition: IOTypes.h:204
+
ROCKY_NAMESPACE::IOResult
Definition: IOTypes.h:213
+
ROCKY_NAMESPACE::IOResult::getResultCodeString
static std::string getResultCodeString(unsigned code)
Definition: IOTypes.h:256
+
ROCKY_NAMESPACE::IOResult::IOResult
IOResult(const Status &s)
Definition: IOTypes.h:240
+
ROCKY_NAMESPACE::IOResult::IOCode
IOCode
Definition: IOTypes.h:216
ROCKY_NAMESPACE::Result
Definition: Status.h:66
ROCKY_NAMESPACE::Status
Definition: Status.h:24
diff --git a/doxygen/_image_layer_8h_source.html b/doxygen/_image_layer_8h_source.html index 08f9d2c8..d8107eba 100644 --- a/doxygen/_image_layer_8h_source.html +++ b/doxygen/_image_layer_8h_source.html @@ -121,7 +121,7 @@
68 
69  ImageLayer();
70 
-
71  ImageLayer(const JSON&);
+
71  ImageLayer(const std::string& JSON, const IOOptions& io);
72 
74  virtual Status writeImageImplementation(
75  const TileKey& key,
@@ -160,7 +160,7 @@
113 
114  private:
115 
-
116  void construct(const JSON&);
+
116  void construct(const std::string& JSON, const IOOptions& io);
117 
118  // Creates an image that's in the same profile as the provided key.
119  Result<GeoImage> createImageInKeyProfile(
diff --git a/doxygen/_instance_8h_source.html b/doxygen/_instance_8h_source.html index 47b1a333..08ee829d 100644 --- a/doxygen/_instance_8h_source.html +++ b/doxygen/_instance_8h_source.html @@ -99,47 +99,46 @@
36  public: // Object factory functions
37 
41  using ObjectFactory = std::function<
-
42  shared_ptr<Object>(
-
43  const std::string& JSON)>;
-
44 
-
46  template<class T>
-
47  static shared_ptr<T> createObject(const std::string& name, const JSON& conf) {
-
48  return std::dynamic_pointer_cast<T>(createObjectImpl(name, conf));
-
49  }
-
50 
-
53  static std::unordered_map<std::string, ObjectFactory>& objectFactories();
-
54 
-
56  static std::set<std::string>& about();
-
57 
-
58  private:
-
59  struct Implementation
-
60  {
-
61  CachePolicy cachePolicy;
-
62  IOOptions ioOptions;
-
63  };
-
64  shared_ptr<Implementation> _impl;
-
65  static Status _global_status;
-
66  static shared_ptr<Object> createObjectImpl(const std::string& name, const JSON& conf);
-
67  };
+
42  shared_ptr<Object>(const std::string& JSON, const IOOptions& io)>;
+
43 
+
45  template<class T>
+
46  static shared_ptr<T> createObject(const std::string& name, const std::string& JSON, const IOOptions& io) {
+
47  return std::dynamic_pointer_cast<T>(createObjectImpl(name, JSON, io));
+
48  }
+
49 
+
52  static std::unordered_map<std::string, ObjectFactory>& objectFactories();
+
53 
+
55  static std::set<std::string>& about();
+
56 
+
57  private:
+
58  struct Implementation
+
59  {
+
60  CachePolicy cachePolicy;
+
61  IOOptions ioOptions;
+
62  };
+
63  shared_ptr<Implementation> _impl;
+
64  static Status _global_status;
+
65  static shared_ptr<Object> createObjectImpl(const std::string& name, const std::string& JSON, const IOOptions& io);
+
66  };
+
67 
68 
-
69 
-
70  // inlines ...
-
71 
-
72  CachePolicy& Instance::cachePolicy() {
-
73  return _impl->cachePolicy;
-
74  }
-
75  IOOptions& Instance::ioOptions() {
-
76  return _impl->ioOptions;
-
77  }
-
78 
-
79  // macro to install an object factory at startup time from a .cpp file.
-
80  #define ROCKY_ADD_OBJECT_FACTORY(NAME, FUNC) \
-
81  struct __ROCKY_OBJECTFACTORY_##NAME##_INSTALLER { \
-
82  __ROCKY_OBJECTFACTORY_##NAME##_INSTALLER () { \
-
83  ROCKY_NAMESPACE::Instance::objectFactories()[util::toLower(#NAME)] = FUNC; \
-
84  } }; \
-
85  __ROCKY_OBJECTFACTORY_##NAME##_INSTALLER __rocky_objectFactory_##NAME ;
-
86 }
+
69  // inlines ...
+
70 
+
71  CachePolicy& Instance::cachePolicy() {
+
72  return _impl->cachePolicy;
+
73  }
+
74  IOOptions& Instance::ioOptions() {
+
75  return _impl->ioOptions;
+
76  }
+
77 
+
78  // macro to install an object factory at startup time from a .cpp file.
+
79  #define ROCKY_ADD_OBJECT_FACTORY(NAME, FUNC) \
+
80  struct __ROCKY_OBJECTFACTORY_##NAME##_INSTALLER { \
+
81  __ROCKY_OBJECTFACTORY_##NAME##_INSTALLER () { \
+
82  ROCKY_NAMESPACE::Instance::objectFactories()[util::toLower(#NAME)] = FUNC; \
+
83  } }; \
+
84  __ROCKY_OBJECTFACTORY_##NAME##_INSTALLER __rocky_objectFactory_##NAME ;
+
85 }
ROCKY_NAMESPACE
Definition: Callbacks.h:16
ROCKY_NAMESPACE::JSON
std::string JSON
json serialization type
Definition: Common.h:48
diff --git a/doxygen/_m_b_tiles_elevation_layer_8h_source.html b/doxygen/_m_b_tiles_elevation_layer_8h_source.html index 7cc06738..bc1726a1 100644 --- a/doxygen/_m_b_tiles_elevation_layer_8h_source.html +++ b/doxygen/_m_b_tiles_elevation_layer_8h_source.html @@ -84,7 +84,7 @@
21  {
22  public:
24  MBTilesElevationLayer();
-
25  explicit MBTilesElevationLayer(const JSON&);
+
25  explicit MBTilesElevationLayer(const std::string& JSON, const IOOptions& io);
26 
28  void setURI(const URI& value) { _options.uri = value; }
29  optional<URI>& uri() { return _options.uri; }
@@ -111,7 +111,7 @@
57  private:
58  MBTiles::Driver _driver;
59  MBTiles::Options _options;
-
60  void construct(const JSON&);
+
60  void construct(const std::string& JSON, const IOOptions& io);
61  };
62 }
63 
diff --git a/doxygen/_m_b_tiles_image_layer_8h_source.html b/doxygen/_m_b_tiles_image_layer_8h_source.html index 88fc651c..9d32c22a 100644 --- a/doxygen/_m_b_tiles_image_layer_8h_source.html +++ b/doxygen/_m_b_tiles_image_layer_8h_source.html @@ -84,7 +84,7 @@
21  {
22  public:
24  MBTilesImageLayer();
-
25  explicit MBTilesImageLayer(const JSON& conf);
+
25  explicit MBTilesImageLayer(const std::string& JSON, const IOOptions& io);
26 
28  void setURI(const URI& value) { _options.uri = value; }
29  optional<URI>& uri() { return _options.uri; }
@@ -111,7 +111,7 @@
57  MBTiles::Driver _driver;
58  MBTiles::Options _options;
59 
-
60  void construct(const JSON&);
+
60  void construct(const std::string& JSON, const IOOptions& io);
61  };
62 }
63 
diff --git a/doxygen/_map_8h_source.html b/doxygen/_map_8h_source.html index 1ccf9644..b102e741 100644 --- a/doxygen/_map_8h_source.html +++ b/doxygen/_map_8h_source.html @@ -110,7 +110,7 @@
55  Instance& instance() { return _instance; }
56  const Instance& instance() const { return _instance; }
57 
-
60  Status from_json(const JSON& value);
+
60  Status from_json(const JSON& value, const IOOptions& io);
61 
62  public:
63 
diff --git a/doxygen/_t_m_s_elevation_layer_8h_source.html b/doxygen/_t_m_s_elevation_layer_8h_source.html index 74b2cabe..8dabedd6 100644 --- a/doxygen/_t_m_s_elevation_layer_8h_source.html +++ b/doxygen/_t_m_s_elevation_layer_8h_source.html @@ -87,7 +87,7 @@
21  {
22  public:
24  TMSElevationLayer();
-
25  TMSElevationLayer(const JSON&);
+
25  TMSElevationLayer(const std::string& JSON, const IOOptions& io);
26 
28  virtual ~TMSElevationLayer() { }
29 
@@ -114,7 +114,7 @@
54 
55  private:
56  TMS::Driver _driver;
-
57  void construct(const JSON&);
+
57  void construct(const std::string& JSON, const IOOptions& io);
58  };
59 }
60 
diff --git a/doxygen/_t_m_s_image_layer_8h_source.html b/doxygen/_t_m_s_image_layer_8h_source.html index 553c11e3..57038683 100644 --- a/doxygen/_t_m_s_image_layer_8h_source.html +++ b/doxygen/_t_m_s_image_layer_8h_source.html @@ -85,7 +85,7 @@
19  {
20  public:
22  TMSImageLayer();
-
23  TMSImageLayer(const JSON&);
+
23  TMSImageLayer(const std::string& JSON, const IOOptions& io);
24 
26  virtual ~TMSImageLayer() { }
27 
@@ -104,7 +104,7 @@
43  private:
44  TMS::Driver _driver;
45 
-
46  void construct(const JSON&);
+
46  void construct(const std::string& JSON, const IOOptions& io);
47  };
48 }
49 
diff --git a/doxygen/_u_r_i_8h_source.html b/doxygen/_u_r_i_8h_source.html index 689820ce..eb7fd48e 100644 --- a/doxygen/_u_r_i_8h_source.html +++ b/doxygen/_u_r_i_8h_source.html @@ -76,110 +76,133 @@
7 
8 #include <rocky/Common.h>
9 #include <rocky/IOTypes.h>
-
10 
-
11 #include <iostream>
-
12 #include <string>
-
13 
-
14 namespace ROCKY_NAMESPACE
-
15 {
-
16  class URI;
-
17  class IOControl;
-
18 
-
33  struct URIContext
-
34  {
-
35  std::string referrer;
-
36  Headers headers;
-
37  };
-
38 
-
39 
-
44  class ROCKY_EXPORT URI
-
45  {
-
46  public:
-
48  static bool supportsHTTPS();
-
49 
-
51  struct ROCKY_EXPORT Stream
-
52  {
-
53  public:
-
54  Stream(shared_ptr<std::istream> s = nullptr);
-
55 
-
57  bool valid() const { return _in != nullptr; }
+
10 #include <rocky/json.h>
+
11 
+
12 #include <iostream>
+
13 #include <string>
+
14 
+
15 namespace ROCKY_NAMESPACE
+
16 {
+
17  class URI;
+
18  class IOControl;
+
19 
+
20  using Headers = std::unordered_map<std::string, std::string>;
+
21 
+
36  struct URIContext
+
37  {
+
38  std::string referrer;
+
39  Headers headers;
+
40  };
+
41 
+
42 
+
47  class ROCKY_EXPORT URI
+
48  {
+
49  public:
+
51  static bool supportsHTTPS();
+
52 
+
54  struct ROCKY_EXPORT Stream
+
55  {
+
56  public:
+
57  Stream(shared_ptr<std::istream> s = nullptr);
58 
-
60  operator std::istream&() { return *_in.get(); }
+
60  bool valid() const { return _in != nullptr; }
61 
-
63  std::string to_string();
+
63  operator std::istream&() { return *_in.get(); }
64 
-
65  private:
-
66  shared_ptr<std::istream> _in;
-
67  };
-
68 
-
69  public:
-
71  URI();
-
72 
-
73  URI(const URI& rhs);
-
74 
-
76  URI(const std::string& location);
+
66  std::string to_string();
+
67 
+
68  private:
+
69  shared_ptr<std::istream> _in;
+
70  };
+
71 
+
72  public:
+
74  URI();
+
75 
+
76  URI(const URI& rhs);
77 
-
79  URI(const std::string& location, const URIContext& context);
+
79  URI(const std::string& location);
80 
-
82  URI(const std::string& location, const std::string& referrer) :
-
83  URI(location, URIContext{ referrer }) { }
-
84 
-
85  URI(const char* location) :
-
86  URI(std::string(location)) { }
+
82  URI(const std::string& location, const URIContext& context);
+
83 
+
85  URI(const std::string& location, const std::string& referrer) :
+
86  URI(location, URIContext{ referrer }) { }
87 
-
89  const std::string& base() const { return _baseURI; }
+
88  URI(const char* location) :
+
89  URI(std::string(location)) { }
90 
-
92  const std::string& full() const { return _fullURI; }
+
92  const std::string& base() const { return _baseURI; }
93 
-
95  const std::string& operator * () const { return _fullURI; }
+
95  const std::string& full() const { return _fullURI; }
96 
-
98  const URIContext& context() const { return _context; }
+
98  const std::string& operator * () const { return _fullURI; }
99 
-
101  bool empty() const { return _baseURI.empty(); }
+
101  void setReferrer(const std::string& value);
102 
-
104  bool isRemote() const;
+
104  const URIContext& context() const { return _context; }
105 
-
107  IOResult<Content> read(const IOOptions& io) const;
+
107  bool empty() const { return _baseURI.empty(); }
108 
-
109  public:
-
110 
-
111  bool operator < (const URI& rhs) const {
-
112  return _fullURI < rhs._fullURI;
-
113  }
+
110  bool isRemote() const;
+
111 
+
113  IOResult<Content> read(const IOOptions& io) const;
114 
-
115  bool operator == (const URI& rhs) const {
-
116  return _fullURI.compare(rhs._fullURI) == 0;
-
117  }
-
118 
-
119  bool operator != (const URI& rhs) const {
-
120  return _fullURI.compare(rhs._fullURI) != 0;
-
121  }
-
122 
-
123 
-
124  public: // Static convenience methods
-
125 
-
127  inline static std::string urlEncode(const std::string &value);
+
115  public:
+
116 
+
117  bool operator < (const URI& rhs) const {
+
118  return _fullURI < rhs._fullURI;
+
119  }
+
120 
+
121  bool operator == (const URI& rhs) const {
+
122  return _fullURI.compare(rhs._fullURI) == 0;
+
123  }
+
124 
+
125  bool operator != (const URI& rhs) const {
+
126  return _fullURI.compare(rhs._fullURI) != 0;
+
127  }
128 
-
129  protected:
-
130  std::string _baseURI;
-
131  std::string _fullURI;
-
132  std::string::size_type _r0 = std::string::npos, _r1 = std::string::npos;
-
133  URIContext _context;
+
129 
+
130  public: // Static convenience methods
+
131 
+
133  inline static std::string urlEncode(const std::string &value);
134 
-
135  void findRotation();
-
136  };
-
137 }
-
ROCKY_NAMESPACE::URI
Definition: URI.h:45
-
ROCKY_NAMESPACE::URI::base
const std::string & base() const
Definition: URI.h:89
-
ROCKY_NAMESPACE::URI::empty
bool empty() const
Definition: URI.h:101
-
ROCKY_NAMESPACE::URI::context
const URIContext & context() const
Definition: URI.h:98
-
ROCKY_NAMESPACE::URI::URI
URI(const std::string &location, const std::string &referrer)
Constructs a new URI from a location and a referring location.
Definition: URI.h:82
-
ROCKY_NAMESPACE::URI::full
const std::string & full() const
Definition: URI.h:92
+
135  protected:
+
136  std::string _baseURI;
+
137  std::string _fullURI;
+
138  std::string::size_type _r0 = std::string::npos, _r1 = std::string::npos;
+
139  URIContext _context;
+
140 
+
141  void set(const std::string& location, const URIContext& context);
+
142  void findRotation();
+
143  };
+
144 
+
145 
+
146  // json specializations.
+
147  inline bool get_to(const json& obj, const char* name, URI& var, const IOOptions& io)
+
148  {
+
149  bool ok = get_to(obj, name, var);
+
150  if (ok && io.referrer.has_value())
+
151  var.setReferrer(io.referrer.value());
+
152  return ok;
+
153  }
+
154  inline bool get_to(const json& obj, const char* name, rocky::optional<URI>& var, const IOOptions& io)
+
155  {
+
156  bool ok = get_to(obj, name, var);
+
157  if (ok && io.referrer.has_value())
+
158  var->setReferrer(io.referrer.value());
+
159  return ok;
+
160  }
+
161 }
+
ROCKY_NAMESPACE::URI
Definition: URI.h:48
+
ROCKY_NAMESPACE::URI::base
const std::string & base() const
Definition: URI.h:92
+
ROCKY_NAMESPACE::URI::empty
bool empty() const
Definition: URI.h:107
+
ROCKY_NAMESPACE::URI::context
const URIContext & context() const
Definition: URI.h:104
+
ROCKY_NAMESPACE::URI::URI
URI(const std::string &location, const std::string &referrer)
Constructs a new URI from a location and a referring location.
Definition: URI.h:85
+
ROCKY_NAMESPACE::URI::full
const std::string & full() const
Definition: URI.h:95
ROCKY_NAMESPACE
Definition: Callbacks.h:16
-
ROCKY_NAMESPACE::IOResult
Definition: IOTypes.h:208
-
ROCKY_NAMESPACE::URI::Stream
Holds a stream for reading content data.
Definition: URI.h:52
-
ROCKY_NAMESPACE::URI::Stream::valid
bool valid() const
Whether the stream exists.
Definition: URI.h:57
-
ROCKY_NAMESPACE::URIContext
Definition: URI.h:34
+
ROCKY_NAMESPACE::IOResult
Definition: IOTypes.h:213
+
ROCKY_NAMESPACE::URI::Stream
Holds a stream for reading content data.
Definition: URI.h:55
+
ROCKY_NAMESPACE::URI::Stream::valid
bool valid() const
Whether the stream exists.
Definition: URI.h:60
+
ROCKY_NAMESPACE::URIContext
Definition: URI.h:37