AceTime
1.8.0
Date and time classes for Arduino that support timezones from the TZ Database, and a system clock that can synchronize from an NTP server or an RTC chip.
|
Class that allows looking up the ZoneInfo (ZI) from its TZDB identifier (e.g. More...
#include <ZoneRegistrar.h>
Public Member Functions | |
ZoneRegistrarTemplate (uint16_t zoneRegistrySize, const ZI *const *zoneRegistry) | |
Constructor. | |
uint16_t | zoneRegistrySize () const |
Return the number of zones and (fat) links. | |
const ZI * | getZoneInfoForIndex (uint16_t i) const |
Return the ZoneInfo at index i. More... | |
const ZI * | getZoneInfoForName (const char *name) const |
Return the ZoneInfo corresponding to the given zone name. More... | |
const ZI * | getZoneInfoForId (uint32_t zoneId) const |
Return the ZoneInfo using the zoneId. More... | |
uint16_t | findIndexForName (const char *name) const |
Find the index for zone name. More... | |
uint16_t | findIndexForId (uint32_t zoneId) const |
Find the index for zone id. More... | |
Static Public Attributes | |
static const uint16_t | kInvalidIndex = 0xffff |
Invalid index to indicate error or not found. | |
Protected Member Functions | |
friend | void ::runIndexForZoneIdBinary () |
friend | void ::runIndexForZoneIdLinear () |
uint16_t | findIndexForIdLinear (uint32_t zoneId) const |
Exposed only for benchmarking purposes. | |
uint16_t | findIndexForIdBinary (uint32_t zoneId) const |
Exposed only for benchmarking purposes. | |
Static Protected Member Functions | |
static bool | isSorted (const ZI *const *registry, uint16_t registrySize) |
Determine if the given zone registry is sorted by id. | |
static uint16_t | linearSearchById (const ZI *const *registry, uint16_t registrySize, uint32_t zoneId) |
Find the registry index corresponding to zoneId using linear search. More... | |
static uint16_t | binarySearchById (const ZI *const *registry, uint16_t registrySize, uint32_t zoneId) |
Find the registry index corresponding to zoneId using a binary search. More... | |
Static Protected Attributes | |
static const uint8_t | kBinarySearchThreshold = 8 |
Use binarySearchById() if zoneRegistrySize >= threshold. | |
Class that allows looking up the ZoneInfo (ZI) from its TZDB identifier (e.g.
"America/Los_Angeles"), zoneId (hash from its name), or the index in the zone registry.
ZI | ZoneInfo type (e.g. basic::ZoneInfo) |
ZIB | ZoneInfoBroker type (e.g. basic::ZoneInfoBroker) |
ZRGB | ZoneRegistryBroker type (e.g. basic::ZoneRegistryBroker) |
Definition at line 44 of file ZoneRegistrar.h.
|
inlinestaticprotected |
Find the registry index corresponding to zoneId using a binary search.
Returns kInvalidIndex if not found.
The largest registrySize is UINT16_MAX so the largest valid index is UINT16_MAX - 1. This allows us to set kInvalidIndex to UINT16_MAX to indicate "Not Found".
Definition at line 176 of file ZoneRegistrar.h.
|
inline |
Find the index for zone id.
Return kInvalidIndex if not found.
Definition at line 103 of file ZoneRegistrar.h.
|
inline |
Find the index for zone name.
Return kInvalidIndex if not found.
Definition at line 87 of file ZoneRegistrar.h.
|
inline |
Return the ZoneInfo using the zoneId.
Return nullptr if not found.
Definition at line 80 of file ZoneRegistrar.h.
|
inline |
Return the ZoneInfo at index i.
Return nullptr if i is out of range.
Definition at line 63 of file ZoneRegistrar.h.
|
inline |
Return the ZoneInfo corresponding to the given zone name.
Return nullptr if not found.
Definition at line 73 of file ZoneRegistrar.h.
|
inlinestaticprotected |
Find the registry index corresponding to zoneId using linear search.
Returns kInvalidIndex if not found.
Definition at line 143 of file ZoneRegistrar.h.