AceTime  0.6.1
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.
Public Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes | Friends | List of all members
ace_time::ZoneRegistrar< ZI, ZRB, ZIB, STRCMP_P, STRCMP_PP > Class Template Reference

Class that allows looking up the ZoneInfo (ZI) from its TZDB identifier (e.g. More...

#include <ZoneRegistrar.h>

Public Member Functions

 ZoneRegistrar (uint16_t registrySize, const ZI *const *zoneRegistry)
 Constructor. More...
 
uint16_t registrySize () const
 Return the number of zones. More...
 
bool isSorted () const
 Return true if zoneRegistry is sorted, and eligible to use a binary search.
 
const ZI * getZoneInfoForIndex (uint16_t i) const
 
const ZI * getZoneInfoForName (const char *name) const
 Return the ZoneInfo corresponding to the given zone name. More...
 
const ZI * getZoneInfoForId (uint32_t zoneId) const
 

Static Protected Member Functions

static bool isSorted (const ZI *const *zr, uint16_t registrySize)
 
static const ZI * linearSearch (const ZI *const *zr, uint16_t registrySize, const char *name)
 
static const ZI * binarySearch (const ZI *const *zr, uint16_t registrySize, const char *name)
 
static const ZI * linearSearchUsingId (const ZI *const *zr, uint16_t registrySize, uint32_t zoneId)
 

Protected Attributes

uint16_t const mRegistrySize
 
const ZI *const *const mZoneRegistry
 
bool const mIsSorted
 

Static Protected Attributes

static const uint8_t kBinarySearchThreshold = 6
 Use binarySearch() if registrySize >= threshold. More...
 

Friends

class ::BasicZoneRegistrarTest_Sorted_isSorted
 
class ::BasicZoneRegistrarTest_Sorted_linearSearch
 
class ::BasicZoneRegistrarTest_Sorted_linearSearch_not_found
 
class ::BasicZoneRegistrarTest_Sorted_binarySearch
 
class ::BasicZoneRegistrarTest_Sorted_binarySearch_not_found
 
class ::BasicZoneRegistrarTest_Unsorted_isSorted
 
class ::BasicZoneRegistrarTest_Unsorted_linearSearch
 

Detailed Description

template<typename ZI, typename ZRB, typename ZIB, strcmp_t STRCMP_P, strcmp_t STRCMP_PP>
class ace_time::ZoneRegistrar< ZI, ZRB, ZIB, STRCMP_P, STRCMP_PP >

Class that allows looking up the ZoneInfo (ZI) from its TZDB identifier (e.g.

"America/Los_Angeles"), or index, or zoneId (hash from its name).

Template Parameters
ZIZoneInfo type (e.g. basic::ZoneInfo)
ZRBZoneRegistryBroker type (e.g. basic::ZoneRegistryBroker)
ZIBZoneInfoBroker type (e.g. basic::ZoneInfoBroker)
STRCMP_Pa function that compares a normal string to flash string (e.g strcmp_P())
STRCMP_PPa function that compares 2 flash strings (must be custom written)

Definition at line 42 of file ZoneRegistrar.h.

Constructor & Destructor Documentation

◆ ZoneRegistrar()

template<typename ZI , typename ZRB , typename ZIB , strcmp_t STRCMP_P, strcmp_t STRCMP_PP>
ace_time::ZoneRegistrar< ZI, ZRB, ZIB, STRCMP_P, STRCMP_PP >::ZoneRegistrar ( uint16_t  registrySize,
const ZI *const *  zoneRegistry 
)
inline

Constructor.

Definition at line 45 of file ZoneRegistrar.h.

Member Function Documentation

◆ getZoneInfoForName()

template<typename ZI , typename ZRB , typename ZIB , strcmp_t STRCMP_P, strcmp_t STRCMP_PP>
const ZI* ace_time::ZoneRegistrar< ZI, ZRB, ZIB, STRCMP_P, STRCMP_PP >::getZoneInfoForName ( const char *  name) const
inline

Return the ZoneInfo corresponding to the given zone name.

Return nullptr if not found.

Definition at line 68 of file ZoneRegistrar.h.

◆ registrySize()

template<typename ZI , typename ZRB , typename ZIB , strcmp_t STRCMP_P, strcmp_t STRCMP_PP>
uint16_t ace_time::ZoneRegistrar< ZI, ZRB, ZIB, STRCMP_P, STRCMP_PP >::registrySize ( ) const
inline

Return the number of zones.

Definition at line 51 of file ZoneRegistrar.h.

Member Data Documentation

◆ kBinarySearchThreshold

template<typename ZI , typename ZRB , typename ZIB , strcmp_t STRCMP_P, strcmp_t STRCMP_PP>
const uint8_t ace_time::ZoneRegistrar< ZI, ZRB, ZIB, STRCMP_P, STRCMP_PP >::kBinarySearchThreshold = 6
staticprotected

Use binarySearch() if registrySize >= threshold.

Definition at line 91 of file ZoneRegistrar.h.


The documentation for this class was generated from the following file: