Files
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

73 lines
1.9 KiB
C++

// WARNING: Changes to this file must be contributed back to Sawyer or else they will
// be clobbered by the next update from Sawyer. The Sawyer repository is at
// https://github.com/matzke1/sawyer.
#ifndef Sawyer_NullBuffer_H
#define Sawyer_NullBuffer_H
#include "Buffer.h"
#include "Sawyer.h"
namespace Sawyer {
namespace Container {
/** %Buffer that has no data.
*
* This can be useful to reserve areas of of a BufferMap address space without actually storing any data at them. All
* reads return default values and writes using such a buffer will fail (return zero). */
template<class A, class T>
class NullBuffer: public Buffer<A, T> {
public:
typedef A Address;
typedef T Value;
private:
Address size_;
protected:
NullBuffer(): size_(0) {}
explicit NullBuffer(Address size): size_(size) {}
public:
/** Construct a new buffer.
*
* The new buffer will act as if it contains @p size values, although no values will actually be stored. */
static typename Buffer<A, T>::Ptr instance(Address size) {
return typename Buffer<A, T>::Ptr(new NullBuffer(size));
}
typename Buffer<A, T>::Ptr copy() const /*override*/ {
return instance(size_);
}
Address available(Address start) const /*override*/ {
return start < size_ ? size_ - start : 0;
}
void resize(Address newSize) /*override*/ {
size_ = newSize;
}
Address read(Value *buf, Address address, Address n) const /*override*/ {
Address nread = std::min(available(address), n);
if (buf) {
for (Address i=0; i<n; ++i)
buf[i] = Value();
}
return nread;
}
Address write(const Value *buf, Address address, Address n) /*override*/ {
return 0;
}
const Value* data() const /*override*/ {
return NULL;
}
};
} // namespace
} // namespace
#endif