Remove unnecessary forward declarations
[alure.git] / src / sourcegroup.h
blob2bb0fc40d90db8b0e806ccc982ebd83ec4d9037f
1 #ifndef SOURCEGROUP_H
2 #define SOURCEGROUP_H
4 #include "main.h"
7 namespace alure
10 struct SourceGroupProps {
11 ALfloat mGain;
12 ALfloat mPitch;
14 SourceGroupProps() : mGain(1.0f), mPitch(1.0f) { }
17 class SourceGroupImpl : SourceGroupProps {
18 ContextImpl *const mContext;
20 Vector<SourceImpl*> mSources;
21 Vector<SourceGroupImpl*> mSubGroups;
23 SourceGroupProps mParentProps;
24 SourceGroupImpl *mParent;
26 const String mName;
28 void applyPropTree(SourceGroupProps &props) const
30 props.mGain *= mGain;
31 props.mPitch *= mPitch;
32 if(mParent)
33 mParent->applyPropTree(props);
36 void update(ALfloat gain, ALfloat pitch);
38 void setParentGroup(SourceGroupImpl *group);
39 void unsetParentGroup();
41 void eraseSubGroup(SourceGroupImpl *group);
43 bool findInSubGroups(SourceGroupImpl *group) const;
45 void collectPlayingSourceIds(Vector<ALuint> &sourceids) const;
46 void updatePausedStatus() const;
48 void collectPausedSourceIds(Vector<ALuint> &sourceids) const;
49 void updatePlayingStatus() const;
51 void collectSourceIds(Vector<ALuint> &sourceids) const;
52 void updateStoppedStatus() const;
54 public:
55 SourceGroupImpl(ContextImpl *context, String name)
56 : mContext(context), mParent(nullptr), mName(std::move(name))
57 { }
59 ALfloat getAppliedGain() const { return mGain * mParentProps.mGain; }
60 ALfloat getAppliedPitch() const { return mPitch * mParentProps.mPitch; }
62 void addSource(Source source);
63 void removeSource(Source source);
65 void addSources(ArrayView<Source> sources);
66 void removeSources(ArrayView<Source> sources);
68 void addSubGroup(SourceGroup group);
69 void removeSubGroup(SourceGroup group);
71 Vector<Source> getSources() const;
73 Vector<SourceGroup> getSubGroups() const;
75 void setGain(ALfloat gain);
76 ALfloat getGain() const { return mGain; }
78 void setPitch(ALfloat pitch);
79 ALfloat getPitch() const { return mPitch; }
81 void pauseAll() const;
82 void resumeAll() const;
84 void stopAll() const;
86 const String &getName() const { return mName; }
88 void release();
91 } // namespace alure2
93 #endif /* SOURCEGROUP_H */