Skip to content

Commit

Permalink
Documnent changes and adding const to get_type method
Browse files Browse the repository at this point in the history
  • Loading branch information
Yossi Levy authored and Yossi Levy committed Dec 23, 2018
1 parent 9590441 commit b17d13e
Show file tree
Hide file tree
Showing 34 changed files with 43 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ bd_size_t DataFlashBlockDevice::size() const
return device_size;
}

const char *DataFlashBlockDevice::get_type()
const char *DataFlashBlockDevice::get_type() const
{
return "DATAFLASH";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class DataFlashBlockDevice : public mbed::BlockDevice {
*
* @return A string represent the BlockDevice class type.
*/
virtual const char *get_type();
virtual const char *get_type() const;

private:
// Master side hardware
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ bd_size_t FlashIAPBlockDevice::size() const
return _size;
}

const char *FlashIAPBlockDevice::get_type()
const char *FlashIAPBlockDevice::get_type() const
{
return "FLASHIAP";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class FlashIAPBlockDevice : public mbed::BlockDevice {
*
* @return A string represent the BlockDevice class type.
*/
virtual const char *get_type();
virtual const char *get_type() const;

private:
// Device configuration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ bd_size_t QSPIFBlockDevice::get_erase_size() const
return _min_common_erase_size;
}

const char *QSPIFBlockDevice::get_type()
const char *QSPIFBlockDevice::get_type() const
{
return "QSPIF";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ class QSPIFBlockDevice : public mbed::BlockDevice {
*
* @return A string represent the BlockDevice class type.
*/
virtual const char *get_type();
virtual const char *get_type() const;

private:
// Internal functions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ bd_size_t SPIFReducedBlockDevice::size() const
return _size;
}

const char *SPIFReducedBlockDevice::get_type()
const char *SPIFReducedBlockDevice::get_type() const
{
return "SPIFR";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class SPIFReducedBlockDevice : public mbed::BlockDevice {
*
* @return A string represent the BlockDevice class type.
*/
virtual const char *get_type();
virtual const char *get_type() const;

private:
// Master side hardware
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ bd_size_t SDBlockDevice::size() const
return _block_size * _sectors;
}

const char *SDBlockDevice::get_type()
const char *SDBlockDevice::get_type() const
{
return "SD";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class SDBlockDevice : public mbed::BlockDevice {
*
* @return A string represent the BlockDevice class type.
*/
virtual const char *get_type();
virtual const char *get_type() const;

private:
/* Commands : Listed below are commands supported
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ int SPIFBlockDevice::get_erase_value() const
return 0xFF;
}

const char *SPIFBlockDevice::get_type()
const char *SPIFBlockDevice::get_type() const
{
return "SPIF";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ class SPIFBlockDevice : public mbed::BlockDevice {
*
* @return A string represent the BlockDevice class type.
*/
virtual const char *get_type();
virtual const char *get_type() const;

private:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,23 @@ In fact it might be worth to consider adding the get_type to any interface with
## Dive into details
we should add the following method to BlockDevice interface class.

```virtual const char * get_type() = 0;```
```virtual const char * get_type() const = 0;```

then every physical BlockDevice class which implements the interface should also implement this method and return a string
representing its type. Furthermore, a nonphysical BlockDevice like SlicingBlockDevice should return the underlying physical
BlockDevice type.

### Physical BlockDevice:
```
const char * HeapBlockDevice::get_type()
const char * HeapBlockDevice::get_type() const
{
return "HEAP";
}
```

### Logical BlockDevice:
```
const char * SlicingBlockDevice::get_type()
const char * SlicingBlockDevice::get_type() const
{
if (_bd != NULL) {
return _bd->get_type();
Expand All @@ -60,6 +60,12 @@ const char * SlicingBlockDevice::get_type()
}
```

### Open issue
The ChainingBlockDevice which chains different type of physical block devices into one block device is unable
to return the underneath physical as it contains two or more types. Therefore it will return CHAINING as its
identity and its left for the user to decide how the application will treat this information.


The below table describes physical BlockDevice and its tyep names


Expand All @@ -72,3 +78,4 @@ The below table describes physical BlockDevice and its tyep names
| SDBlockDevice | "SD" |
| FlashIAPBlockDevice | "FLASHIAP" |
| DataFlashBlockDevice | "DATAFLASH" |
| ChainingBlockDevice | "CHAINING" |
2 changes: 1 addition & 1 deletion features/storage/blockdevice/BlockDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ class BlockDevice {
*
* @return A string represent the BlockDevice class type.
*/
virtual const char *get_type() = 0;
virtual const char *get_type() const = 0;
};

} // namespace mbed
Expand Down
2 changes: 1 addition & 1 deletion features/storage/blockdevice/BufferedBlockDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ bd_size_t BufferedBlockDevice::size() const
return _bd_size;
}

const char *BufferedBlockDevice::get_type()
const char *BufferedBlockDevice::get_type() const
{
if (_bd != NULL) {
return _bd->get_type();
Expand Down
2 changes: 1 addition & 1 deletion features/storage/blockdevice/BufferedBlockDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class BufferedBlockDevice : public BlockDevice {
*
* @return A string represent the BlockDevice class type.
*/
virtual const char *get_type();
virtual const char *get_type() const;

protected:
BlockDevice *_bd;
Expand Down
2 changes: 1 addition & 1 deletion features/storage/blockdevice/ChainingBlockDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ bd_size_t ChainingBlockDevice::size() const
return _size;
}

const char *ChainingBlockDevice::get_type()
const char *ChainingBlockDevice::get_type() const
{
return "CHAINING";
}
Expand Down
2 changes: 1 addition & 1 deletion features/storage/blockdevice/ChainingBlockDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ class ChainingBlockDevice : public BlockDevice {
*
* @return A string represent the BlockDevice class type.
*/
virtual const char *get_type();
virtual const char *get_type() const;

protected:
BlockDevice **_bds;
Expand Down
2 changes: 1 addition & 1 deletion features/storage/blockdevice/ExhaustibleBlockDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ bd_size_t ExhaustibleBlockDevice::size() const
return _bd->size();
}

const char *ExhaustibleBlockDevice::get_type()
const char *ExhaustibleBlockDevice::get_type() const
{
if (_bd != NULL) {
return _bd->get_type();
Expand Down
2 changes: 1 addition & 1 deletion features/storage/blockdevice/ExhaustibleBlockDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ class ExhaustibleBlockDevice : public BlockDevice {
*
* @return A string represent the BlockDevice class type.
*/
virtual const char *get_type();
virtual const char *get_type() const;

private:
BlockDevice *_bd;
Expand Down
2 changes: 1 addition & 1 deletion features/storage/blockdevice/FlashSimBlockDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ int FlashSimBlockDevice::get_erase_value() const
return _erase_value;
}

const char *FlashSimBlockDevice::get_type()
const char *FlashSimBlockDevice::get_type() const
{
if (_bd != NULL) {
return _bd->get_type();
Expand Down
2 changes: 1 addition & 1 deletion features/storage/blockdevice/FlashSimBlockDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class FlashSimBlockDevice : public BlockDevice {
*
* @return A string represent the BlockDevice class type.
*/
virtual const char *get_type();
virtual const char *get_type() const;

private:
uint8_t _erase_value;
Expand Down
2 changes: 1 addition & 1 deletion features/storage/blockdevice/HeapBlockDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ int HeapBlockDevice::erase(bd_addr_t addr, bd_size_t size)
return 0;
}

const char *HeapBlockDevice::get_type()
const char *HeapBlockDevice::get_type() const
{
return "HEAP";
}
Expand Down
2 changes: 1 addition & 1 deletion features/storage/blockdevice/HeapBlockDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class HeapBlockDevice : public BlockDevice {
*
* @return A string represent the BlockDevice class type.
*/
virtual const char *get_type();
virtual const char *get_type() const;

private:
bd_size_t _read_size;
Expand Down
2 changes: 1 addition & 1 deletion features/storage/blockdevice/MBRBlockDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ int MBRBlockDevice::get_partition_number() const
return _part;
}

const char *MBRBlockDevice::get_type()
const char *MBRBlockDevice::get_type() const
{
if (_bd != NULL) {
return _bd->get_type();
Expand Down
2 changes: 1 addition & 1 deletion features/storage/blockdevice/MBRBlockDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ class MBRBlockDevice : public BlockDevice {
*
* @return A string represent the BlockDevice class type.
*/
virtual const char *get_type();
virtual const char *get_type() const;

protected:
BlockDevice *_bd;
Expand Down
2 changes: 1 addition & 1 deletion features/storage/blockdevice/ObservingBlockDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ bd_size_t ObservingBlockDevice::size() const
return _bd->size();
}

const char *ObservingBlockDevice::get_type()
const char *ObservingBlockDevice::get_type() const
{
if (_bd != NULL) {
return _bd->get_type();
Expand Down
2 changes: 1 addition & 1 deletion features/storage/blockdevice/ObservingBlockDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class ObservingBlockDevice : public BlockDevice {
*
* @return A string represent the BlockDevice class type.
*/
virtual const char *get_type();
virtual const char *get_type() const;

private:
BlockDevice *_bd;
Expand Down
2 changes: 1 addition & 1 deletion features/storage/blockdevice/ProfilingBlockDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ bd_size_t ProfilingBlockDevice::get_erase_count() const
return _erase_count;
}

const char *ProfilingBlockDevice::get_type()
const char *ProfilingBlockDevice::get_type() const
{
if (_bd != NULL) {
return _bd->get_type();
Expand Down
2 changes: 1 addition & 1 deletion features/storage/blockdevice/ProfilingBlockDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ class ProfilingBlockDevice : public BlockDevice {
*
* @return A string represent the BlockDevice class type.
*/
virtual const char *get_type();
virtual const char *get_type() const;

private:
BlockDevice *_bd;
Expand Down
2 changes: 1 addition & 1 deletion features/storage/blockdevice/ReadOnlyBlockDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ bd_size_t ReadOnlyBlockDevice::size() const
return _bd->size();
}

const char *ReadOnlyBlockDevice::get_type()
const char *ReadOnlyBlockDevice::get_type() const
{
if (_bd != NULL) {
return _bd->get_type();
Expand Down
2 changes: 1 addition & 1 deletion features/storage/blockdevice/ReadOnlyBlockDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class ReadOnlyBlockDevice : public BlockDevice {
*
* @return A string represent the BlockDevice class type.
*/
virtual const char *get_type();
virtual const char *get_type() const;

private:
BlockDevice *_bd;
Expand Down
2 changes: 1 addition & 1 deletion features/storage/blockdevice/SlicingBlockDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ bd_size_t SlicingBlockDevice::size() const
return _stop - _start;
}

const char *SlicingBlockDevice::get_type()
const char *SlicingBlockDevice::get_type() const
{
if (_bd != NULL) {
return _bd->get_type();
Expand Down
2 changes: 1 addition & 1 deletion features/storage/blockdevice/SlicingBlockDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class SlicingBlockDevice : public BlockDevice {
*
* @return A string represent the BlockDevice class type.
*/
virtual const char *get_type();
virtual const char *get_type() const;

protected:
BlockDevice *_bd;
Expand Down

0 comments on commit b17d13e

Please sign in to comment.