mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
AudioProcessorGraph: Add constexpr annotations
This commit is contained in:
parent
20b5e92559
commit
a31cadaa18
2 changed files with 46 additions and 55 deletions
|
|
@ -1035,20 +1035,20 @@ private:
|
|||
{
|
||||
NodeAndChannel channel;
|
||||
|
||||
static AssignedBuffer createReadOnlyEmpty() noexcept { return { { zeroNodeID(), 0 } }; }
|
||||
static AssignedBuffer createFree() noexcept { return { { freeNodeID(), 0 } }; }
|
||||
static constexpr AssignedBuffer createReadOnlyEmpty() noexcept { return { { zeroNodeID, 0 } }; }
|
||||
static constexpr AssignedBuffer createFree() noexcept { return { { freeNodeID, 0 } }; }
|
||||
|
||||
bool isReadOnlyEmpty() const noexcept { return channel.nodeID == zeroNodeID(); }
|
||||
bool isFree() const noexcept { return channel.nodeID == freeNodeID(); }
|
||||
bool isAssigned() const noexcept { return ! (isReadOnlyEmpty() || isFree()); }
|
||||
constexpr bool isReadOnlyEmpty() const noexcept { return channel.nodeID == zeroNodeID; }
|
||||
constexpr bool isFree() const noexcept { return channel.nodeID == freeNodeID; }
|
||||
constexpr bool isAssigned() const noexcept { return ! (isReadOnlyEmpty() || isFree()); }
|
||||
|
||||
void setFree() noexcept { channel = { freeNodeID(), 0 }; }
|
||||
void setAssignedToNonExistentNode() noexcept { channel = { anonNodeID(), 0 }; }
|
||||
constexpr void setFree() noexcept { channel = { freeNodeID, 0 }; }
|
||||
constexpr void setAssignedToNonExistentNode() noexcept { channel = { anonNodeID, 0 }; }
|
||||
|
||||
private:
|
||||
static NodeID anonNodeID() { return NodeID (0x7ffffffd); }
|
||||
static NodeID zeroNodeID() { return NodeID (0x7ffffffe); }
|
||||
static NodeID freeNodeID() { return NodeID (0x7fffffff); }
|
||||
constexpr static inline NodeID anonNodeID { 0x7ffffffd };
|
||||
constexpr static inline NodeID zeroNodeID { 0x7ffffffe };
|
||||
constexpr static inline NodeID freeNodeID { 0x7fffffff };
|
||||
};
|
||||
|
||||
Array<AssignedBuffer> audioBuffers, midiBuffers;
|
||||
|
|
@ -1676,34 +1676,6 @@ private:
|
|||
bool isNew = false;
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
AudioProcessorGraph::Connection::Connection (NodeAndChannel src, NodeAndChannel dst) noexcept
|
||||
: source (src), destination (dst)
|
||||
{
|
||||
}
|
||||
|
||||
bool AudioProcessorGraph::Connection::operator== (const Connection& other) const noexcept
|
||||
{
|
||||
return source == other.source && destination == other.destination;
|
||||
}
|
||||
|
||||
bool AudioProcessorGraph::Connection::operator!= (const Connection& c) const noexcept
|
||||
{
|
||||
return ! operator== (c);
|
||||
}
|
||||
|
||||
bool AudioProcessorGraph::Connection::operator< (const Connection& other) const noexcept
|
||||
{
|
||||
const auto tie = [] (auto& x)
|
||||
{
|
||||
return std::tie (x.source.nodeID,
|
||||
x.destination.nodeID,
|
||||
x.source.channelIndex,
|
||||
x.destination.channelIndex);
|
||||
};
|
||||
return tie (*this) < tie (other);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
class AudioProcessorGraph::Pimpl
|
||||
{
|
||||
|
|
|
|||
|
|
@ -67,14 +67,14 @@ public:
|
|||
/** Each node in the graph has a UID of this type. */
|
||||
struct NodeID
|
||||
{
|
||||
NodeID() {}
|
||||
explicit NodeID (uint32 i) : uid (i) {}
|
||||
constexpr NodeID() = default;
|
||||
explicit constexpr NodeID (uint32 i) : uid (i) {}
|
||||
|
||||
uint32 uid = 0;
|
||||
|
||||
bool operator== (const NodeID& other) const noexcept { return uid == other.uid; }
|
||||
bool operator!= (const NodeID& other) const noexcept { return uid != other.uid; }
|
||||
bool operator< (const NodeID& other) const noexcept { return uid < other.uid; }
|
||||
constexpr bool operator== (const NodeID& other) const noexcept { return uid == other.uid; }
|
||||
constexpr bool operator!= (const NodeID& other) const noexcept { return uid != other.uid; }
|
||||
constexpr bool operator< (const NodeID& other) const noexcept { return uid < other.uid; }
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -91,17 +91,17 @@ public:
|
|||
*/
|
||||
class NodeAndChannel
|
||||
{
|
||||
auto tie() const { return std::tie (nodeID, channelIndex); }
|
||||
constexpr auto tie() const { return std::tie (nodeID, channelIndex); }
|
||||
|
||||
public:
|
||||
NodeID nodeID;
|
||||
int channelIndex;
|
||||
|
||||
bool isMIDI() const noexcept { return channelIndex == midiChannelIndex; }
|
||||
constexpr bool isMIDI() const noexcept { return channelIndex == midiChannelIndex; }
|
||||
|
||||
bool operator== (const NodeAndChannel& other) const noexcept { return tie() == other.tie(); }
|
||||
bool operator!= (const NodeAndChannel& other) const noexcept { return tie() != other.tie(); }
|
||||
bool operator< (const NodeAndChannel& other) const noexcept { return tie() < other.tie(); }
|
||||
constexpr bool operator== (const NodeAndChannel& other) const noexcept { return tie() == other.tie(); }
|
||||
constexpr bool operator!= (const NodeAndChannel& other) const noexcept { return tie() != other.tie(); }
|
||||
constexpr bool operator< (const NodeAndChannel& other) const noexcept { return tie() < other.tie(); }
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -192,15 +192,34 @@ public:
|
|||
struct JUCE_API Connection
|
||||
{
|
||||
//==============================================================================
|
||||
Connection() = default;
|
||||
Connection (NodeAndChannel source, NodeAndChannel destination) noexcept;
|
||||
constexpr Connection() = default;
|
||||
constexpr Connection (NodeAndChannel sourceIn, NodeAndChannel destinationIn) noexcept
|
||||
: source (sourceIn), destination (destinationIn) {}
|
||||
|
||||
Connection (const Connection&) = default;
|
||||
Connection& operator= (const Connection&) = default;
|
||||
constexpr Connection (const Connection&) = default;
|
||||
constexpr Connection& operator= (const Connection&) = default;
|
||||
|
||||
bool operator== (const Connection&) const noexcept;
|
||||
bool operator!= (const Connection&) const noexcept;
|
||||
bool operator< (const Connection&) const noexcept;
|
||||
constexpr bool operator== (const Connection& other) const noexcept
|
||||
{
|
||||
return source == other.source && destination == other.destination;
|
||||
}
|
||||
|
||||
constexpr bool operator!= (const Connection& other) const noexcept
|
||||
{
|
||||
return ! operator== (other);
|
||||
}
|
||||
|
||||
constexpr bool operator< (const Connection& other) const noexcept
|
||||
{
|
||||
const auto tie = [] (auto& x)
|
||||
{
|
||||
return std::tie (x.source.nodeID,
|
||||
x.destination.nodeID,
|
||||
x.source.channelIndex,
|
||||
x.destination.channelIndex);
|
||||
};
|
||||
return tie (*this) < tie (other);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
/** The channel and node which is the input source for this connection. */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue