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.
|
6 #ifndef ACE_TIME_ZONE_MANAGER_H
7 #define ACE_TIME_ZONE_MANAGER_H
9 #include "internal/ZoneRegistrar.h"
10 #include "ZoneProcessorCache.h"
11 #include "TimeZoneData.h"
94 case TimeZoneData::kTypeError:
96 case TimeZoneData::kTypeManual:
141 typename ZI,
typename ZRR,
142 typename ZP,
typename ZPC
147 const ZI* zoneInfo = mZoneRegistrar.getZoneInfoForName(name);
152 const ZI* zoneInfo = mZoneRegistrar.getZoneInfoForId(
id);
157 const ZI* zoneInfo = mZoneRegistrar.getZoneInfoForIndex(index);
163 case TimeZoneData::kTypeError:
165 case TimeZoneData::kTypeManual:
169 case TimeZoneData::kTypeZoneId:
178 return mZoneRegistrar.findIndexForName(name);
182 return mZoneRegistrar.findIndexForId(
id);
186 return mZoneRegistrar.zoneRegistrySize();
198 ZP* processor = mZoneProcessorCache.getZoneProcessor(
199 (uintptr_t) zoneInfo);
212 const ZI*
const* zoneRegistry
215 mZoneProcessorCache() {}
221 const ZRR mZoneRegistrar;
222 ZPC mZoneProcessorCache;
232 template<u
int16_t SIZE>
235 basic::ZoneRegistrar,
237 BasicZoneProcessorCache<SIZE>
243 const basic::ZoneInfo*
const* zoneRegistry
261 const basic::ZoneInfo* zoneInfo =
263 if (! zoneInfo)
return nullptr;
264 return this->mZoneProcessorCache.getZoneProcessor((uintptr_t) zoneInfo);
274 template<u
int16_t SIZE>
277 extended::ZoneRegistrar,
278 ExtendedZoneProcessor,
279 ExtendedZoneProcessorCache<SIZE>
285 const extended::ZoneInfo*
const* zoneRegistry
303 const extended::ZoneInfo* zoneInfo =
305 if (! zoneInfo)
return nullptr;
306 return this->mZoneProcessorCache.getZoneProcessor((uintptr_t) zoneInfo);
320 template<u
int8_t SIZE>
321 using BasicZoneManager = ZoneManagerImpl<
323 basic::ZoneRegistrar,
325 BasicZoneProcessorCache<SIZE>
328 template<u
int8_t SIZE>
329 using ExtendedZoneManager = ZoneManagerImpl<
331 extended::ZoneRegistrar,
332 ExtendedZoneProcessor,
333 ExtendedZoneProcessorCache<SIZE>
ExtendedZoneProcessor * getZoneProcessor(const char *name)
Return the ExtendedZoneProcessor for given zone name.
static TimeZone forZoneInfo(const basic::ZoneInfo *zoneInfo, BasicZoneProcessor *zoneProcessor)
Convenience factory method to create from a zoneInfo and an associated BasicZoneProcessor.
TimeZone createForZoneId(uint32_t) override
Create a TimeZone for the given 32-bit zoneId.
BasicZoneProcessor * getZoneProcessor(const char *name)
Return the BasicZoneProcessor for given zone name.
A ZoneManager that implements only createForTimeZoneData() to create TimeZones of type kTypeManual,...
uint16_t indexForZoneName(const char *) const override
Find the registry index for the given time zone name.
TimeZone createForZoneName(const char *name) override
Create a TimeZone for the given zone name (e.g.
Concrete template instantiation of ZoneRegistrarTemplate for basic::ZoneInfo, which can be used with ...
static TimeZone forError()
Return a TimeZone representing an error condition.
virtual uint16_t zoneRegistrySize() const =0
Return the number of elements in the Zone and Fat Link registry.
virtual uint16_t indexForZoneName(const char *name) const =0
Find the registry index for the given time zone name.
TimeZone createForZoneId(uint32_t id) override
Create a TimeZone for the given 32-bit zoneId.
ZoneManagerImpl(uint16_t zoneRegistrySize, const ZI *const *zoneRegistry)
Constructor.
TimeZone createForZoneInfo(const ZI *zoneInfo)
Create a TimeZone from an explicit ZoneInfo reference.
TimeZone createForTimeZoneData(const TimeZoneData &d) override
Create a TimeZone from the TimeZoneData created by TimeZone::toTimeZoneData().
A specific implementation of ExtendedZoneProcessorTemplate that uses ZoneXxxBrokers which read from z...
uint16_t zoneRegistrySize() const override
Return the number of elements in the Zone and Fat Link registry.
virtual TimeZone createForZoneId(uint32_t id)=0
Create a TimeZone for the given 32-bit zoneId.
uint16_t zoneRegistrySize() const override
Return the number of elements in the Zone and Fat Link registry.
Concrete template instantiation of ZoneRegistrarTemplate for extended::ZoneInfo, which can be used wi...
An implementation of the ZoneManager which uses a registry of basic::ZoneInfo records.
static const uint16_t kInvalidIndex
Registry index which is not valid.
static TimeOffset forMinutes(int16_t minutes)
Create TimeOffset from minutes from 00:00.
virtual uint16_t indexForZoneId(uint32_t id) const =0
Find the registry index for the given time zone id.
virtual TimeZone createForZoneIndex(uint16_t index)=0
Create a TimeZone for the given index in the ZoneInfo registry that was used to create this ZoneManag...
Common interface to the BasicZoneManager and ExtendedZoneManager so that a single interface can be pa...
const ZI * getZoneInfoForName(const char *name) const
Return the ZoneInfo corresponding to the given zone name.
Data structure that captures the internal state of a TimeZone object with enough information so that ...
TimeZone createForZoneIndex(uint16_t) override
Create a TimeZone for the given index in the ZoneInfo registry that was used to create this ZoneManag...
TimeZone createForTimeZoneData(const TimeZoneData &d) override
Create a TimeZone from the TimeZoneData created by TimeZone::toTimeZoneData().
An implementation of the ZoneManager which uses a registry of extended::ZoneInfo records.
TimeZone createForZoneIndex(uint16_t index) override
Create a TimeZone for the given index in the ZoneInfo registry that was used to create this ZoneManag...
uint16_t indexForZoneId(uint32_t id) const override
Find the registry index for the given time zone id.
A templatized implementation of ZoneManager that binds the ZoneRegistrar with the corresponding (Basi...
Class that describes a time zone.
static TimeZone forTimeOffset(TimeOffset stdOffset, TimeOffset dstOffset=TimeOffset())
Factory method to create from a UTC offset and an optional DST offset.
A specific implementation of BasicZoneProcessorTemplate that uses ZoneXxxBrokers which read from zone...
uint16_t indexForZoneName(const char *name) const override
Find the registry index for the given time zone name.
uint32_t zoneId
Both TimeZone::kTypeBasic and TimeZone::kTypeExtended are mapped to a TimeZoneData::kTypeZoneId.
virtual TimeZone createForTimeZoneData(const TimeZoneData &d)=0
Create a TimeZone from the TimeZoneData created by TimeZone::toTimeZoneData().
uint16_t indexForZoneId(uint32_t) const override
Find the registry index for the given time zone id.
virtual TimeZone createForZoneName(const char *name)=0
Create a TimeZone for the given zone name (e.g.
TimeZone createForZoneName(const char *) override
Create a TimeZone for the given zone name (e.g.