HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HUSD_TimeCode.h
Go to the documentation of this file.
1 /*
2  * Copyright 2019 Side Effects Software Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 
18 #ifndef __HUSD_TimeCode_h__
19 #define __HUSD_TimeCode_h__
20 
21 #include "HUSD_API.h"
22 #include <SYS/SYS_Types.h>
23 
25 {
26 public:
27  enum TimeFormat {
29  FRAME
30  };
31 
32  // Constructs a pure default time code. Use this only if there is really
33  // no sensible fallback time/frame value available.
35  : myFrame(0.0),
36  myIsDefault(true)
37  { }
38  // Constructs a time code at a specific frame. The time code can still be
39  // marked as "default", in which case we still record the provided frame
40  // number for cases where a default time is not acceptable (such as when
41  // querying an attribute from a stage).
42  explicit HUSD_TimeCode(fpreal frame,
43  bool is_default = false)
44  : myFrame(frame),
45  myIsDefault(is_default)
46  { }
47  // Constructs a time code at a specific time or frame. The time code can
48  // still be marked as "default", in which case we still record the provided
49  // frame number for cases where a default time is not acceptable (such as
50  // when querying an attribute from a stage).
51  explicit HUSD_TimeCode(fpreal time,
52  TimeFormat format,
53  bool is_default = false);
54 
55  /// Returns a time code with the same specific time/frame as this one,
56  /// but whose default flag is cleared. This is needed for cases where
57  /// a default time is not acceptable (such as when setting a time-varying
58  /// attribute on a stage).
60  { return HUSD_TimeCode(myFrame, false); }
61 
62  bool operator==(const HUSD_TimeCode &other) const
63  { return other.myIsDefault ? myIsDefault :
64  (other.myFrame == myFrame); }
65  bool operator!=(const HUSD_TimeCode &other) const
66  { return !(other == *this); }
67 
68  fpreal time() const;
69  fpreal frame() const
70  { return myFrame; }
71  bool isDefault() const
72  { return myIsDefault; }
73 
74 private:
75  fpreal myFrame;
76  bool myIsDefault;
77 };
78 
79 #endif
80 
GT_API const UT_StringHolder time
#define HUSD_API
Definition: HUSD_API.h:32
HUSD_TimeCode getNonDefaultTimeCode() const
Definition: HUSD_TimeCode.h:59
fpreal frame() const
Definition: HUSD_TimeCode.h:69
bool isDefault() const
Definition: HUSD_TimeCode.h:71
HUSD_TimeCode(fpreal frame, bool is_default=false)
Definition: HUSD_TimeCode.h:42
double fpreal
Definition: SYS_Types.h:276
bool operator!=(const HUSD_TimeCode &other) const
Definition: HUSD_TimeCode.h:65
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: glew.h:1254
bool operator==(const HUSD_TimeCode &other) const
Definition: HUSD_TimeCode.h:62