KHtml

SMILTime.h
1 /*
2  * Copyright (C) 2008 Apple Inc. All Rights Reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
17  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 
26 #ifndef SMILTime_h
27 #define SMILTime_h
28 
29 #if ENABLE(SVG)
30 
31 #include <algorithm>
32 
33 namespace WebCore
34 {
35 
36 class SMILTime
37 {
38 public:
39  SMILTime() : m_time(0) { }
40  SMILTime(double time) : m_time(time) { }
41  SMILTime(const SMILTime &o) : m_time(o.m_time) { }
42 
43  static SMILTime unresolved()
44  {
45  return unresolvedValue;
46  }
47  static SMILTime indefinite()
48  {
49  return indefiniteValue;
50  }
51 
52  SMILTime &operator=(const SMILTime &o)
53  {
54  m_time = o.m_time;
55  return *this;
56  }
57  double value() const
58  {
59  return m_time;
60  }
61 
62  bool isFinite() const
63  {
64  return m_time < indefiniteValue;
65  }
66  bool isIndefinite() const
67  {
68  return m_time == indefiniteValue;
69  }
70  bool isUnresolved() const
71  {
72  return m_time == unresolvedValue;
73  }
74 
75 private:
76  static const double unresolvedValue;
77  static const double indefiniteValue;
78 
79  double m_time;
80 };
81 
82 inline bool operator==(const SMILTime &a, const SMILTime &b)
83 {
84  return a.isFinite() && a.value() == b.value();
85 }
86 inline bool operator!=(const SMILTime &a, const SMILTime &b)
87 {
88  return !operator==(a, b);
89 }
90 inline bool operator>(const SMILTime &a, const SMILTime &b)
91 {
92  return a.value() > b.value();
93 }
94 inline bool operator<(const SMILTime &a, const SMILTime &b)
95 {
96  return a.value() < b.value();
97 }
98 inline bool operator>=(const SMILTime &a, const SMILTime &b)
99 {
100  return a.value() > b.value() || operator==(a, b);
101 }
102 inline bool operator<=(const SMILTime &a, const SMILTime &b)
103 {
104  return a.value() < b.value() || operator==(a, b);
105 }
106 
107 inline SMILTime max(const SMILTime &a, const SMILTime &b)
108 {
109  return std::max(a.value(), b.value());
110 }
111 inline SMILTime min(const SMILTime &a, const SMILTime &b)
112 {
113  return std::min(a.value(), b.value());
114 }
115 SMILTime operator+(const SMILTime &, const SMILTime &);
116 SMILTime operator-(const SMILTime &, const SMILTime &);
117 // So multiplying times does not make too much sense but SMIL defines it for duration * repeatCount
118 SMILTime operator*(const SMILTime &, const SMILTime &);
119 }
120 
121 #endif
122 #endif
bool operator==(const Qt3DRender::QGraphicsApiFilter &reference, const Qt3DRender::QGraphicsApiFilter &sample)
QCA_EXPORT const SecureArray operator+(const SecureArray &a, const SecureArray &b)
bool operator!=(const Qt3DRender::QGraphicsApiFilter &reference, const Qt3DRender::QGraphicsApiFilter &sample)
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Tue Oct 26 2021 22:48:09 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.