Avoid an unnecessary move of a string
[alure.git] / src / sourcegroup.h
blob086757c606002d1714ecec7adc137f23896b71b8
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 update(ALfloat gain, ALfloat pitch);
30 void unsetParent();
32 void insertSubGroup(SourceGroupImpl *group);
33 void eraseSubGroup(SourceGroupImpl *group);
35 bool findInSubGroups(SourceGroupImpl *group) const;
37 void collectPlayingSourceIds(Vector<ALuint> &sourceids) const;
38 void updatePausedStatus() const;
40 void collectPausedSourceIds(Vector<ALuint> &sourceids) const;
41 void updatePlayingStatus() const;
43 void collectSourceIds(Vector<ALuint> &sourceids) const;
44 void updateStoppedStatus() const;
46 public:
47 SourceGroupImpl(ContextImpl *context, StringView name)
48 : mContext(context), mParent(nullptr), mName(String(name))
49 { }
51 ALfloat getAppliedGain() const { return mGain * mParentProps.mGain; }
52 ALfloat getAppliedPitch() const { return mPitch * mParentProps.mPitch; }
54 void insertSource(SourceImpl *source);
55 void eraseSource(SourceImpl *source);
57 void setParentGroup(SourceGroup group);
58 SourceGroup getParentGroup() const { return SourceGroup(mParent); }
60 Vector<Source> getSources() const;
62 Vector<SourceGroup> getSubGroups() const;
64 void setGain(ALfloat gain);
65 ALfloat getGain() const { return mGain; }
67 void setPitch(ALfloat pitch);
68 ALfloat getPitch() const { return mPitch; }
70 void pauseAll() const;
71 void resumeAll() const;
73 void stopAll() const;
75 StringView getName() const { return mName; }
77 void release();
80 } // namespace alure2
82 #endif /* SOURCEGROUP_H */