hueplusplus  1.0.0
Public Types | Public Member Functions | Static Public Member Functions | List of all members
hueplusplus::time::TimePattern Class Reference

Holds different time representations. More...

#include <hueplusplus/TimePattern.h>

+ Collaboration diagram for hueplusplus::time::TimePattern:

Public Types

enum  Type {
  Type::undefined, Type::absolute, Type::recurring, Type::interval,
  Type::timer
}
 Currently active type. More...
 

Public Member Functions

 TimePattern ()
 Create empty TimePattern. More...
 
 ~TimePattern ()
 Destructor for union. More...
 
 TimePattern (const AbsoluteVariedTime &absolute)
 Create TimePattern from AbsoluteVariedTime. More...
 
 TimePattern (const RecurringTime &recurring)
 Create TimePattern from RecurringTime. More...
 
 TimePattern (const TimeInterval &interval)
 Create TimePattern from TimeInterval. More...
 
 TimePattern (const Timer &timer)
 Create TimePattern from Timer. More...
 
 TimePattern (const TimePattern &other)
 Copy constructor for union. More...
 
TimePatternoperator= (const TimePattern &other)
 Copy assignment for union. More...
 
Type getType () const
 Get currently active type. More...
 
AbsoluteVariedTime asAbsolute () const
 Get contained absolute time. More...
 
RecurringTime asRecurring () const
 Get contained recurring time. More...
 
TimeInterval asInterval () const
 Get contained time interval. More...
 
Timer asTimer () const
 Get contained timer. More...
 
std::string toString () const
 Get formatted string of the contained value as expected by Hue API. More...
 

Static Public Member Functions

static TimePattern parse (const std::string &s)
 Parses TimePattern from formatted string as returned by Hue API. More...
 

Detailed Description

Holds different time representations.

Holds either AbsoluteTime, RecurringTime, TimeInterval, Timer or an undefined state. TimePattern is used to specify the occurrance of Schedules.

Member Enumeration Documentation

◆ Type

Currently active type.

Enumerator
undefined 

No active type.

absolute 

Active type is AbsoluteVariedTime.

recurring 

Active type is RecurringTime.

interval 

Active type is TimeInterval.

timer 

Active type is Timer.

Constructor & Destructor Documentation

◆ TimePattern() [1/6]

hueplusplus::time::TimePattern::TimePattern ( )

Create empty TimePattern.

◆ ~TimePattern()

hueplusplus::time::TimePattern::~TimePattern ( )

Destructor for union.

◆ TimePattern() [2/6]

hueplusplus::time::TimePattern::TimePattern ( const AbsoluteVariedTime absolute)
explicit

◆ TimePattern() [3/6]

hueplusplus::time::TimePattern::TimePattern ( const RecurringTime recurring)
explicit

Create TimePattern from RecurringTime.

◆ TimePattern() [4/6]

hueplusplus::time::TimePattern::TimePattern ( const TimeInterval interval)
explicit

Create TimePattern from TimeInterval.

◆ TimePattern() [5/6]

hueplusplus::time::TimePattern::TimePattern ( const Timer timer)
explicit

Create TimePattern from Timer.

◆ TimePattern() [6/6]

hueplusplus::time::TimePattern::TimePattern ( const TimePattern other)

Copy constructor for union.

Member Function Documentation

◆ asAbsolute()

AbsoluteVariedTime hueplusplus::time::TimePattern::asAbsolute ( ) const

Get contained absolute time.

Precondition
getType() == Type::absolute

◆ asInterval()

TimeInterval hueplusplus::time::TimePattern::asInterval ( ) const

Get contained time interval.

Precondition
getType() == Type::interval

◆ asRecurring()

RecurringTime hueplusplus::time::TimePattern::asRecurring ( ) const

Get contained recurring time.

Precondition
getType() == Type::recurring

◆ asTimer()

Timer hueplusplus::time::TimePattern::asTimer ( ) const

Get contained timer.

Precondition
getType() == Type::timer

◆ getType()

TimePattern::Type hueplusplus::time::TimePattern::getType ( ) const

Get currently active type.

Note
Only the currently active type may be accessed, anything else is undefined behavior.

◆ operator=()

TimePattern & hueplusplus::time::TimePattern::operator= ( const TimePattern other)

Copy assignment for union.

◆ parse()

TimePattern hueplusplus::time::TimePattern::parse ( const std::string &  s)
static

Parses TimePattern from formatted string as returned by Hue API.

Parameters
sEmpty string, "none", or in one of the formats the contained types return in their toString() method.
Returns
TimePattern with the matching type that is given in s
See also
AbsoluteTime::toString, RecurringTime::toString, TimeInterval::toString, Timer::toString
Exceptions
HueExceptionwhen the format does not match or a parsing error occurs
std::invalid_argumentwhen an integer conversion fails

◆ toString()

std::string hueplusplus::time::TimePattern::toString ( ) const

Get formatted string of the contained value as expected by Hue API.

Returns
Empty string when type is undefined, otherwise toString() of the active type.
See also
AbsoluteTime::toString, RecurringTime::toString, TimeInterval::toString, Timer::toString

Member Data Documentation

◆ absolute

AbsoluteVariedTime hueplusplus::time::TimePattern::absolute

◆ interval

TimeInterval hueplusplus::time::TimePattern::interval

◆ recurring

RecurringTime hueplusplus::time::TimePattern::recurring

◆ timer

Timer hueplusplus::time::TimePattern::timer

◆ undefined

std::nullptr_t hueplusplus::time::TimePattern::undefined

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