Rename AL* implementation classes to *Impl
[alure.git] / src / sourcegroup.h
blobf1c4aa4d8efa7ae96643145413b1e1004d4d8d66
1 #ifndef SOURCEGROUP_H
2 #define SOURCEGROUP_H
4 #include "main.h"
7 namespace alure
10 class ContextImpl;
11 class SourceImpl;
13 struct SourceGroupProps {
14 ALfloat mGain;
15 ALfloat mPitch;
17 SourceGroupProps() : mGain(1.0f), mPitch(1.0f) { }
20 class SourceGroupImpl : SourceGroupProps {
21 ContextImpl *const mContext;
23 Vector<SourceImpl*> mSources;
24 Vector<SourceGroupImpl*> mSubGroups;
26 SourceGroupProps mParentProps;
27 SourceGroupImpl *mParent;
29 const String mName;
31 void applyPropTree(SourceGroupProps &props) const
33 props.mGain *= mGain;
34 props.mPitch *= mPitch;
35 if(mParent)
36 mParent->applyPropTree(props);
39 void update(ALfloat gain, ALfloat pitch);
41 void setParentGroup(SourceGroupImpl *group);
42 void unsetParentGroup();
44 void eraseSubGroup(SourceGroupImpl *group);
46 bool findInSubGroups(SourceGroupImpl *group) const;
48 void collectPlayingSourceIds(Vector<ALuint> &sourceids) const;
49 void updatePausedStatus() const;
51 void collectPausedSourceIds(Vector<ALuint> &sourceids) const;
52 void updatePlayingStatus() const;
54 void collectSourceIds(Vector<ALuint> &sourceids) const;
55 void updateStoppedStatus() const;
57 public:
58 SourceGroupImpl(ContextImpl *context, String name)
59 : mContext(context), mParent(nullptr), mName(std::move(name))
60 { }
62 ALfloat getAppliedGain() const { return mGain * mParentProps.mGain; }
63 ALfloat getAppliedPitch() const { return mPitch * mParentProps.mPitch; }
65 void addSource(Source source);
66 void removeSource(Source source);
68 void addSources(ArrayView<Source> sources);
69 void removeSources(ArrayView<Source> sources);
71 void addSubGroup(SourceGroup group);
72 void removeSubGroup(SourceGroup group);
74 Vector<Source> getSources() const;
76 Vector<SourceGroup> getSubGroups() const;
78 void setGain(ALfloat gain);
79 ALfloat getGain() const { return mGain; }
81 void setPitch(ALfloat pitch);
82 ALfloat getPitch() const { return mPitch; }
84 void pauseAll() const;
85 void resumeAll() const;
87 void stopAll() const;
89 const String &getName() const { return mName; }
91 void release();
94 } // namespace alure2
96 #endif /* SOURCEGROUP_H */