Program Listing for File random-access-storage.h

Return to documentation for file (include\stream\random-access-storage.h)

/******************************************************************************
© Intel Corporation.

This software and the related documents are Intel copyrighted materials,
and your use of them is governed by the express license under which they
were provided to you ("License"). Unless the License provides otherwise,
you may not use, modify, copy, publish, distribute, disclose or transmit
this software or the related documents without Intel's prior written
permission.


 This software and the related documents are provided as is, with no express
or implied warranties, other than those that are expressly stated in the
License.

******************************************************************************/

#pragma once

#include "stream/storage.h"
#include "stream/types.h"

#include <cstdint>
#include <cstddef>

namespace gpa {
namespace stream {

class View;

class RandomAccessStorage : public serialization::Storage
{
public:
    RandomAccessStorage(uint64_t id);
    ~RandomAccessStorage();

    // Storage implementation
    bool IsRandomAccess() const override final;
    bool IsEmpty() const override final;

    SizeType SizeInBytes() const;

    virtual View* Map(void* addrHint = nullptr, SizeType offset = 0, size_t windowSize = (size_t)-1) = 0;

    virtual void Unmap(View* view) = 0;

    virtual bool Resize(SizeType minSize) = 0;

    virtual bool Truncate(SizeType size) = 0;

protected:
    void* mBase{};
    SizeType mSize{};
};

}  // namespace stream
}  // namespace gpa