OpenZGY/C++ Public API (ALPHA)
Access seismic data stored in ZGY format.
iocontext.h
Go to the documentation of this file.
1 // Copyright 2017-2020, Schlumberger
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
23 #include "declspec.h"
24 #include "exception.h"
25 
26 #include <cstdint>
27 #include <string>
28 #include <vector>
29 #include <functional>
30 
31 namespace Test
32 {
33  class TestIOContext;
34 }
35 namespace InternalZGY
36 {
37  class SeismicStoreFile;
38  class SeismicStoreFileDelayedWrite;
39 }
40 
41 namespace OpenZGY {
42 #if 0
43 }
44 #endif
45 
49 class OPENZGY_API IOContext
50 {
51 public:
52  virtual ~IOContext();
54  virtual std::string toString() const = 0;
55 };
56 
73 class OPENZGY_API SeismicStoreIOContext : public IOContext
74 {
75  // Needed because there are no public accessors. Because I am lazy.
76  friend class Test::TestIOContext;
77  friend class InternalZGY::SeismicStoreFile;
78  friend class InternalZGY::SeismicStoreFileDelayedWrite;
79 
80 public:
81  typedef std::function<std::string()> tokencb_t;
82  typedef std::function<void(const std::string&, std::int64_t, std::int64_t, std::int64_t, const std::vector<std::int64_t>&)> debugtrace_t;
83  virtual std::string toString() const override;
85 
86 private:
87  std::string _sdurl;
88  std::string _sdapikey;
89  std::string _sdtoken;
90  std::string _sdtokentype;
91  std::int64_t _maxsize;
92  std::int64_t _maxhole;
93  std::int64_t _aligned;
94  std::int64_t _segsize;
95  std::int64_t _threads;
96  std::string _legaltag;
97  std::string _writeid;
98  std::string _seismicmeta;
99  std::string _sdtoken_cbtype;
100  tokencb_t _sdtokencb;
101  debugtrace_t _debug_trace;
102 
103 public:
110  SeismicStoreIOContext& sdurl(const std::string& value)
111  {
112  this->_sdurl = value;
113  return *this;
114  }
115 
122  SeismicStoreIOContext& sdapikey(const std::string& value)
123  {
124  this->_sdapikey = value;
125  return *this;
126  }
127 
144  SeismicStoreIOContext& sdtoken(const std::string& value, const std::string& type) {
145  this->_sdtoken = value;
146  this->_sdtokentype = type;
147  this->_sdtokencb = tokencb_t();
148  return *this;
149  }
150 
162  SeismicStoreIOContext& sdtokencb(const tokencb_t& value, const std::string& type) {
163  this->_sdtokencb = value;
164  this->_sdtokentype = type;
165  this->_sdtoken = std::string();
166  return *this;
167  }
168 
196  {
197  if (value < 0 || value > 1024)
198  throw OpenZGY::Errors::ZgyUserError("maxsize must be between 0 and 1024 MB");
199  this->_maxsize = value * (std::int64_t)(1024*1024);
200  return *this;
201  }
202 
222  {
223  if (value < 0 || value > 1024)
224  throw OpenZGY::Errors::ZgyUserError("maxhole must be between 0 and 1024 MB");
225  this->_maxhole = value * (std::int64_t)(1024*1024);
226  return *this;
227  }
228 
242  {
243  if (value < 0 || value > 1024)
244  throw OpenZGY::Errors::ZgyUserError("aligned must be between 0 and 1024 MB");
245  this->_aligned = value * (std::int64_t)(1024*1024);
246  return *this;
247  }
248 
256  {
257  if (value < 0 || value > 16*1024)
258  throw OpenZGY::Errors::ZgyUserError("segsize must be between 0 and 16*1024 MB");
259  this->_segsize = value * (std::int64_t)(1024*1024);
260  return *this;
261  }
262 
278  {
279  if (value < 1 || value > 1024)
280  throw OpenZGY::Errors::ZgyUserError("threads must be between 1 and 1024");
281  this->_threads = value;
282  return *this;
283  }
284 
288  SeismicStoreIOContext& legaltag(const std::string& value)
289  {
290  this->_legaltag = value;
291  return *this;
292  }
293 
299  SeismicStoreIOContext& writeid(const std::string& value)
300  {
301  this->_writeid = value;
302  return *this;
303  }
304 
312  SeismicStoreIOContext& seismicmeta(const std::string& value)
313  {
314  this->_seismicmeta = value;
315  return *this;
316  }
317 
325  SeismicStoreIOContext& debug_trace(const debugtrace_t& value)
326  {
327  this->_debug_trace = value;
328  return *this;
329  }
330 };
331 
334 }
335 
336 // namespace
exception.h
Defines exceptions that may be raised by OpenZGY.
OpenZGY::SeismicStoreIOContext::maxsize
SeismicStoreIOContext & maxsize(int value)
Definition: iocontext.h:195
OpenZGY::SeismicStoreIOContext::sdtokencb
SeismicStoreIOContext & sdtokencb(const tokencb_t &value, const std::string &type)
Definition: iocontext.h:162
OpenZGY::IOContext::toString
virtual std::string toString() const =0
OpenZGY::SeismicStoreIOContext::legaltag
SeismicStoreIOContext & legaltag(const std::string &value)
Definition: iocontext.h:288
OpenZGY::SeismicStoreIOContext::sdtoken
SeismicStoreIOContext & sdtoken(const std::string &value, const std::string &type)
Definition: iocontext.h:144
OpenZGY::Errors::ZgyUserError
Exception that might be caused by the calling application.
Definition: exception.h:98
OpenZGY::SeismicStoreIOContext::sdurl
SeismicStoreIOContext & sdurl(const std::string &value)
Definition: iocontext.h:110
OpenZGY::SeismicStoreIOContext::debug_trace
SeismicStoreIOContext & debug_trace(const debugtrace_t &value)
Definition: iocontext.h:325
OpenZGY::SeismicStoreIOContext::sdapikey
SeismicStoreIOContext & sdapikey(const std::string &value)
Definition: iocontext.h:122
OpenZGY::SeismicStoreIOContext::seismicmeta
SeismicStoreIOContext & seismicmeta(const std::string &value)
Definition: iocontext.h:312
OpenZGY::SeismicStoreIOContext::writeid
SeismicStoreIOContext & writeid(const std::string &value)
Definition: iocontext.h:299
OpenZGY::IOContext
Base class for backend specific context.
Definition: iocontext.h:49
OpenZGY::SeismicStoreIOContext::segsize
SeismicStoreIOContext & segsize(int value)
Definition: iocontext.h:255
OpenZGY::SeismicStoreIOContext::maxhole
SeismicStoreIOContext & maxhole(int value)
Definition: iocontext.h:221
OpenZGY::SeismicStoreIOContext::aligned
SeismicStoreIOContext & aligned(int value)
Definition: iocontext.h:241
OpenZGY
The entire public API is in this namespace.
Definition: api.h:38
OpenZGY::SeismicStoreIOContext
Credentials and configuration for Seismic Store.
Definition: iocontext.h:73
OpenZGY::SeismicStoreIOContext::threads
SeismicStoreIOContext & threads(int value)
Definition: iocontext.h:277