Mbed OS Reference
Loading...
Searching...
No Matches
KVMap Class Reference

KVMap class. More...

#include <KVMap.h>

Inheritance diagram for KVMap:
NonCopyable< KVMap >

Public Member Functions

int init ()
 Initializes KVMap. More...
 
int attach (const char *partition_name, kvstore_config_t *kv_config)
 Attach a KVStore partition configuration, and add it to the KVMap array. More...
 
int detach (const char *partition_name)
 Detach a KVStore partition configuration from the KVMap array, and deinitialize its components. More...
 
int deinit ()
 Deinitialize the KVMap array, and deinitialize all the attached partitions. More...
 
int lookup (const char *full_name, mbed::KVStore **kv_instance, size_t *key_index, uint32_t *flags_mask=NULL)
 Full name lookup, and then break it into KVStore instance and key. More...
 
KVStoreget_internal_kv_instance (const char *name)
 Getter for the internal KVStore instance. More...
 
KVStoreget_external_kv_instance (const char *name)
 Getter for the external KVStore instance. More...
 
KVStoreget_main_kv_instance (const char *name)
 Getter for the main KVStore instance. More...
 
BlockDeviceget_internal_blockdevice_instance (const char *name)
 Getter for the internal BlockDevice instance. More...
 
BlockDeviceget_external_blockdevice_instance (const char *name)
 Getter for the external BlockDevice instance. More...
 
FileSystemget_external_filesystem_instance (const char *name)
 Getter for the external FileSystem instance. More...
 

Static Public Member Functions

static KVMapget_instance ()
 As a singleton, return the single instance of the class. More...
 

Detailed Description

KVMap class.

Singleton class to manage the mapping of KVStore partition and its naming.

Definition at line 90 of file KVMap.h.

Member Function Documentation

◆ get_instance()

static KVMap & get_instance ( )
static

As a singleton, return the single instance of the class.

This class is a singleton for the following reasons:

  • Ease of use, so you don't have to coordinate instantiations.
  • Lazy instantiation of internal data, (which we can't achieve with simple static classes).
Returns
Singleton instance reference.

Definition at line 101 of file KVMap.h.

◆ init()

int init ( )

Initializes KVMap.

Returns
0 on success, negative error code on failure

◆ attach()

int attach ( const char *  partition_name,
kvstore_config_t kv_config 
)

Attach a KVStore partition configuration, and add it to the KVMap array.

Parameters
partition_nameString parameter contains the partition name.
kv_configA configuration struct created by the kv_config or by the user.
Returns
0 on success, negative error code on failure

◆ detach()

int detach ( const char *  partition_name)

Detach a KVStore partition configuration from the KVMap array, and deinitialize its components.

Parameters
partition_nameString parameter contains the partition name.
Returns
0 on success, negative error code on failure

◆ deinit()

int deinit ( )

Deinitialize the KVMap array, and deinitialize all the attached partitions.

Returns
0 on success, negative error code on failure

◆ lookup()

int lookup ( const char *  full_name,
mbed::KVStore **  kv_instance,
size_t *  key_index,
uint32_t *  flags_mask = NULL 
)

Full name lookup, and then break it into KVStore instance and key.

Parameters
[in]full_nameString parameter contains the partition name to look for. The String should be formated as follow "/partition name/key". The key is optional.
[out]kv_instanceReturns the main KVStore instance associated with the required partition name.
[out]key_indexReturns an index to the first character of the key.
[out]flags_maskReturn the flag masking for the current configuration
Returns
0 on success, negative error code on failure

◆ get_internal_kv_instance()

KVStore * get_internal_kv_instance ( const char *  name)

Getter for the internal KVStore instance.

Parameters
nameString parameter contains the /partition name/.
Returns
Pointer to the internal kvstore on success, NULL on failure or if not exist

◆ get_external_kv_instance()

KVStore * get_external_kv_instance ( const char *  name)

Getter for the external KVStore instance.

Parameters
nameString parameter contains the /partition name/.
Returns
Pointer to the external kvstore on success, NULL on failure or if not exist

◆ get_main_kv_instance()

KVStore * get_main_kv_instance ( const char *  name)

Getter for the main KVStore instance.

Parameters
nameString parameter contains the /partition name/.
Returns
Pointer to the main kvstore on success, NULL on failure or if not exist

◆ get_internal_blockdevice_instance()

BlockDevice * get_internal_blockdevice_instance ( const char *  name)

Getter for the internal BlockDevice instance.

Parameters
nameString parameter contains the /partition name/.
Returns
Pointer to the internal BlockDevice on success, NULL on failure or if not exist

◆ get_external_blockdevice_instance()

BlockDevice * get_external_blockdevice_instance ( const char *  name)

Getter for the external BlockDevice instance.

Parameters
nameString parameter contains the /partition name/.
Returns
Pointer to the external BlockDevice on success, NULL on failure or if not exist

◆ get_external_filesystem_instance()

FileSystem * get_external_filesystem_instance ( const char *  name)

Getter for the external FileSystem instance.

Parameters
nameString parameter contains the /partition name/.
Returns
Pointer to the external FileSystem on success, NULL on failure or if not exist