nl::Weave::Profiles::DataManagement_Current::CircularEventBuffer

#include <src/lib/profiles/data-management/Current/LoggingManagement.h>

Internal event buffer, built around the nl::Weave::TLV::WeaveCircularTLVBuffer.

Summary

Constructors and Destructors

CircularEventBuffer(uint8_t *inBuffer, size_t inBufferLength, CircularEventBuffer *inPrev, CircularEventBuffer *inNext)
A constructor for the CircularEventBuffer (internal API).

Public attributes

mBuffer
mEventIdCounter
mExternalEventsList[1]
mFirstEventID
mFirstEventTimestamp
mFirstEventUTCTimestamp
mImportance
mLastEventID
mLastEventTimestamp
mLastEventUTCTimestamp
mNext
mNonPersistedCounter
mPrev
mUTCInitialized
bool

Public functions

AddEvent(timestamp_t inEventTimestamp)
void
Given a timestamp of an event, compute the delta time to store in the log.
AddEventUTC(utc_timestamp_t inEventTimestamp)
void
Given a timestamp of an event, compute the delta utc time to store in the log.
GetExternalEventsFromEventID(event_id_t aEventID)
A function to get a pointer to the ExternalEvent storing aEventID.
GetNextAvailableExternalEvents(void)
A function to get a pointer to the next available ExternalEvent.
IsFinalDestinationForImportance(ImportanceType inImportance) const
bool
A helper function that determines whether the event of specified importance is dropped from this buffer.
RegisterExternalEventsCallback(FetchExternalEventsFunct aFetchCallback, NotifyExternalEventsDeliveredFunct aNotifyCallback, size_t aNumEvents, ExternalEvents **aExternalEventsPtr)
This function registers a set of event IDs and a function callback for externally stored events.
RemoveEvent(void)
void
UnregisterExternalEventsCallback(ExternalEvents *ioPtr)
void
This function unregisters a callback.
VendEventID(void)
Allocate a new event ID based on the event importance, and advance the counter if we have one.

Public static functions

GetNextBufferFunct(nl::Weave::TLV::TLVReader & ioReader, uintptr_t & inBufHandle, const uint8_t *& outBufStart, uint32_t & outBufLen)

Public attributes

mBuffer

nl::Weave::TLV::WeaveCircularTLVBuffer nl::Weave::Profiles::DataManagement_Current::CircularEventBuffer::mBuffer

mEventIdCounter

nl::Weave::MonotonicallyIncreasingCounter * nl::Weave::Profiles::DataManagement_Current::CircularEventBuffer::mEventIdCounter

mExternalEventsList

ExternalEvents nl::Weave::Profiles::DataManagement_Current::CircularEventBuffer::mExternalEventsList[1]

mFirstEventID

event_id_t nl::Weave::Profiles::DataManagement_Current::CircularEventBuffer::mFirstEventID

mFirstEventTimestamp

timestamp_t nl::Weave::Profiles::DataManagement_Current::CircularEventBuffer::mFirstEventTimestamp

mFirstEventUTCTimestamp

utc_timestamp_t nl::Weave::Profiles::DataManagement_Current::CircularEventBuffer::mFirstEventUTCTimestamp

mImportance

ImportanceType nl::Weave::Profiles::DataManagement_Current::CircularEventBuffer::mImportance

mLastEventID

event_id_t nl::Weave::Profiles::DataManagement_Current::CircularEventBuffer::mLastEventID

mLastEventTimestamp

timestamp_t nl::Weave::Profiles::DataManagement_Current::CircularEventBuffer::mLastEventTimestamp

mLastEventUTCTimestamp

utc_timestamp_t nl::Weave::Profiles::DataManagement_Current::CircularEventBuffer::mLastEventUTCTimestamp

mNext

CircularEventBuffer * nl::Weave::Profiles::DataManagement_Current::CircularEventBuffer::mNext

mNonPersistedCounter

nl::Weave::MonotonicallyIncreasingCounter nl::Weave::Profiles::DataManagement_Current::CircularEventBuffer::mNonPersistedCounter

mPrev

CircularEventBuffer * nl::Weave::Profiles::DataManagement_Current::CircularEventBuffer::mPrev

mUTCInitialized

bool nl::Weave::Profiles::DataManagement_Current::CircularEventBuffer::mUTCInitialized

Public functions

AddEvent

void nl::Weave::Profiles::DataManagement_Current::CircularEventBuffer::AddEvent(
  timestamp_t inEventTimestamp
)

Given a timestamp of an event, compute the delta time to store in the log.

