AVPKit
ITimeValue.cpp
1 /*******************************************************************************
2  * Copyright (c) 2024, 2026, Olivier Ayache. All rights reserved.
3  *
4  * This file is part of AVPKit.
5  *
6  * AVPKit is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * AVPKit is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with AVPKit. If not, see <http://www.gnu.org/licenses/>.
18  *******************************************************************************/
19 
20 /*
21  * ITimeValue.cpp
22  *
23  * Created on: Sep 19, 2008
24  * Author: aclarke
25  */
26 
27 #include "ITimeValue.h"
28 #include "TimeValue.h"
29 
30 namespace com { namespace avpkit { namespace core
31 {
32 
33 ITimeValue::ITimeValue()
34 {
35 }
36 
37 ITimeValue::~ITimeValue()
38 {
39 }
40 
41 ITimeValue*
42 ITimeValue::make(int64_t aValue, Unit aUnit)
43 {
44  return TimeValue::make(aValue, aUnit);
45 }
46 
49 {
50  return TimeValue::make(dynamic_cast<TimeValue*>(src));
51 }
52 
53 int32_t
55 {
56  int32_t retval = 0;
57  if (a)
58  {
59  retval = a->compareTo(b);
60  }
61  else
62  {
63  if (b)
64  // null is always less than any non-null value
65  retval = 1;
66  else // both are null
67  retval = 0;
68  }
69 
70  return retval;
71 }
72 
73 int32_t
74 ITimeValue::compare(int64_t a, int64_t b)
75 {
76  return TimeValue::compare(a, b);
77 }
78 }}}
Time (duration) values with units.
Definition: ITimeValue.h:43
static int32_t compare(ITimeValue *a, ITimeValue *b)
Convenience method that calls a.compareTo(b).
Definition: ITimeValue.cpp:54
static ITimeValue * make(int64_t value, Unit unit)
Make a new time value.
Definition: ITimeValue.cpp:42
virtual int32_t compareTo(ITimeValue *other)=0
Compare this timeValue to another.
WARNING: Do not use logging in this class, and do not set any static file variables to values other t...