AceTime
1.7.2
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 "internal/LinkRegistrar.h"
11 #include "ZoneProcessorCache.h"
12 #include "TimeZoneData.h"
100 case TimeZoneData::kTypeError:
102 case TimeZoneData::kTypeManual:
153 typename ZI,
typename ZRR,
154 typename LE,
typename LRR,
155 typename ZP,
typename ZPC
160 const ZI* zoneInfo = mZoneRegistrar.getZoneInfoForName(name);
165 const ZI* zoneInfo = mZoneRegistrar.getZoneInfoForId(
id);
168 if (zoneInfo ==
nullptr) {
169 const LE* linkEntry = mLinkRegistrar.getLinkEntryForId(
id);
171 uint32_t targetZoneId = linkEntry->zoneId;
172 zoneInfo = mZoneRegistrar.getZoneInfoForId(targetZoneId);
179 const ZI* zoneInfo = mZoneRegistrar.getZoneInfoForIndex(index);
185 case TimeZoneData::kTypeError:
187 case TimeZoneData::kTypeManual:
191 case TimeZoneData::kTypeZoneId:
200 return mZoneRegistrar.findIndexForName(name);
204 return mZoneRegistrar.findIndexForId(
id);
208 return mZoneRegistrar.zoneRegistrySize();
212 return mLinkRegistrar.linkRegistrySize();
224 ZP* processor = (ZP*) mZoneProcessorCache.getZoneProcessor(
225 (uintptr_t) zoneInfo);
240 const ZI*
const* zoneRegistry,
242 const LE* linkRegistry
246 mZoneProcessorCache() {}
253 const ZRR mZoneRegistrar;
254 const LRR mLinkRegistrar;
255 ZPC mZoneProcessorCache;
265 template<u
int16_t SIZE>
268 basic::ZoneRegistrar,
270 basic::LinkRegistrar,
272 BasicZoneProcessorCache<SIZE>
278 const basic::ZoneInfo*
const* zoneRegistry,
280 const basic::LinkEntry* linkRegistry =
nullptr
304 template<u
int16_t SIZE>
307 extended::ZoneRegistrar,
309 extended::LinkRegistrar,
310 ExtendedZoneProcessor,
311 ExtendedZoneProcessorCache<SIZE>
317 const extended::ZoneInfo*
const* zoneRegistry,
319 const extended::LinkEntry* linkRegistry =
nullptr
347 template<u
int8_t SIZE>
357 template<u
int8_t SIZE>
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.
TimeZone createForZoneIndex(uint16_t index) override
Create a TimeZone for the given index in the ZoneInfo registry that was used to create this ZoneManag...
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.
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.
Concrete template instantiation of LinkRegistrarTemplate for extended::LinkEntry.
TimeZone createForZoneName(const char *name) override
Create a TimeZone for the given zone name (e.g.
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.
uint16_t linkRegistrySize() const override
Return the number of elements in the (thin) Link registry.
virtual TimeZone createForZoneId(uint32_t id)=0
Create a TimeZone for the given 32-bit zoneId.
Concrete template instantiation of ZoneRegistrarTemplate for extended::ZoneInfo, which can be used wi...
virtual uint16_t linkRegistrySize() const =0
Return the number of elements in the (thin) Link registry.
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.
TimeZone createForTimeZoneData(const TimeZoneData &d) override
Create a TimeZone from the TimeZoneData created by TimeZone::toTimeZoneData().
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...
TimeZone createForZoneInfo(const ZI *zoneInfo)
Create a TimeZone from an explicit ZoneInfo reference.
uint16_t zoneRegistrySize() const override
Return the number of elements in the Zone (and fat Link) registry.
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.
Concrete template instantiation of LinkRegistrarTemplate for basic::LinkEntry.
uint16_t indexForZoneName(const char *name) const override
Find the registry index for the given time zone name.
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...
ZoneManagerImpl(uint16_t zoneRegistrySize, const ZI *const *zoneRegistry, uint16_t linkRegistrySize, const LE *linkRegistry)
Constructor.
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 id) const override
Find the registry index for the given time zone id.
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.
TimeZone createForZoneId(uint32_t id) override
Create a TimeZone for the given 32-bit zoneId.
uint16_t linkRegistrySize() const override
Return the number of elements in the (thin) Link registry.