Commit c0501f7d authored by Paal Kvamme's avatar Paal Kvamme
Browse files

Refactoring before complicated change to make diffing simpler. const correctness.

parent 23971964
......@@ -132,12 +132,12 @@ GenLodBase::GenLodBase(
* _total done in __init__ might need to change.
*/
void
GenLodBase::_report(const DataBuffer* data)
GenLodBase::_report(const DataBuffer* data) const
{
if (data) {
std::array<std::int64_t,3> bricks =
(data->size3d() + this->_bricksize - std::int64_t(1)) / this->_bricksize;
this->_done += (bricks[0] * bricks[1] * bricks[2]);
const_cast<std::int64_t&>(this->_done) += (bricks[0] * bricks[1] * bricks[2]);
}
if (this->_progress && !this->_progress(_done, _total))
throw OpenZGY::Errors::ZgyAborted("Computation of low resolution data was aborted");
......@@ -153,7 +153,7 @@ bool
GenLodBase::_canread(
std::int32_t lod,
const std::array<std::int64_t,3>& /*pos*/,
const std::array<std::int64_t,3>& /*size*/)
const std::array<std::int64_t,3>& /*size*/) const
{
return lod==0;
}
......@@ -168,7 +168,7 @@ std::shared_ptr<DataBuffer>
GenLodBase::_read(
std::int32_t lod,
const std::array<std::int64_t,3>& pos,
const std::array<std::int64_t,3>& size)
const std::array<std::int64_t,3>& size) const
{
std::shared_ptr<DataBuffer> result = DataBuffer::makeScalarBuffer3d
(_wa_defaultstorage, size, _dtype);
......@@ -186,7 +186,7 @@ void
GenLodBase::_write(
std::int32_t lod,
const std::array<std::int64_t,3>& pos,
const std::shared_ptr<const DataBuffer>& data)
const std::shared_ptr<const DataBuffer>& data) const
{
this->_report(data.get());
}
......@@ -204,7 +204,7 @@ GenLodBase::_savestats()
* For debugging and logging only.
*/
std::string
GenLodBase::_prefix(std::int32_t lod)
GenLodBase::_prefix(std::int32_t lod) const
{
return std::string(2 * (this->_nlods - 1 - lod), ' ');
}
......@@ -797,7 +797,7 @@ bool
GenLodC::_canread(
std::int32_t lod,
const std::array<std::int64_t,3>& pos,
const std::array<std::int64_t,3>& size)
const std::array<std::int64_t,3>& size) const
{
if (lod == 0) {
return true; // Fullres always read from file.
......@@ -820,7 +820,7 @@ std::shared_ptr<DataBuffer>
GenLodC::_read(
std::int32_t lod,
const index3_t& pos,
const index3_t& size)
const index3_t& size) const
{
std::shared_ptr<DataBuffer> result = this->_accessor->readToNewBuffer
(pos, size, lod, /*as_float=*/false, /*extra_checking*/true);
......@@ -834,7 +834,7 @@ GenLodC::_read(
void
GenLodC::_write(
std::int32_t lod, const index3_t& pos,
const std::shared_ptr<const DataBuffer>& data)
const std::shared_ptr<const DataBuffer>& data) const
{
if (lod > 0) {
if (this->_verbose)
......
......@@ -82,15 +82,15 @@ public:
bool verbose);
protected:
virtual bool _canread(
std::int32_t lod, const index3_t& pos, const index3_t& size);
std::int32_t lod, const index3_t& pos, const index3_t& size) const;
virtual std::shared_ptr<DataBuffer> _read(
std::int32_t lod, const index3_t& pos, const index3_t& size);
std::int32_t lod, const index3_t& pos, const index3_t& size) const;
virtual void _write(
std::int32_t lod, const index3_t& pos,
const std::shared_ptr<const DataBuffer>& data);
const std::shared_ptr<const DataBuffer>& data) const;
virtual void _savestats();
void _report(const DataBuffer* data);
std::string _prefix(std::int32_t lod);
void _report(const DataBuffer* data) const;
std::string _prefix(std::int32_t lod) const;
static std::string _format_result(const std::shared_ptr<DataBuffer>& data);
};
......@@ -159,12 +159,12 @@ public:
bool verbose);
protected:
bool _canread(
std::int32_t lod, const index3_t& pos, const index3_t& size) override;
std::int32_t lod, const index3_t& pos, const index3_t& size) const override;
std::shared_ptr<DataBuffer> _read(
std::int32_t lod, const index3_t& pos, const index3_t& size) override;
std::int32_t lod, const index3_t& pos, const index3_t& size) const override;
void _write(
std::int32_t lod, const index3_t& pos,
const std::shared_ptr<const DataBuffer>& data) override;
const std::shared_ptr<const DataBuffer>& data) const override;
void _savestats() override;
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment