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.
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
ace_time::ZoneProcessor Class Referenceabstract

Base interface for ZoneProcessor classes. More...

#include <ZoneProcessor.h>

Inheritance diagram for ace_time::ZoneProcessor:
Inheritance graph
[legend]

Public Member Functions

uint8_t getType () const
 Return the kTypeXxx of the current instance.
 
virtual uint32_t getZoneId () const =0
 Return the unique stable zoneId.
 
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 printNameTo (Print &printer) const =0
 Print a human-readable identifier (e.g. More...
 
virtual void printShortNameTo (Print &printer) const =0
 Print a short human-readable identifier (e.g. More...
 
virtual void setZoneKey (uintptr_t zoneKey)=0
 Set the opaque zoneKey of this object to a new value, reseting any internally cached information. More...
 
virtual bool equalsZoneKey (uintptr_t zoneKey) const =0
 Return true if ZoneProcessor is associated with the given opaque zoneKey. More...
 

Protected Member Functions

 ZoneProcessor (const ZoneProcessor &)=delete
 
ZoneProcessoroperator= (const ZoneProcessor &)=delete
 
 ZoneProcessor (uint8_t type)
 Constructor.
 
virtual bool equals (const ZoneProcessor &other) const =0
 Return true if equal.
 

Protected Attributes

const uint8_t mType
 

Friends

bool operator== (const ZoneProcessor &a, const ZoneProcessor &b)
 

Detailed Description

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 41 of file ZoneProcessor.h.

Member Function Documentation

◆ equalsZoneKey()

virtual bool ace_time::ZoneProcessor::equalsZoneKey ( uintptr_t  zoneKey) const
pure virtual

◆ getAbbrev()

virtual const char* ace_time::ZoneProcessor::getAbbrev ( acetime_t  epochSeconds) const
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::ExtendedZoneProcessorTemplate< BF, ZIB, ZEB, ZPB, ZRB >, ace_time::ExtendedZoneProcessorTemplate< extended::BrokerFactory, extended::ZoneInfoBroker, extended::ZoneEraBroker, extended::ZonePolicyBroker, extended::ZoneRuleBroker >, ace_time::BasicZoneProcessorTemplate< BF, ZIB, ZEB, ZPB, ZRB >, and ace_time::BasicZoneProcessorTemplate< basic::BrokerFactory, basic::ZoneInfoBroker, basic::ZoneEraBroker, basic::ZonePolicyBroker, basic::ZoneRuleBroker >.

◆ getDeltaOffset()

virtual TimeOffset ace_time::ZoneProcessor::getDeltaOffset ( acetime_t  epochSeconds) const
pure virtual

◆ getOffsetDateTime()

virtual OffsetDateTime ace_time::ZoneProcessor::getOffsetDateTime ( const LocalDateTime ldt) const
pure virtual

◆ getUtcOffset()

virtual TimeOffset ace_time::ZoneProcessor::getUtcOffset ( acetime_t  epochSeconds) const
pure virtual

◆ printNameTo()

virtual void ace_time::ZoneProcessor::printNameTo ( Print &  printer) const
pure virtual

◆ printShortNameTo()

virtual void ace_time::ZoneProcessor::printShortNameTo ( Print &  printer) const
pure virtual

◆ setZoneKey()

virtual void ace_time::ZoneProcessor::setZoneKey ( uintptr_t  zoneKey)
pure virtual

Set the opaque zoneKey of this object to a new value, reseting any internally cached information.

Normally a ZoneProcessor object is associated with a single TimeZone. However, the ZoneProcessorCache will sometimes "take over" a ZoneProcessor from another TimeZone using this method. The other TimeZone will take back control of the ZoneProcessor if needed. To avoid bouncing the ownership of this object repeatedly, the ZoneProcessorCache should allocate enough ZoneProcessors to handle the usage pattern.

This method should be considered to be private, to be used only by the TimeZone and ZoneProcessorCache classes. I had to make it public because it got too ugly to maintain the friend list in C++.

Implemented in ace_time::ExtendedZoneProcessorTemplate< BF, ZIB, ZEB, ZPB, ZRB >, ace_time::ExtendedZoneProcessorTemplate< extended::BrokerFactory, extended::ZoneInfoBroker, extended::ZoneEraBroker, extended::ZonePolicyBroker, extended::ZoneRuleBroker >, ace_time::BasicZoneProcessorTemplate< BF, ZIB, ZEB, ZPB, ZRB >, and ace_time::BasicZoneProcessorTemplate< basic::BrokerFactory, basic::ZoneInfoBroker, basic::ZoneEraBroker, basic::ZonePolicyBroker, basic::ZoneRuleBroker >.


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