Skip to content
Snippets Groups Projects
buffer.h 933 B
Newer Older
数学の武士's avatar
数学の武士 committed
#pragma once
#include "TemplateParameters.h"
#include <cstdlib>

class buffer
数学の武士's avatar
数学の武士 committed
{
public:
    void *ptr;
    size_t allocated_size;
    size_t scalar_size;
    bool is_free;
    int id;
    MemType mem;

    buffer(const size_t required_size, const MemType mem); // Done
    buffer(const buffer& other); // Done
    buffer(buffer&& other) noexcept; // Done
    ~buffer(); // Done
数学の武士's avatar
数学の武士 committed

    bool is_available() const; // Done
    void* get_ptr(); // Done
    bool get_status() const; // Done
    size_t get_size() const; // Done
    int get_id() const; // Done

    void set_allocated_size(const size_t required_size); // Done
    void set_status(const bool status); // Done
    void set_id(const int id); // Done
    void set_null_pointer(); // Done

    buffer& operator=(const buffer& other); // Done
    buffer& operator=(buffer&& other) noexcept;      // Done
数学の武士's avatar
数学の武士 committed

    void reallocate(const size_t required_size);
    void deallocate();
};