Skip to content

Commit ddb39f5

Browse files
Support for C++17 (#1713)
* Use std::any and std::optional * Update Python bindings * Fix missing std::any_cast * Set minimum OSX version to 10.13 --------- Signed-off-by: Darby Johnston <darbyjohnston@yahoo.com>
1 parent afcb552 commit ddb39f5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+675
-742
lines changed

.gitmodules

-6
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
1-
[submodule "src/deps/optional-lite"]
2-
path = src/deps/optional-lite
3-
url = https://github.com/martinmoene/optional-lite
41
[submodule "src/deps/pybind11"]
52
path = src/deps/pybind11
63
url = https://github.com/pybind/pybind11.git
74
[submodule "src/deps/rapidjson"]
85
path = src/deps/rapidjson
96
url = https://github.com/Tencent/rapidjson.git
10-
[submodule "src/deps/any"]
11-
path = src/deps/any
12-
url = https://github.com/thelink2012/any.git
137
[submodule "src/deps/Imath"]
148
path = src/deps/Imath
159
url = https://github.com/AcademySoftwareFoundation/Imath

CMakeLists.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ set(OTIO_AUTHOR_EMAIL "otio-discussion@lists.aswf.io")
1616
set(OTIO_LICENSE "Modified Apache 2.0 License")
1717

1818
set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64" CACHE STRING "")
19+
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.13" CACHE STRING "Minimum OS X deployment version")
1920

2021
project(OpenTimelineIO VERSION ${OTIO_VERSION} LANGUAGES C CXX)
2122

@@ -142,7 +143,7 @@ endif()
142143
# Global language settings
143144

144145
if (NOT CMAKE_CXX_STANDARD)
145-
set(CMAKE_CXX_STANDARD 14)
146+
set(CMAKE_CXX_STANDARD 17)
146147
endif()
147148

148149
set(CMAKE_CXX_STANDARD_REQUIRED ON)

src/deps/CMakeLists.txt

+1-8
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#----- Other dependencies
55

66
# detect if the submodules haven't been updated
7-
set(DEPS_SUBMODULES any optional-lite pybind11 rapidjson)
7+
set(DEPS_SUBMODULES pybind11 rapidjson)
88
foreach(submodule IN LISTS DEPS_SUBMODULES)
99
file(GLOB SUBMOD_CONTENTS ${submodule})
1010
list(LENGTH SUBMOD_CONTENTS SUBMOD_CONTENT_LEN)
@@ -20,13 +20,6 @@ if(OTIO_PYTHON_INSTALL)
2020
add_subdirectory(pybind11)
2121
endif()
2222

23-
if(OTIO_CXX_INSTALL AND OTIO_DEPENDENCIES_INSTALL)
24-
install(FILES any/any.hpp
25-
DESTINATION "${OTIO_RESOLVED_CXX_INSTALL_DIR}/include/opentimelineio/deps/any")
26-
install(FILES optional-lite/include/nonstd/optional.hpp
27-
DESTINATION "${OTIO_RESOLVED_CXX_INSTALL_DIR}/include/opentimelineio/deps/nonstd")
28-
endif()
29-
3023
if (USE_DEPS_IMATH)
3124
# preserve BUILD_SHARED_LIBS options for this project, but set it off for Imath
3225
option(BUILD_SHARED_LIBS "Build shared libraries" ON)

src/deps/any

-1
This file was deleted.

src/deps/optional-lite

-1
This file was deleted.

src/opentimelineio/CMakeLists.txt

-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
# opentimelineio/CMakeLists.txt
33

44
set(OPENTIMELINEIO_HEADER_FILES
5-
any.h
65
anyDictionary.h
76
anyVector.h
87
clip.h
@@ -22,7 +21,6 @@ set(OPENTIMELINEIO_HEADER_FILES
2221
marker.h
2322
mediaReference.h
2423
missingReference.h
25-
optional.h
2624
safely_typed_any.h
2725
serializableCollection.h
2826
serializableObject.h
@@ -83,7 +81,6 @@ target_include_directories(opentimelineio
8381
PRIVATE "${IMATH_INCLUDES}"
8482
"${PROJECT_SOURCE_DIR}/src"
8583
"${PROJECT_SOURCE_DIR}/src/deps"
86-
"${PROJECT_SOURCE_DIR}/src/deps/optional-lite/include"
8784
"${PROJECT_SOURCE_DIR}/src/deps/rapidjson/include"
8885
"${IMATH_INCLUDES}")
8986

src/opentimelineio/any.h

-14
This file was deleted.

src/opentimelineio/anyDictionary.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
#pragma once
55

6-
#include "opentimelineio/any.h"
76
#include "opentimelineio/version.h"
87

8+
#include <any>
99
#include <assert.h>
1010
#include <map>
1111
#include <string>
@@ -14,7 +14,7 @@ namespace opentimelineio { namespace OPENTIMELINEIO_VERSION {
1414

1515
/**
1616
* An AnyDictionary has exactly the same API as
17-
* std::map<std::string, any>
17+
* std::map<std::string, std::any>
1818
*
1919
* except that it records a "time-stamp" that bumps monotonically every time an
2020
* operation that would invalidate iterators is performed.
@@ -26,7 +26,7 @@ namespace opentimelineio { namespace OPENTIMELINEIO_VERSION {
2626
* and take steps to safe-guard themselves from causing a crash. (Yes,
2727
* I'm talking to you, Python...)
2828
*/
29-
class AnyDictionary : private std::map<std::string, any>
29+
class AnyDictionary : private std::map<std::string, std::any>
3030
{
3131
public:
3232
using map::map;
@@ -125,7 +125,7 @@ class AnyDictionary : private std::map<std::string, any>
125125
/// @TODO: remove all of these @{
126126

127127
// if key is in this, and the type of key matches the type of result, then
128-
// set result to the value of any_cast<type>(this[key]) and return true,
128+
// set result to the value of std::any_cast<type>(this[key]) and return true,
129129
// otherwise return false
130130
template <typename containedType>
131131
bool get_if_set(const std::string& key, containedType* result) const
@@ -141,7 +141,7 @@ class AnyDictionary : private std::map<std::string, any>
141141
&& (it->second.type().hash_code()
142142
== typeid(containedType).hash_code()))
143143
{
144-
*result = any_cast<containedType>(it->second);
144+
*result = std::any_cast<containedType>(it->second);
145145
return true;
146146
}
147147
else
@@ -171,7 +171,7 @@ class AnyDictionary : private std::map<std::string, any>
171171
&& (d_it->second.type().hash_code()
172172
== typeid(containedType).hash_code()))
173173
{
174-
*result = any_cast<containedType>(d_it->second);
174+
*result = std::any_cast<containedType>(d_it->second);
175175
return true;
176176
}
177177
else

src/opentimelineio/anyVector.h

+4-3
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,17 @@
33

44
#pragma once
55

6-
#include "opentimelineio/any.h"
76
#include "opentimelineio/version.h"
7+
8+
#include <any>
89
#include <assert.h>
910
#include <vector>
1011

1112
namespace opentimelineio { namespace OPENTIMELINEIO_VERSION {
1213

1314
/**
1415
* An AnyVector has exactly the same API as
15-
* std::vector<any>
16+
* std::vector<std::any>
1617
*
1718
* except that it records a "time-stamp" that
1819
* lets external observers know when the vector has been destroyed (which includes
@@ -22,7 +23,7 @@ namespace opentimelineio { namespace OPENTIMELINEIO_VERSION {
2223
* and take steps to safe-guard themselves from causing a crash.
2324
*/
2425

25-
class AnyVector : private std::vector<any>
26+
class AnyVector : private std::vector<std::any>
2627
{
2728
public:
2829
using vector::vector;

src/opentimelineio/clip.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ namespace opentimelineio { namespace OPENTIMELINEIO_VERSION {
99
char constexpr Clip::default_media_key[];
1010

1111
Clip::Clip(
12-
std::string const& name,
13-
MediaReference* media_reference,
14-
optional<TimeRange> const& source_range,
15-
AnyDictionary const& metadata,
16-
std::string const& active_media_reference_key)
12+
std::string const& name,
13+
MediaReference* media_reference,
14+
std::optional<TimeRange> const& source_range,
15+
AnyDictionary const& metadata,
16+
std::string const& active_media_reference_key)
1717
: Parent{ name, source_range, metadata }
1818
, _active_media_reference_key(active_media_reference_key)
1919
{
@@ -184,7 +184,7 @@ Clip::available_range(ErrorStatus* error_status) const
184184
return active_media->available_range().value();
185185
}
186186

187-
optional<IMATH_NAMESPACE::Box2d>
187+
std::optional<IMATH_NAMESPACE::Box2d>
188188
Clip::available_image_bounds(ErrorStatus* error_status) const
189189
{
190190
auto active_media = media_reference();
@@ -194,7 +194,7 @@ Clip::available_image_bounds(ErrorStatus* error_status) const
194194
ErrorStatus::CANNOT_COMPUTE_BOUNDS,
195195
"No image bounds set on clip",
196196
this);
197-
return optional<IMATH_NAMESPACE::Box2d>();
197+
return std::optional<IMATH_NAMESPACE::Box2d>();
198198
}
199199

200200
if (!active_media->available_image_bounds())
@@ -203,7 +203,7 @@ Clip::available_image_bounds(ErrorStatus* error_status) const
203203
ErrorStatus::CANNOT_COMPUTE_BOUNDS,
204204
"No image bounds set on media reference on clip",
205205
this);
206-
return optional<IMATH_NAMESPACE::Box2d>();
206+
return std::optional<IMATH_NAMESPACE::Box2d>();
207207
}
208208

209209
return active_media->available_image_bounds();

src/opentimelineio/clip.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ class Clip : public Item
2323
using Parent = Item;
2424

2525
Clip(
26-
std::string const& name = std::string(),
27-
MediaReference* media_reference = nullptr,
28-
optional<TimeRange> const& source_range = nullopt,
29-
AnyDictionary const& metadata = AnyDictionary(),
30-
std::string const& active_media_reference_key = default_media_key);
26+
std::string const& name = std::string(),
27+
MediaReference* media_reference = nullptr,
28+
std::optional<TimeRange> const& source_range = std::nullopt,
29+
AnyDictionary const& metadata = AnyDictionary(),
30+
std::string const& active_media_reference_key = default_media_key);
3131

3232
void set_media_reference(MediaReference* media_reference);
3333
MediaReference* media_reference() const noexcept;
@@ -48,7 +48,7 @@ class Clip : public Item
4848
TimeRange
4949
available_range(ErrorStatus* error_status = nullptr) const override;
5050

51-
optional<IMATH_NAMESPACE::Box2d>
51+
std::optional<IMATH_NAMESPACE::Box2d>
5252
available_image_bounds(ErrorStatus* error_status) const override;
5353

5454
protected:

src/opentimelineio/composable.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ Composable::duration(ErrorStatus* error_status) const
7474
return RationalTime();
7575
}
7676

77-
optional<IMATH_NAMESPACE::Box2d>
77+
std::optional<IMATH_NAMESPACE::Box2d>
7878
Composable::available_image_bounds(ErrorStatus* error_status) const
7979
{
8080
*error_status = ErrorStatus::NOT_IMPLEMENTED;
81-
return optional<IMATH_NAMESPACE::Box2d>();
81+
return std::optional<IMATH_NAMESPACE::Box2d>();
8282
}
8383

8484
}} // namespace opentimelineio::OPENTIMELINEIO_VERSION

src/opentimelineio/composable.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class Composable : public SerializableObjectWithMetadata
3434

3535
virtual RationalTime duration(ErrorStatus* error_status = nullptr) const;
3636

37-
virtual optional<IMATH_NAMESPACE::Box2d>
37+
virtual std::optional<IMATH_NAMESPACE::Box2d>
3838
available_image_bounds(ErrorStatus* error_status) const;
3939

4040
protected:

0 commit comments

Comments
 (0)