AceTime
1.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.
|
Base interface for ZoneProcessor classes. More...
#include <ZoneProcessor.h>
Public Member Functions | |
uint8_t | getType () const |
Return the kTypeXxx of the current instance. More... | |
virtual const void * | getZoneInfo () const =0 |
Return the opaque zoneInfo. More... | |
virtual uint32_t | getZoneId () const =0 |
Return the unique stable zoneId. More... | |
virtual TimeOffset | getUtcOffset (acetime_t epochSeconds) const =0 |
Return the total UTC offset at epochSeconds, including DST offset. More... | |
virtual TimeOffset | getDeltaOffset (acetime_t epochSeconds) const =0 |
Return the DST delta offset at epochSeconds. More... | |
virtual const char * | getAbbrev (acetime_t epochSeconds) const =0 |
Return the time zone abbreviation at epochSeconds. More... | |
virtual OffsetDateTime | getOffsetDateTime (const LocalDateTime &ldt) const =0 |
Return the best estimate of the OffsetDateTime at the given LocalDateTime for the timezone of the current ZoneProcessor. More... | |
virtual void | printTo (Print &printer) const =0 |
Print a human-readable identifier (e.g. More... | |
virtual void | printShortTo (Print &printer) const =0 |
Print a short human-readable identifier (e.g. More... | |
Static Public Attributes | |
static const uint8_t | kTypeBasic = 2 |
Indicate BasicZoneProcessor. More... | |
static const uint8_t | kTypeExtended = 3 |
Indicate ExtendedZoneProcessor. More... | |
Protected Member Functions | |
ZoneProcessor (const ZoneProcessor &)=delete | |
ZoneProcessor & | operator= (const ZoneProcessor &)=delete |
ZoneProcessor (uint8_t type) | |
Constructor. More... | |
virtual bool | equals (const ZoneProcessor &other) const =0 |
Return true if equal. More... | |
virtual void | setZoneInfo (const void *zoneInfo)=0 |
Set the opaque zoneInfo. More... | |
Protected Attributes | |
uint8_t | mType |
Friends | |
class | TimeZone |
template<uint8_t SIZE, uint8_t TYPE, typename ZS , typename ZI , typename ZIB > | |
class | ZoneProcessorCacheImpl |
bool | operator== (const ZoneProcessor &a, const ZoneProcessor &b) |
Base interface for ZoneProcessor classes.
There were 2 options for implmenting the various concrete implementations of ZoneProcessors:
1) Implement only a single getType() method to distinguish the different runtime types of the object. Then use this type information in the TimeZone class to downcast the ZoneProcessor pointer to the correct subclass, and call the correct methods.
2) Fully implement a polymorphic class hierarchy, lifting various common methods (getUtcOffset(), getDeltaOffset(), getAbbrev()) into this interface as virtual methods, then add a virtual equals() method to implement the operator==().
The problem with Option 1 is that the code for both subclasses would be compiled into the program, even if the application used only one of the subclasses. Instead I use Option 2, using a fully polymorphic class hierarchy, adding 3-4 virtual methods. When a program uses only a single subclass, only that particular subclass is included into the program. Unfortunately, this comes at the cost of forcing programs to use the virtual dispatch at runtime for some of the often-used methods.
Definition at line 45 of file ZoneProcessor.h.
|
inlineprotected |
Constructor.
Definition at line 122 of file ZoneProcessor.h.
|
protectedpure virtual |
Return true if equal.
|
pure virtual |
Return the time zone abbreviation at epochSeconds.
Returns an empty string ("") if an error occurs. The returned pointer points to a char buffer that could get overriden by subsequent method calls to this object. The pointer must not be stored permanently, it should be used as soon as possible (e.g. printed out).
This is an experimental method that has not been tested thoroughly. Use with caution.
Implemented in ace_time::ExtendedZoneProcessor, and ace_time::BasicZoneProcessor.
|
pure virtual |
Return the DST delta offset at epochSeconds.
This is an experimental method that has not been tested thoroughly. Use with caution. Returns TimeOffset::forError() if an error occurs.
Implemented in ace_time::ExtendedZoneProcessor, and ace_time::BasicZoneProcessor.
|
pure virtual |
Return the best estimate of the OffsetDateTime at the given LocalDateTime for the timezone of the current ZoneProcessor.
Returns OffsetDateTime::forError() if an error occurs, for example, if the LocalDateTime is outside of the support date range of the underlying ZoneInfo files.
Implemented in ace_time::ExtendedZoneProcessor, and ace_time::BasicZoneProcessor.
|
inline |
Return the kTypeXxx of the current instance.
Definition at line 60 of file ZoneProcessor.h.
|
pure virtual |
Return the total UTC offset at epochSeconds, including DST offset.
Returns TimeOffset::forError() if an error occurs.
Implemented in ace_time::ExtendedZoneProcessor, and ace_time::BasicZoneProcessor.
|
pure virtual |
Return the unique stable zoneId.
Implemented in ace_time::ExtendedZoneProcessor, and ace_time::BasicZoneProcessor.
|
pure virtual |
Return the opaque zoneInfo.
Implemented in ace_time::ExtendedZoneProcessor, and ace_time::BasicZoneProcessor.
|
pure virtual |
Print a short human-readable identifier (e.g.
"Los_Angeles")
Implemented in ace_time::ExtendedZoneProcessor, and ace_time::BasicZoneProcessor.
|
pure virtual |
Print a human-readable identifier (e.g.
"America/Los_Angeles").
Implemented in ace_time::ExtendedZoneProcessor, and ace_time::BasicZoneProcessor.
|
protectedpure virtual |
Set the opaque zoneInfo.
|
static |
Indicate BasicZoneProcessor.
Must not be TimeZone::kTypeError (0) or TimeZone::kTypeManual (1).
Definition at line 51 of file ZoneProcessor.h.
|
static |
Indicate ExtendedZoneProcessor.
Must not be TimeZone::kTypeError (0) or TimeZone::kTypeManual (1).
Definition at line 57 of file ZoneProcessor.h.