Storage.h
Go to the documentation of this file.
1 /****
2  * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development.
3  * Created 2015 by Skurydin Alexey
4  * http://github.com/SmingHub/Sming
5  * All files of the Sming Core are provided under the LGPL v3 license.
6  *
7  * Storage.h
8  *
9  ****/
10 #pragma once
11 
12 #include "Storage/Device.h"
13 
14 namespace Storage
15 {
19 void initialize();
20 
25 
30 bool registerDevice(Device* device);
31 
37 bool unRegisterDevice(Device* device);
38 
42 Device* findDevice(const String& name);
43 
48 
53 {
54  return Iterator(type, subType);
55 }
56 
57 template <typename T> typename std::enable_if<std::is_enum<T>::value, Iterator>::type findPartition(T subType)
58 {
59  return Iterator(Partition::Type(T::partitionType), uint8_t(subType));
60 }
61 
62 template <typename T> Storage::Partition findDefaultPartition(T subType)
63 {
64  auto part = *Storage::findPartition(subType);
65  if(part) {
66  debug_i("[%s] Found '%s'", part.typeString().c_str(), part.name().c_str());
67  } else {
68  debug_e("[%s] No partition found", toString(subType).c_str());
69  }
70  return part;
71 }
72 
73 } // namespace Storage
std::enable_if< std::is_integral< T >::value, String >::type toString(T value)
Definition: BitSet.h:481
Definition: LinkedObjectList.h:90
Represents a storage device (e.g. flash memory)
Definition: Components/Storage/src/include/Storage/Device.h:34
Definition: Iterator.h:19
Represents a flash partition.
Definition: Partition.h:86
Type
Definition: Partition.h:88
The String class.
Definition: WString.h:137
#define debug_i
Definition: debug_progmem.h:99
#define debug_e(fmt,...)
Definition: debug_progmem.h:77
Definition: FileDevice.h:26
const Device::List getDevices()
Get read-only reference to device list.
bool registerDevice(Device *device)
Register a storage device.
bool unRegisterDevice(Device *device)
Unregister a storage device.
Device * findDevice(const String &name)
Find a registered device.
void initialize()
Called early in the startup phase.
Storage::Partition findDefaultPartition(T subType)
Definition: Storage.h:62
Partition findPartition(const String &name)
Find the first partition matching the given name.
static constexpr uint8_t any
Definition: Partition.h:99