mn_block_device.hpp
Go to the documentation of this file.
1 
21 #ifndef __MINILIB_BLOCK_DEVICE_H__
22 #define __MINILIB_BLOCK_DEVICE_H__
23 
24 #include "../mn_config.hpp"
25 
26 
27 #include "mn_basic_device.hpp"
28 #include "../mn_def.hpp"
29 
30 namespace mn {
31  namespace device {
37  public:
38  basic_block_device(char prefix[8]) : basic_device(prefix) { }
39 
43  virtual ~basic_block_device() = default;
44 
49  virtual int open() = 0;
57  virtual int synchronize() = 0;
63  virtual int stop() = 0;
64 
68  virtual void lock() = 0;
69 
74  virtual void unlock() = 0;
75 
86  virtual int read(uint64_t address, void* buffer, size_t size) = 0;
98  virtual int write(uint64_t address, const void* buffer, size_t size) = 0;
99 
107  virtual int erase(uint64_t address, uint64_t size) = 0;
108 
112  virtual size_t get_block_size() const = 0;
113 
117  virtual uint64_t get_size() const = 0;
118 
121 
122  };
123  }
124 }
125 
126 
127 #endif // __MINILIB_BLOCK_DEVICE_H__
A buffer class that allocates a buffer of a given type and size.
Definition: mn_buffer.hpp:37
basic_block_device class is an interface for a block device.
Definition: mn_block_device.hpp:36
virtual ~basic_block_device()=default
BlockDevice's destructor.
virtual uint64_t get_size() const =0
basic_block_device(char prefix[8])
Definition: mn_block_device.hpp:38
virtual int read(uint64_t address, void *buffer, size_t size)=0
Reads data from a device.
virtual int synchronize()=0
Synchronizes state of a device, ensuring all cached writes are finished.
basic_block_device(const basic_block_device &)=delete
virtual size_t get_block_size() const =0
virtual void lock()=0
Locks the device for exclusive use by current thread.
basic_block_device & operator=(const basic_block_device &)=delete
virtual int erase(uint64_t address, uint64_t size)=0
Erases blocks on a device.
virtual int open()=0
Opens device.
virtual int write(uint64_t address, const void *buffer, size_t size)=0
Writes data to a device.
virtual void unlock()=0
Unlocks the device which was previously locked by current thread.
virtual int stop()=0
Closes device.
Definition: mn_basic_device.hpp:27
This file is part of the Mini Thread Library (https://github.com/RoseLeBlood/MiniThread ).
Definition: mn_allocator_typetraits.hpp:25