Skip to content

Commit 878b852

Browse files
committed
Merge branch 'bs2076-3' of https://github.com/davemar-bbc/libadm into bs2076-3
2 parents 5332c4d + 353aa56 commit 878b852

25 files changed

+665
-10
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
submodules: recursive
3939

4040
- name: Get CMake and ninja
41-
uses: lukka/get-cmake@v3.20.1
41+
uses: lukka/get-cmake@latest
4242

4343
- name: Restore artifacts, or run vcpkg, build and cache artifacts
4444
uses: lukka/run-vcpkg@v7
@@ -82,7 +82,7 @@ jobs:
8282
message("::set-output name=timestamp::${current_date}")
8383
8484
- name: ccache cache files
85-
uses: actions/cache@v1.1.0
85+
uses: actions/cache@v4
8686
with:
8787
path: ${{ github.workspace }}/.ccache
8888
key: ${{ env.CCACHE_KEY }}-${{ steps.ccache_cache_timestamp.outputs.timestamp }}

format.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/bin/bash
2+
clang-format --version
23
DIRS="examples include src tests"
34

45
IGNORE="

include/adm/document.hpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ namespace adm {
8080
ADM_EXPORT bool add(std::shared_ptr<AudioTrackFormat> trackFormat);
8181
/// @brief Add an AudioTrackUid
8282
ADM_EXPORT bool add(std::shared_ptr<AudioTrackUid> trackUid);
83+
/// @brief Add a profileList
84+
ADM_EXPORT bool add(std::shared_ptr<ProfileList> profileList);
85+
/// @brief Add a tagList
86+
ADM_EXPORT bool add(std::shared_ptr<TagList> tagList);
8387
///@}
8488

8589
/** @name Remove ADM elements
@@ -104,6 +108,10 @@ namespace adm {
104108
ADM_EXPORT bool remove(std::shared_ptr<AudioTrackFormat> trackFormat);
105109
/// @brief Remove an AudioTrackUid
106110
ADM_EXPORT bool remove(std::shared_ptr<AudioTrackUid> trackUid);
111+
/// @brief Remove a profileList
112+
ADM_EXPORT bool remove(std::shared_ptr<ProfileList> profileList);
113+
/// @brief Remove a tagList
114+
ADM_EXPORT bool remove(std::shared_ptr<TagList> tagList);
107115
///@}
108116

109117
/**
@@ -126,6 +134,12 @@ namespace adm {
126134
template <typename Element>
127135
ElementRange<Element> getElements();
128136

137+
template <typename Element>
138+
std::shared_ptr<const Element> getElement() const;
139+
140+
template <typename Element>
141+
std::shared_ptr<Element> getElement();
142+
129143
/** @name Lookup ADM elements by its Id
130144
*
131145
* Lookup the first ADM element with the given Id.
@@ -257,6 +271,10 @@ namespace adm {
257271
detail::ParameterTraits<AudioTrackFormat>::tag) const;
258272
ADM_EXPORT ElementRange<const AudioTrackUid> getElements(
259273
detail::ParameterTraits<AudioTrackUid>::tag) const;
274+
ADM_EXPORT std::shared_ptr<const ProfileList> getElement(
275+
detail::ParameterTraits<ProfileList>::tag) const;
276+
ADM_EXPORT std::shared_ptr<const TagList> getElement(
277+
detail::ParameterTraits<TagList>::tag) const;
260278
ADM_EXPORT ElementRange<AudioProgramme> getElements(
261279
detail::ParameterTraits<AudioProgramme>::tag);
262280
ADM_EXPORT ElementRange<AudioContent> getElements(
@@ -273,6 +291,10 @@ namespace adm {
273291
detail::ParameterTraits<AudioTrackFormat>::tag);
274292
ADM_EXPORT ElementRange<AudioTrackUid> getElements(
275293
detail::ParameterTraits<AudioTrackUid>::tag);
294+
ADM_EXPORT std::shared_ptr<ProfileList> getElement(
295+
detail::ParameterTraits<ProfileList>::tag);
296+
ADM_EXPORT std::shared_ptr<TagList> getElement(
297+
detail::ParameterTraits<TagList>::tag);
276298

277299
/// check the parent of an element
278300
///
@@ -300,6 +322,8 @@ namespace adm {
300322
std::vector<std::shared_ptr<AudioStreamFormat>> audioStreamFormats_;
301323
std::vector<std::shared_ptr<AudioTrackFormat>> audioTrackFormats_;
302324
std::vector<std::shared_ptr<AudioTrackUid>> audioTrackUids_;
325+
std::shared_ptr<ProfileList> profileList_;
326+
std::shared_ptr<TagList> tagList_;
303327
detail::IdAssigner idAssigner_;
304328
};
305329

@@ -317,4 +341,16 @@ namespace adm {
317341
return getElements(Tag());
318342
}
319343

344+
template <typename Element>
345+
std::shared_ptr<const Element> Document::getElement() const {
346+
typedef typename detail::ParameterTraits<Element>::tag Tag;
347+
return getElement(Tag());
348+
}
349+
350+
template <typename Element>
351+
std::shared_ptr<Element> Document::getElement() {
352+
typedef typename detail::ParameterTraits<Element>::tag Tag;
353+
return getElement(Tag());
354+
}
355+
320356
} // namespace adm

include/adm/elements.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "adm/elements/audio_stream_format.hpp"
2828
#include "adm/elements/audio_track_uid.hpp"
2929
#include "adm/elements/profile_list.hpp"
30+
#include "adm/elements/tag_list.hpp"
3031

3132
#include "adm/elements/audio_block_format_direct_speakers.hpp"
3233
#include "adm/elements/audio_block_format_matrix.hpp"

include/adm/elements/audio_channel_format.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ namespace adm {
381381
return previous == 0u || current == previous.get() + 1u;
382382
}
383383
}
384-
384+
385385
template <typename BlockFormat>
386386
void AudioChannelFormat::assignId(BlockFormat &blockFormat,
387387
BlockFormat *previousBlock) {

include/adm/elements/profile_list.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,12 @@ namespace adm {
8585
using ProfileListBase = HasParameters<VectorParameter<Profiles>>;
8686
} // namespace detail
8787

88-
struct ProfileceListTag {};
88+
struct ProfileListTag {};
8989

9090
class ProfileList : private detail::ProfileListBase,
9191
private detail::AddWrapperMethods<ProfileList> {
9292
public:
93-
using tag = ProfileceListTag;
93+
using tag = ProfileListTag;
9494

9595
template <typename... Parameters>
9696
explicit ProfileList(Parameters... namedArgs) {

include/adm/elements/tag_list.hpp

Lines changed: 258 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,258 @@
1+
#pragma once
2+
#include <vector>
3+
#include "adm/detail/auto_base.hpp"
4+
#include "adm/elements/audio_programme.hpp"
5+
#include "adm/elements_fwd.hpp"
6+
#include "adm/detail/named_option_helper.hpp"
7+
#include "adm/detail/optional_comparison.hpp"
8+
#include "adm/errors.hpp"
9+
10+
namespace adm {
11+
struct TTagValueTag {};
12+
using TTagValue = detail::NamedType<std::string, TTagValueTag>;
13+
14+
struct TTagClassTag {};
15+
using TTagClass = detail::NamedType<std::string, TTagClassTag>;
16+
17+
struct TTagTag {};
18+
19+
namespace detail {
20+
extern template class ADM_EXPORT_TEMPLATE_METHODS
21+
RequiredParameter<TTagValue>;
22+
extern template class ADM_EXPORT_TEMPLATE_METHODS
23+
OptionalParameter<TTagClass>;
24+
25+
using TTagBase = HasParameters<RequiredParameter<TTagValue>,
26+
OptionalParameter<TTagClass>>;
27+
} // namespace detail
28+
29+
class TTag : private detail::TTagBase,
30+
private detail::AddWrapperMethods<TTag> {
31+
public:
32+
using tag = TTagTag;
33+
34+
template <typename... Parameters>
35+
explicit TTag(Parameters... namedArgs) {
36+
detail::setNamedOptionHelper(this, std::move(namedArgs)...);
37+
}
38+
39+
ADM_EXPORT explicit TTag(std::string str)
40+
: TTag(TTagValue(std::move(str))) {}
41+
ADM_EXPORT explicit TTag(const char *s);
42+
43+
ADM_EXPORT void print(std::ostream &os) const;
44+
45+
using detail::TTagBase::set;
46+
using detail::TTagBase::unset;
47+
using detail::AddWrapperMethods<TTag>::get;
48+
using detail::AddWrapperMethods<TTag>::has;
49+
using detail::AddWrapperMethods<TTag>::isDefault;
50+
using detail::AddWrapperMethods<TTag>::unset;
51+
52+
private:
53+
using detail::TTagBase::get;
54+
using detail::TTagBase::has;
55+
56+
friend class detail::AddWrapperMethods<TTag>;
57+
};
58+
59+
struct TTagsTag {};
60+
61+
using TTags = std::vector<TTag>;
62+
ADD_TRAIT(TTags, TTagsTag);
63+
64+
inline bool operator==(const TTag &a, const TTag &b) {
65+
return detail::optionalsEqual<TTagValue, TTagClass>(a, b);
66+
}
67+
68+
inline bool operator!=(const TTag &a, const TTag &b) { return !(a == b); }
69+
70+
struct TagGroupTag {};
71+
72+
namespace detail {
73+
extern template class ADM_EXPORT_TEMPLATE_METHODS VectorParameter<TTags>;
74+
75+
using TagGroupBase = HasParameters<VectorParameter<TTags>>;
76+
} // namespace detail
77+
78+
class TagGroup : private detail::TagGroupBase,
79+
private detail::AddWrapperMethods<TagGroup> {
80+
public:
81+
using tag = TagGroupTag;
82+
83+
// DEBUG FUNCTIONS
84+
int getTempId() { return temp_id_; };
85+
void setTempId(int n) { temp_id_ = n; };
86+
87+
template <typename... Parameters>
88+
explicit TagGroup(Parameters... namedArgs) {
89+
detail::setNamedOptionHelper(this, std::move(namedArgs)...);
90+
}
91+
92+
/// @brief Add reference to an AudioProgramme
93+
ADM_EXPORT bool addReference(std::shared_ptr<AudioProgramme> programme);
94+
95+
/// @brief Add reference to an AudioContent
96+
ADM_EXPORT bool addReference(std::shared_ptr<AudioContent> content);
97+
98+
/// @brief Add reference to an AudioObject
99+
ADM_EXPORT bool addReference(std::shared_ptr<AudioObject> object);
100+
101+
template <typename Element>
102+
ElementRange<Element> getReferences();
103+
104+
template <typename Element>
105+
ElementRange<const Element> getReferences() const;
106+
107+
/// @brief Remove reference to an AudioProgramme
108+
ADM_EXPORT void removeReference(std::shared_ptr<AudioProgramme> programme);
109+
110+
/// @brief Remove reference to an AudioContent
111+
ADM_EXPORT void removeReference(std::shared_ptr<AudioContent> content);
112+
113+
/// @brief Remove reference to an AudioObject
114+
ADM_EXPORT void removeReference(std::shared_ptr<AudioObject> object);
115+
116+
template <typename Element>
117+
void clearReferences();
118+
119+
using detail::TagGroupBase::set;
120+
using detail::AddWrapperMethods<TagGroup>::get;
121+
using detail::AddWrapperMethods<TagGroup>::has;
122+
using detail::AddWrapperMethods<TagGroup>::isDefault;
123+
using detail::AddWrapperMethods<TagGroup>::unset;
124+
using detail::TagGroupBase::add;
125+
using detail::TagGroupBase::remove;
126+
127+
private:
128+
int temp_id_;
129+
130+
using detail::TagGroupBase::get;
131+
using detail::TagGroupBase::has;
132+
using detail::TagGroupBase::isDefault;
133+
using detail::TagGroupBase::unset;
134+
135+
friend class detail::AddWrapperMethods<TagGroup>;
136+
137+
ADM_EXPORT ElementRange<const AudioProgramme> getReferences(
138+
detail::ParameterTraits<AudioProgramme>::tag) const;
139+
ADM_EXPORT ElementRange<AudioProgramme> getReferences(
140+
detail::ParameterTraits<AudioProgramme>::tag);
141+
ADM_EXPORT ElementRange<const AudioContent> getReferences(
142+
detail::ParameterTraits<AudioContent>::tag) const;
143+
ADM_EXPORT ElementRange<AudioContent> getReferences(
144+
detail::ParameterTraits<AudioContent>::tag);
145+
ADM_EXPORT ElementRange<const AudioObject> getReferences(
146+
detail::ParameterTraits<AudioObject>::tag) const;
147+
ADM_EXPORT ElementRange<AudioObject> getReferences(
148+
detail::ParameterTraits<AudioObject>::tag);
149+
150+
ADM_EXPORT void clearReferences(
151+
detail::ParameterTraits<AudioProgramme>::tag);
152+
ADM_EXPORT void clearReferences(detail::ParameterTraits<AudioContent>::tag);
153+
ADM_EXPORT void clearReferences(detail::ParameterTraits<AudioObject>::tag);
154+
155+
ADM_EXPORT void disconnectReferences();
156+
157+
std::vector<std::shared_ptr<AudioProgramme>> audioProgrammes_;
158+
std::vector<std::shared_ptr<AudioContent>> audioContents_;
159+
std::vector<std::shared_ptr<AudioObject>> audioObjects_;
160+
};
161+
162+
inline bool operator==(const TagGroup &a, const TagGroup &b) {
163+
return detail::optionalsEqual<TTags>(a, b);
164+
}
165+
166+
inline bool operator!=(const TagGroup &a, const TagGroup &b) {
167+
return !(a == b);
168+
}
169+
170+
template <typename Element>
171+
ElementRange<const Element> TagGroup::getReferences() const {
172+
typedef typename detail::ParameterTraits<Element>::tag Tag;
173+
return getReferences(Tag());
174+
}
175+
176+
template <typename Element>
177+
ElementRange<Element> TagGroup::getReferences() {
178+
typedef typename detail::ParameterTraits<Element>::tag Tag;
179+
return getReferences(Tag());
180+
}
181+
182+
inline ElementRange<const AudioProgramme> TagGroup::getReferences(
183+
detail::ParameterTraits<AudioProgramme>::tag) const {
184+
return detail::makeElementRange<AudioProgramme>(audioProgrammes_);
185+
}
186+
187+
inline ElementRange<AudioProgramme> TagGroup::getReferences(
188+
detail::ParameterTraits<AudioProgramme>::tag) {
189+
return detail::makeElementRange<AudioProgramme>(audioProgrammes_);
190+
}
191+
192+
inline ElementRange<const AudioContent> TagGroup::getReferences(
193+
detail::ParameterTraits<AudioContent>::tag) const {
194+
return detail::makeElementRange<AudioContent>(audioContents_);
195+
}
196+
197+
inline ElementRange<AudioContent> TagGroup::getReferences(
198+
detail::ParameterTraits<AudioContent>::tag) {
199+
return detail::makeElementRange<AudioContent>(audioContents_);
200+
}
201+
202+
inline ElementRange<const AudioObject> TagGroup::getReferences(
203+
detail::ParameterTraits<AudioObject>::tag) const {
204+
return detail::makeElementRange<AudioObject>(audioObjects_);
205+
}
206+
207+
inline ElementRange<AudioObject> TagGroup::getReferences(
208+
detail::ParameterTraits<AudioObject>::tag) {
209+
return detail::makeElementRange<AudioObject>(audioObjects_);
210+
}
211+
212+
template <typename Element>
213+
void TagGroup::clearReferences() {
214+
typedef typename detail::ParameterTraits<Element>::tag Tag;
215+
clearReferences(Tag());
216+
}
217+
218+
struct TagGroupsTag {};
219+
220+
using TagGroups = std::vector<TagGroup>;
221+
ADD_TRAIT(TagGroups, TagGroupsTag);
222+
223+
namespace detail {
224+
extern template class ADM_EXPORT_TEMPLATE_METHODS
225+
VectorParameter<TagGroups>;
226+
227+
using TagListBase = HasParameters<VectorParameter<TagGroups>>;
228+
} // namespace detail
229+
230+
struct TagListTag {};
231+
232+
class TagList : private detail::TagListBase,
233+
private detail::AddWrapperMethods<TagList> {
234+
public:
235+
using tag = TagListTag;
236+
237+
template <typename... Parameters>
238+
explicit TagList(Parameters... namedArgs) {
239+
detail::setNamedOptionHelper(this, std::move(namedArgs)...);
240+
}
241+
242+
using detail::TagListBase::set;
243+
using detail::AddWrapperMethods<TagList>::get;
244+
using detail::AddWrapperMethods<TagList>::has;
245+
using detail::AddWrapperMethods<TagList>::isDefault;
246+
using detail::AddWrapperMethods<TagList>::unset;
247+
using detail::TagListBase::add;
248+
using detail::TagListBase::remove;
249+
250+
private:
251+
using detail::TagListBase::get;
252+
using detail::TagListBase::has;
253+
using detail::TagListBase::isDefault;
254+
using detail::TagListBase::unset;
255+
256+
friend class detail::AddWrapperMethods<TagList>;
257+
};
258+
} // namespace adm

0 commit comments

Comments
 (0)