nl::Weave::PersistedCounter

#include <src/lib/support/PersistedCounter.h>

A class for managing a counter as an integer value intended to persist across reboots.

Summary

Inheritance

Inherits from: nl::Weave::MonotonicallyIncreasingCounter

Constructors and Destructors

PersistedCounter(void)
~PersistedCounter(void)

Public functions

Advance(void)
virtual WEAVE_ERROR
Increment the counter and write to persisted storage if we've completed the current epoch.
AdvanceEpochRelative(uint32_t aValue)
Init(const nl::Weave::Platform::PersistedStorage::Key aId, uint32_t aEpoch)
Initialize a PersistedCounter object.
SetValue(uint32_t value)
This is used to set the event counter from persisted events.

Public functions

Advance

virtual WEAVE_ERROR Advance(
  void
)

Increment the counter and write to persisted storage if we've completed the current epoch.

Details
Returns
Any error returned by a write to persisted storage.

AdvanceEpochRelative

WEAVE_ERROR AdvanceEpochRelative(
  uint32_t aValue
)

Init

WEAVE_ERROR Init(
  const nl::Weave::Platform::PersistedStorage::Key aId,
  uint32_t aEpoch
)

Initialize a PersistedCounter object.

Details
Parameters
[in] aId
The identifier of this PersistedCounter instance.
[in] aEpoch
On bootup, values we vend will start at a multiple of this parameter.
Returns
WEAVE_ERROR_INVALID_ARGUMENT if aId is NULL WEAVE_ERROR_INVALID_STRING_LENGTH if aId is longer than WEAVE_CONFIG_PERSISTED_STORAGE_MAX_KEY_LENGTH. WEAVE_ERROR_INVALID_INTEGER_VALUE if aEpoch is 0. WEAVE_NO_ERROR otherwise

PersistedCounter

 PersistedCounter(
  void
)

SetValue

WEAVE_ERROR SetValue(
  uint32_t value
)

This is used to set the event counter from persisted events.

~PersistedCounter

virtual  ~PersistedCounter(
  void
)