Skip to content

Commit f0aac2b

Browse files
Add Doxygen comments to opentimelineio (#1868)
Add Doxygen comments to opentimelineio
1 parent 3b7ef23 commit f0aac2b

35 files changed

+656
-142
lines changed

src/opentimelineio/anyDictionary.h

Lines changed: 40 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,37 +12,39 @@
1212

1313
namespace opentimelineio { namespace OPENTIMELINEIO_VERSION {
1414

15-
/**
16-
* An AnyDictionary has exactly the same API as
17-
* std::map<std::string, std::any>
18-
*
19-
* except that it records a "time-stamp" that bumps monotonically every time an
20-
* operation that would invalidate iterators is performed.
21-
* (This happens for operator=, clear, erase, insert, swap). The stamp also
22-
* lets external observers know when the map has been destroyed (which includes
23-
* the case of the map being relocated in memory).
24-
*
25-
* This allows us to hand out iterators that can be aware of mutation and moves
26-
* and take steps to safe-guard themselves from causing a crash. (Yes,
27-
* I'm talking to you, Python...)
28-
*/
15+
/// @brief This class provides a replacement for "std::map<std::string, std::any>".
16+
///
17+
/// This class has exactly the same API as "std::map<std::string, std::any>",
18+
/// except that it records a "time-stamp" that bumps monotonically every time an
19+
/// operation that would invalidate iterators is performed (this happens for
20+
/// operator =, clear, erase, insert, and swap). The stamp also lets external
21+
/// observers know when the map has been destroyed (which includes the case of
22+
/// the map being relocated in memory).
23+
///
24+
/// This allows us to hand out iterators that can be aware of mutation and moves
25+
/// and take steps to safe-guard themselves from causing a crash. (Yes, I'm
26+
/// talking to you, Python...)
2927
class AnyDictionary : private std::map<std::string, std::any>
3028
{
3129
public:
3230
using map::map;
3331

32+
/// @brief Create an empty dictionary.
3433
AnyDictionary()
3534
: map{}
3635
, _mutation_stamp{}
3736
{}
3837

39-
// to be safe, avoid brace-initialization so as to not trigger
40-
// list initialization behavior in older compilers:
38+
/// @brief Create a copy of a dictionary.
39+
///
40+
/// To be safe, avoid brace-initialization so as to not trigger
41+
/// list initialization behavior in older compilers:
4142
AnyDictionary(const AnyDictionary& other)
4243
: map(other)
4344
, _mutation_stamp{}
4445
{}
4546

47+
/// @brief Destructor.
4648
~AnyDictionary()
4749
{
4850
if (_mutation_stamp)
@@ -52,13 +54,15 @@ class AnyDictionary : private std::map<std::string, std::any>
5254
}
5355
}
5456

57+
/// @brief Copy operator.
5558
AnyDictionary& operator=(const AnyDictionary& other)
5659
{
5760
mutate();
5861
map::operator=(other);
5962
return *this;
6063
}
6164

65+
/// @brief Move operator.
6266
AnyDictionary& operator=(AnyDictionary&& other)
6367
{
6468
mutate();
@@ -67,6 +71,7 @@ class AnyDictionary : private std::map<std::string, std::any>
6771
return *this;
6872
}
6973

74+
/// @brief Copy operator.
7075
AnyDictionary& operator=(std::initializer_list<value_type> ilist)
7176
{
7277
mutate();
@@ -88,6 +93,7 @@ class AnyDictionary : private std::map<std::string, std::any>
8893
using map::rbegin;
8994
using map::rend;
9095

96+
/// @brief Clear the dictionary.
9197
void clear() noexcept
9298
{
9399
mutate();
@@ -97,36 +103,40 @@ class AnyDictionary : private std::map<std::string, std::any>
97103
using map::emplace_hint;
98104
using map::insert;
99105

106+
/// @brief Erase an item.
100107
iterator erase(const_iterator pos)
101108
{
102109
mutate();
103110
return map::erase(pos);
104111
}
105112

113+
/// @brief Erase a range of items.
106114
iterator erase(const_iterator first, const_iterator last)
107115
{
108116
mutate();
109117
return map::erase(first, last);
110118
}
111119

120+
/// @brief Erase an item with the given key.
112121
size_type erase(const key_type& key)
113122
{
114123
mutate();
115124
return map::erase(key);
116125
}
117126

127+
/// @brief Swap dictionaries.
118128
void swap(AnyDictionary& other)
119129
{
120130
mutate();
121131
other.mutate();
122132
map::swap(other);
123133
}
124134

125-
/// @TODO: remove all of these @{
126-
127-
// if key is in this, and the type of key matches the type of result, then
128-
// set result to the value of std::any_cast<type>(this[key]) and return true,
129-
// otherwise return false
135+
/// @brief Return whether the given key has been set.
136+
///
137+
/// If key is in this, and the type of key matches the type of result, then
138+
/// set result to the value of std::any_cast<type>(this[key]) and return true,
139+
/// otherwise return false.
130140
template <typename containedType>
131141
bool get_if_set(const std::string& key, containedType* result) const
132142
{
@@ -150,13 +160,16 @@ class AnyDictionary : private std::map<std::string, std::any>
150160
}
151161
}
152162

163+
/// @brief Return whether the dictionary contains the given key.
153164
inline bool has_key(const std::string& key) const
154165
{
155166
return (this->find(key) != this->end());
156167
}
157168

158-
// if key is in this, place the value in result and return true, otherwise
159-
// store the value in result at key and return false
169+
/// @brief Set the default for the given key.
170+
///
171+
/// If key is in this, place the value in result and return true, otherwise
172+
/// store the value in result at key and return false.
160173
template <typename containedType>
161174
bool set_default(const std::string& key, containedType* result)
162175
{
@@ -210,8 +223,10 @@ class AnyDictionary : private std::map<std::string, std::any>
210223
using map::size_type;
211224
using map::value_type;
212225

226+
/// @brief This struct provides a mutation time stamp.
213227
struct MutationStamp
214228
{
229+
/// @brief Create a new time stamp.
215230
constexpr MutationStamp(AnyDictionary* d) noexcept
216231
: stamp{ 1 }
217232
, any_dictionary{ d }
@@ -223,6 +238,7 @@ class AnyDictionary : private std::map<std::string, std::any>
223238
MutationStamp(MutationStamp const&) = delete;
224239
MutationStamp& operator=(MutationStamp const&) = delete;
225240

241+
/// @brief Destructor.
226242
~MutationStamp()
227243
{
228244
if (any_dictionary)
@@ -249,6 +265,7 @@ class AnyDictionary : private std::map<std::string, std::any>
249265
}
250266
};
251267

268+
/// @brief Get or crate a mutation time stamp.
252269
MutationStamp* get_or_create_mutation_stamp()
253270
{
254271
if (!_mutation_stamp)

src/opentimelineio/anyVector.h

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,34 +11,35 @@
1111

1212
namespace opentimelineio { namespace OPENTIMELINEIO_VERSION {
1313

14-
/**
15-
* An AnyVector has exactly the same API as
16-
* std::vector<std::any>
17-
*
18-
* except that it records a "time-stamp" that
19-
* lets external observers know when the vector has been destroyed (which includes
20-
* the case of the vector being relocated in memory).
21-
*
22-
* This allows us to hand out iterators that can be aware of moves
23-
* and take steps to safe-guard themselves from causing a crash.
24-
*/
25-
14+
/// @brief This class provides a replacement for "std::vector<std::any>".
15+
///
16+
/// This class has exactly the same API as "std::vector<std::any>", except
17+
/// that it records a "time-stamp" that lets external observers know when
18+
/// the vector has been destroyed (which includes the case of the vector
19+
/// being relocated in memory).
20+
///
21+
/// This allows us to hand out iterators that can be aware of moves
22+
/// and take steps to safe-guard themselves from causing a crash.
2623
class AnyVector : private std::vector<std::any>
2724
{
2825
public:
2926
using vector::vector;
3027

28+
/// @brief Create an empty vector.
3129
AnyVector()
3230
: _mutation_stamp{}
3331
{}
3432

35-
// must avoid brace-initialization so as to not trigger
36-
// list initialization behavior in older compilers:
33+
/// @brief Create a copy of a vector.
34+
///
35+
/// To be safe, avoid brace-initialization so as to not trigger
36+
/// list initialization behavior in older compilers:
3737
AnyVector(const AnyVector& other)
3838
: vector(other)
3939
, _mutation_stamp{ nullptr }
4040
{}
4141

42+
/// @brief Destructor.
4243
~AnyVector()
4344
{
4445
if (_mutation_stamp)
@@ -47,18 +48,21 @@ class AnyVector : private std::vector<std::any>
4748
}
4849
}
4950

51+
/// @brief Copy operator.
5052
AnyVector& operator=(const AnyVector& other)
5153
{
5254
vector::operator=(other);
5355
return *this;
5456
}
5557

58+
/// @brief Move operator.
5659
AnyVector& operator=(AnyVector&& other)
5760
{
5861
vector::operator=(other);
5962
return *this;
6063
}
6164

65+
/// @brief Copy operator.
6266
AnyVector& operator=(std::initializer_list<value_type> ilist)
6367
{
6468
vector::operator=(ilist);
@@ -113,10 +117,13 @@ class AnyVector : private std::vector<std::any>
113117
using vector::size_type;
114118
using vector::value_type;
115119

120+
/// @brief Swap vectors.
116121
void swap(AnyVector& other) { vector::swap(other); }
117122

123+
/// @brief This struct provides a mutation time stamp.
118124
struct MutationStamp
119125
{
126+
/// @brief Create a new time stamp.
120127
MutationStamp(AnyVector* v)
121128
: any_vector{ v }
122129
, owning{ false }
@@ -127,6 +134,7 @@ class AnyVector : private std::vector<std::any>
127134
MutationStamp(MutationStamp const&) = delete;
128135
MutationStamp& operator=(MutationStamp const&) = delete;
129136

137+
/// @brief Destructor.
130138
~MutationStamp()
131139
{
132140
if (any_vector)
@@ -151,6 +159,7 @@ class AnyVector : private std::vector<std::any>
151159
}
152160
};
153161

162+
/// @brief Get or create a mutation time stamp.
154163
MutationStamp* get_or_create_mutation_stamp()
155164
{
156165
if (!_mutation_stamp)

src/opentimelineio/clip.h

Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,16 @@
99

1010
namespace opentimelineio { namespace OPENTIMELINEIO_VERSION {
1111

12+
/// @brief A clip is a segment of editable media (usually audio or video).
13+
///
14+
/// Contains a MediaReference and a trim on that media reference.
1215
class Clip : public Item
1316
{
1417
public:
18+
/// @brief The default media within a clip.
1519
static char constexpr default_media_key[] = "DEFAULT_MEDIA";
1620

21+
/// @brief This struct provides the Clip schema.
1722
struct Schema
1823
{
1924
static auto constexpr name = "Clip";
@@ -22,6 +27,18 @@ class Clip : public Item
2227

2328
using Parent = Item;
2429

30+
/// @brief Create a new clip.
31+
///
32+
/// @param name The name of the clip.
33+
/// @param media_reference The media reference for the clip. Note
34+
/// that the Clip keeps a Retainer to the media reference.
35+
/// @param source_range The source range of the clip.
36+
/// @param metadata The metadata for the clip.
37+
/// @param effects The list of effects for the clip. Note that the
38+
/// the clip keeps a retainer to each effect.
39+
/// @param markers The list of markers for the clip. Note that the
40+
/// the clip keeps a retainer to each marker.
41+
/// @param active_media_reference_key The active media reference.
2542
Clip(
2643
std::string const& name = std::string(),
2744
MediaReference* media_reference = nullptr,
@@ -31,21 +48,37 @@ class Clip : public Item
3148
std::vector<Marker*> const& markers = std::vector<Marker*>(),
3249
std::string const& active_media_reference_key = default_media_key);
3350

34-
void set_media_reference(MediaReference* media_reference);
51+
/// @name Media References
52+
///@{
53+
54+
/// @brief Set the media reference. Note that the Clip keeps a Retainer to
55+
/// the media reference.
56+
void set_media_reference(MediaReference* media_reference);
57+
58+
/// @brief Return the media reference.
3559
MediaReference* media_reference() const noexcept;
3660

3761
using MediaReferences = std::map<std::string, MediaReference*>;
3862

63+
/// @brief Return the list of media references.
3964
MediaReferences media_references() const noexcept;
40-
void set_media_references(
41-
MediaReferences const& media_references,
42-
std::string const& new_active_key,
43-
ErrorStatus* error_status = nullptr) noexcept;
4465

66+
/// @brief Set the list of media references. Note that the Clip keeps a
67+
/// Retainer to each media reference.
68+
void set_media_references(
69+
MediaReferences const& media_references,
70+
std::string const& new_active_key,
71+
ErrorStatus* error_status = nullptr) noexcept;
72+
73+
/// @brief Return the active media reference.
4574
std::string active_media_reference_key() const noexcept;
46-
void set_active_media_reference_key(
47-
std::string const& new_active_key,
48-
ErrorStatus* error_status = nullptr) noexcept;
75+
76+
/// @brief Set the active media reference.
77+
void set_active_media_reference_key(
78+
std::string const& new_active_key,
79+
ErrorStatus* error_status = nullptr) noexcept;
80+
81+
///@}
4982

5083
TimeRange
5184
available_range(ErrorStatus* error_status = nullptr) const override;

0 commit comments

Comments
 (0)