Loading...
Searching...
No Matches
hueplusplus::time::TimePattern Class Reference

Holds different time representations. More...

`#include <hueplusplus/TimePattern.h>`

Collaboration diagram for hueplusplus::time::TimePattern:
[legend]

## Public Types

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

## Public Member Functions

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

## Static Public Member Functions

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

## 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

enum class hueplusplus::time::TimePattern::Type

strong

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

Create TimePattern from AbsoluteVariedTime.

## 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

  s | Empty 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

  HueException | when the format does not match or a parsing error occurs
  std::invalid_argument | when 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:

- include/hueplusplus/TimePattern.h
- src/TimePattern.cpp