Open Lighting Architecture: include/ola/timecode/TimeCode.h Source File

| Open Lighting Architecture 0.10.9

Loading...
Searching...
No Matches
TimeCode.h
1/*
2 * This library is free software; you can redistribute it and/or
3 * modify it under the terms of the GNU Lesser General Public
4 * License as published by the Free Software Foundation; either
5 * version 2.1 of the License, or (at your option) any later version.
6 *
7 * This library is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 * Lesser General Public License for more details.
11 *
12 * You should have received a copy of the GNU Lesser General Public
13 * License along with this library; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15 *
16 * TimeCode.h
17 * Represents TimeCode
18 * Copyright (C) 2011 Simon Newton
19 */
20
21#ifndef INCLUDE_OLA_TIMECODE_TIMECODE_H_
22#define INCLUDE_OLA_TIMECODE_TIMECODE_H_
23
24#include <ola/timecode/TimeCodeEnums.h>
25#include <stdint.h>
26#include <sstream>
27#include <string>
28
29namespace ola {
30namespace timecode {
31
32
33 class TimeCode {
34 public:
35 TimeCode(TimeCodeType type, uint8_t hours, uint8_t minutes,
36 uint8_t seconds, uint8_t frames)
37 : m_type(type),
38 m_hours(hours),
39 m_minutes(minutes),
40 m_seconds(seconds),
41 m_frames(frames) {
42 }
43 TimeCode(const TimeCode &other);
44 TimeCode& operator=(const TimeCode &other);
45 ~TimeCode() {}
46
47 bool IsValid() const;
48
49 TimeCodeType Type() const { return m_type; }
50 uint8_t Hours() const { return m_hours; }
51 uint8_t Minutes() const { return m_minutes; }
52 uint8_t Seconds() const { return m_seconds; }
53 uint8_t Frames() const { return m_frames; }
54
55 bool operator==(const TimeCode &other) const;
56 bool operator!=(const TimeCode &other) const;
57
58 std::string AsString() const;
59 friend std::ostream& operator<<(std::ostream &out, const TimeCode&);
60
61 private:
62 TimeCodeType m_type;
63 uint8_t m_hours;
64 uint8_t m_minutes;
65 uint8_t m_seconds;
66 uint8_t m_frames;
67
68 static const uint8_t MAX_HOURS = 23;
69 static const uint8_t MAX_MINUTES = 59;
70 static const uint8_t MAX_SECONDS = 59;
71};
72} // namespace timecode
73} // namespace ola
74#endif // INCLUDE_OLA_TIMECODE_TIMECODE_H_
ola::timecode::TimeCode::IsValid
bool IsValid() const
Definition TimeCode.cpp:57
ola::timecode
Timecode.
Definition TimeCode.cpp:30
ola
The namespace containing all OLA symbols.
Definition Credentials.cpp:44