Details
Parameters
inEventTimestamp
The event timestamp.
Returns
int32_t Time delta to encode for the event.

AddEventUTC

void nl::Weave::Profiles::DataManagement_Current::CircularEventBuffer::AddEventUTC(
  utc_timestamp_t inEventTimestamp
)

Given a timestamp of an event, compute the delta utc time to store in the log.

Details
Parameters
inEventTimestamp
The event's utc timestamp
Returns
int64_t Time delta to encode for the event.

CircularEventBuffer

 nl::Weave::Profiles::DataManagement_Current::CircularEventBuffer::CircularEventBuffer(
  uint8_t *inBuffer,
  size_t inBufferLength,
  CircularEventBuffer *inPrev,
  CircularEventBuffer *inNext
)

A constructor for the CircularEventBuffer (internal API).

Details
Parameters
[in] inBuffer
The actual storage to use for event storage.
[in] inBufferLength
The length of the inBuffer in bytes.
[in] inPrev
The pointer to CircularEventBuffer storing events of lesser priority.
[in] inNext
The pointer to CircularEventBuffer storing events of greater priority.
Returns

GetExternalEventsFromEventID

ExternalEvents * nl::Weave::Profiles::DataManagement_Current::CircularEventBuffer::GetExternalEventsFromEventID(
  event_id_t aEventID
)

A function to get a pointer to the ExternalEvent storing aEventID.

Details
Returns
NULL if aEventID is not externally stored.

GetNextAvailableExternalEvents

ExternalEvents * nl::Weave::Profiles::DataManagement_Current::CircularEventBuffer::GetNextAvailableExternalEvents(
  void
)

A function to get a pointer to the next available ExternalEvent.

A NULL pointer assigned to an ExternalEvents.mFetchEventsFunct is an indication that the callback slot is unused.

Details
Returns
NULL if all callbacks are in use.

IsFinalDestinationForImportance

bool nl::Weave::Profiles::DataManagement_Current::CircularEventBuffer::IsFinalDestinationForImportance(
  ImportanceType inImportance
) const 

A helper function that determines whether the event of specified importance is dropped from this buffer.

Details
Parameters
[in] inImportance
Importance of the event.
Return Values
true
The event will be dropped from this buffer as a result of queue overflow.
false
The event will be bumped to the next queue.

RegisterExternalEventsCallback

WEAVE_ERROR nl::Weave::Profiles::DataManagement_Current::CircularEventBuffer::RegisterExternalEventsCallback(
  FetchExternalEventsFunct aFetchCallback,
  NotifyExternalEventsDeliveredFunct aNotifyCallback,
  size_t aNumEvents,
  ExternalEvents **aExternalEventsPtr
)

This function registers a set of event IDs and a function callback for externally stored events.

Details
Parameters
[in] aFetchCallback
The function callback for unloading events.
[in] aNotifyCallback
The function callback to notify about offload
[in] aNumEvents
Number of events to register.
[out] aExternalEventsPtr
When non-NULL, on successful return it will contain the pointer to the ExternalEvents object
Returns
WEAVE_ERROR_INVALID_ARGUMENT Null function callback or no events to register.
Returns
WEAVE_ERROR_NO_MEMORY If all callbacks are in use.
Returns
WEAVE_NO_ERROR Otherwise.

RemoveEvent

void nl::Weave::Profiles::DataManagement_Current::CircularEventBuffer::RemoveEvent(
  void
)

UnregisterExternalEventsCallback

void nl::Weave::Profiles::DataManagement_Current::CircularEventBuffer::UnregisterExternalEventsCallback(
  ExternalEvents *ioPtr
)

This function unregisters a callback.

Once the callback is unregistered, if the event IDs are fetched by a subscriber, the event logging framework will return an empty buffer. If the event IDs no longer need to be fetched, the ExternalEvents callback can be reused.

Details
Parameters
inPtr
Pointer to ExternalEvents struct to unregister.

VendEventID

event_id_t nl::Weave::Profiles::DataManagement_Current::CircularEventBuffer::VendEventID(
  void
)

Allocate a new event ID based on the event importance, and advance the counter if we have one.

Details
Returns
event_id_t Event ID for this importance.

Public static functions

GetNextBufferFunct

WEAVE_ERROR nl::Weave::Profiles::DataManagement_Current::CircularEventBuffer::GetNextBufferFunct(
  nl::Weave::TLV::TLVReader & ioReader,
  uintptr_t & inBufHandle,
  const uint8_t *& outBufStart,
  uint32_t & outBufLen
)