From 8676ac38f987f55fc25d777157ded98cc8d042c1 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Tue, 14 Jan 2014 15:54:09 -0800 Subject: [PATCH] foreach spacing and reference repairs --- assignment-client/src/audio/AudioMixer.cpp | 8 ++++---- assignment-client/src/avatars/AvatarMixer.cpp | 6 +++--- domain-server/src/DomainServer.cpp | 10 +++++----- interface/src/Application.cpp | 14 +++++++------- interface/src/DataServerClient.cpp | 4 ++-- interface/src/VoxelSystem.cpp | 2 +- interface/src/avatar/Hand.cpp | 2 +- interface/src/avatar/MyAvatar.cpp | 2 +- interface/src/ui/VoxelStatsDialog.cpp | 2 +- libraries/octree/src/JurisdictionListener.cpp | 2 +- libraries/octree/src/OctreeEditPacketSender.cpp | 8 ++++---- .../particles/src/ParticleCollisionSystem.cpp | 2 +- libraries/shared/src/NodeList.cpp | 12 ++++++------ 13 files changed, 37 insertions(+), 37 deletions(-) diff --git a/assignment-client/src/audio/AudioMixer.cpp b/assignment-client/src/audio/AudioMixer.cpp index 0524576474..37756679b0 100644 --- a/assignment-client/src/audio/AudioMixer.cpp +++ b/assignment-client/src/audio/AudioMixer.cpp @@ -188,7 +188,7 @@ void AudioMixer::prepareMixForListeningNode(Node* node) { memset(_clientSamples, 0, sizeof(_clientSamples)); // loop through all other nodes that have sufficient audio to mix - foreach(SharedNodePointer otherNode, NodeList::getInstance()->getNodeHash()) { + foreach (const SharedNodePointer& otherNode, NodeList::getInstance()->getNodeHash()) { if (otherNode->getLinkedData()) { AudioMixerClientData* otherNodeClientData = (AudioMixerClientData*) otherNode->getLinkedData(); @@ -263,13 +263,13 @@ void AudioMixer::run() { break; } - foreach(SharedNodePointer node, nodeList->getNodeHash()) { + foreach (const SharedNodePointer& node, nodeList->getNodeHash()) { if (node->getLinkedData()) { ((AudioMixerClientData*) node->getLinkedData())->checkBuffersBeforeFrameSend(JITTER_BUFFER_SAMPLES); } } - foreach(SharedNodePointer node, nodeList->getNodeHash()) { + foreach (const SharedNodePointer& node, nodeList->getNodeHash()) { if (node->getType() == NODE_TYPE_AGENT && node->getActiveSocket() && node->getLinkedData() && ((AudioMixerClientData*) node->getLinkedData())->getAvatarAudioRingBuffer()) { prepareMixForListeningNode(node.data()); @@ -282,7 +282,7 @@ void AudioMixer::run() { } // push forward the next output pointers for any audio buffers we used - foreach(SharedNodePointer node, nodeList->getNodeHash()) { + foreach (const SharedNodePointer& node, nodeList->getNodeHash()) { if (node->getLinkedData()) { ((AudioMixerClientData*) node->getLinkedData())->pushBuffersAfterFrameSend(); } diff --git a/assignment-client/src/avatars/AvatarMixer.cpp b/assignment-client/src/avatars/AvatarMixer.cpp index 67685cf085..b9aa911bf0 100644 --- a/assignment-client/src/avatars/AvatarMixer.cpp +++ b/assignment-client/src/avatars/AvatarMixer.cpp @@ -67,7 +67,7 @@ void broadcastAvatarData() { NodeList* nodeList = NodeList::getInstance(); - foreach(SharedNodePointer node, nodeList->getNodeHash()) { + foreach (const SharedNodePointer& node, nodeList->getNodeHash()) { if (node->getLinkedData() && node->getType() == NODE_TYPE_AGENT && node->getActiveSocket()) { // reset packet pointers for this node @@ -76,7 +76,7 @@ void broadcastAvatarData() { // this is an AGENT we have received head data from // send back a packet with other active node data to this node - foreach(SharedNodePointer otherNode, nodeList->getNodeHash()) { + foreach (const SharedNodePointer& otherNode, nodeList->getNodeHash()) { if (otherNode->getLinkedData() && otherNode->getUUID() != node->getUUID()) { unsigned char* avatarDataEndpoint = addNodeToBroadcastPacket((unsigned char*)&avatarDataBuffer[0], @@ -142,7 +142,7 @@ void AvatarMixer::processDatagram(const QByteArray& dataByteArray, const HifiSoc QUuid nodeUUID = QUuid::fromRfc4122(dataByteArray.mid(numBytesForPacketHeader((unsigned char*) dataByteArray.data()), NUM_BYTES_RFC4122_UUID)); // let everyone else know about the update - foreach(SharedNodePointer node, nodeList->getNodeHash()) { + foreach (const SharedNodePointer& node, nodeList->getNodeHash()) { if (node->getActiveSocket() && node->getUUID() != nodeUUID) { nodeList->getNodeSocket().writeDatagram(dataByteArray, node->getActiveSocket()->getAddress(), diff --git a/domain-server/src/DomainServer.cpp b/domain-server/src/DomainServer.cpp index 6fe2aff926..a295a9c1c1 100644 --- a/domain-server/src/DomainServer.cpp +++ b/domain-server/src/DomainServer.cpp @@ -201,7 +201,7 @@ void DomainServer::readAvailableDatagrams() { if (numInterestTypes > 0) { // if the node has sent no types of interest, assume they want nothing but their own ID back - foreach(SharedNodePointer node, nodeList->getNodeHash()) { + foreach (const SharedNodePointer& node, nodeList->getNodeHash()) { if (node->getUUID() != nodeUUID && memchr(nodeTypesOfInterest, node->getType(), numInterestTypes)) { @@ -318,7 +318,7 @@ int DomainServer::civetwebRequestHandler(struct mg_connection *connection) { QJsonObject assignedNodesJSON; // enumerate the NodeList to find the assigned nodes - foreach(SharedNodePointer node, NodeList::getInstance()->getNodeHash()) { + foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) { if (node->getLinkedData()) { // add the node using the UUID as the key QString uuidString = uuidStringWithoutCurlyBraces(node->getUUID()); @@ -370,7 +370,7 @@ int DomainServer::civetwebRequestHandler(struct mg_connection *connection) { // enumerate the NodeList to find the assigned nodes NodeList* nodeList = NodeList::getInstance(); - foreach(SharedNodePointer node, nodeList->getNodeHash()) { + foreach (const SharedNodePointer& node, nodeList->getNodeHash()) { // add the node using the UUID as the key QString uuidString = uuidStringWithoutCurlyBraces(node->getUUID()); nodesJSON[uuidString] = jsonObjectForNode(node.data()); @@ -735,7 +735,7 @@ bool DomainServer::checkInWithUUIDMatchesExistingNode(const HifiSockAddr& nodePu const QUuid& checkInUUID) { NodeList* nodeList = NodeList::getInstance(); - foreach(SharedNodePointer node, nodeList->getNodeHash()) { + foreach (const SharedNodePointer& node, nodeList->getNodeHash()) { if (node->getLinkedData() && nodePublicSocket == node->getPublicSocket() && nodeLocalSocket == node->getLocalSocket() @@ -767,7 +767,7 @@ void DomainServer::addStaticAssignmentsBackToQueueAfterRestart() { NodeList* nodeList = NodeList::getInstance(); // enumerate the nodes and check if there is one with an attached assignment with matching UUID - foreach(SharedNodePointer node, nodeList->getNodeHash()) { + foreach (const SharedNodePointer& node, nodeList->getNodeHash()) { if (node->getLinkedData()) { Assignment* linkedAssignment = (Assignment*) node->getLinkedData(); if (linkedAssignment->getUUID() == _staticAssignments[i].getUUID()) { diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index ac6ddf2a2b..3a821677d6 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1969,7 +1969,7 @@ void Application::updateLookatTargetAvatar(const glm::vec3& mouseRayOrigin, cons Avatar* Application::findLookatTargetAvatar(const glm::vec3& mouseRayOrigin, const glm::vec3& mouseRayDirection, glm::vec3& eyePosition, QUuid& nodeUUID = DEFAULT_NODE_ID_REF) { - foreach(SharedNodePointer node, NodeList::getInstance()->getNodeHash()) { + foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) { if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) { Avatar* avatar = (Avatar*)node->getLinkedData(); float distance; @@ -2029,7 +2029,7 @@ void Application::updateAvatars(float deltaTime, glm::vec3 mouseRayOrigin, glm:: bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); PerformanceWarning warn(showWarnings, "Application::updateAvatars()"); - foreach(SharedNodePointer node, NodeList::getInstance()->getNodeHash()) { + foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) { QMutexLocker(&node->getMutex()); if (node->getLinkedData()) { Avatar *avatar = (Avatar *)node->getLinkedData(); @@ -2657,7 +2657,7 @@ void Application::queryOctree(NODE_TYPE serverType, PACKET_TYPE packetType, Node int inViewServers = 0; int unknownJurisdictionServers = 0; - foreach(SharedNodePointer node, NodeList::getInstance()->getNodeHash()) { + foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) { // only send to the NodeTypes that are serverType if (node->getActiveSocket() != NULL && node->getType() == serverType) { totalServers++; @@ -2717,7 +2717,7 @@ void Application::queryOctree(NODE_TYPE serverType, PACKET_TYPE packetType, Node NodeList* nodeList = NodeList::getInstance(); - foreach(SharedNodePointer node, nodeList->getNodeHash()) { + foreach (const SharedNodePointer& node, nodeList->getNodeHash()) { // only send to the NodeTypes that are serverType if (node->getActiveSocket() != NULL && node->getType() == serverType) { @@ -3292,7 +3292,7 @@ void Application::displayOverlay() { int totalAvatars = 0, totalServers = 0; - foreach(SharedNodePointer node, NodeList::getInstance()->getNodeHash()) { + foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) { node->getType() == NODE_TYPE_AGENT ? totalAvatars++ : totalServers++; } @@ -3406,7 +3406,7 @@ void Application::displayStats() { unsigned long totalPingVoxel = 0; int voxelServerCount = 0; - foreach(SharedNodePointer node, nodeList->getNodeHash()) { + foreach (const SharedNodePointer& node, nodeList->getNodeHash()) { if (node->getType() == NODE_TYPE_VOXEL_SERVER) { totalPingVoxel += node->getPingMs(); voxelServerCount++; @@ -3757,7 +3757,7 @@ void Application::renderAvatars(bool forceRenderHead, bool selfAvatarOnly) { // Render avatars of other nodes NodeList* nodeList = NodeList::getInstance(); - foreach(SharedNodePointer node, nodeList->getNodeHash()) { + foreach (const SharedNodePointer& node, nodeList->getNodeHash()) { QMutexLocker(&node->getMutex()); if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) { diff --git a/interface/src/DataServerClient.cpp b/interface/src/DataServerClient.cpp index 34fe0b165c..306b68536a 100644 --- a/interface/src/DataServerClient.cpp +++ b/interface/src/DataServerClient.cpp @@ -145,7 +145,7 @@ void DataServerClient::processSendFromDataServer(unsigned char* packetData, int } else { // mesh URL for a UUID, find avatar in our list - foreach(SharedNodePointer node, NodeList::getInstance()->getNodeHash()) { + foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) { if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) { Avatar* avatar = (Avatar *) node->getLinkedData(); @@ -163,7 +163,7 @@ void DataServerClient::processSendFromDataServer(unsigned char* packetData, int Application::getInstance()->getProfile()->setSkeletonModelURL(QUrl(valueList[i])); } else { // skeleton URL for a UUID, find avatar in our list - foreach(SharedNodePointer node, NodeList::getInstance()->getNodeHash()) { + foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) { if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) { Avatar* avatar = (Avatar *) node->getLinkedData(); diff --git a/interface/src/VoxelSystem.cpp b/interface/src/VoxelSystem.cpp index 7dfa4158cf..e66f4cb7f1 100644 --- a/interface/src/VoxelSystem.cpp +++ b/interface/src/VoxelSystem.cpp @@ -1605,7 +1605,7 @@ void VoxelSystem::falseColorizeBySource() { // create a bunch of colors we'll use during colorization - foreach(SharedNodePointer node, NodeList::getInstance()->getNodeHash()) { + foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) { if (node->getType() == NODE_TYPE_VOXEL_SERVER) { uint16_t nodeID = VoxelTreeElement::getSourceNodeUUIDKey(node->getUUID()); int groupColor = voxelServerCount % NUMBER_OF_COLOR_GROUPS; diff --git a/interface/src/avatar/Hand.cpp b/interface/src/avatar/Hand.cpp index 78be4a1864..2784e0a115 100644 --- a/interface/src/avatar/Hand.cpp +++ b/interface/src/avatar/Hand.cpp @@ -368,7 +368,7 @@ void Hand::updateCollisions() { glm::vec3 totalPenetration; // check other avatars - foreach(SharedNodePointer node, NodeList::getInstance()->getNodeHash()) { + foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) { if (node->getLinkedData() && node->getType() == NODE_TYPE_AGENT) { Avatar* otherAvatar = (Avatar*)node->getLinkedData(); if (Menu::getInstance()->isOptionChecked(MenuOption::PlaySlaps)) { diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index 1e6b2565ce..76f946d7a4 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -843,7 +843,7 @@ void MyAvatar::updateChatCircle(float deltaTime) { // find all circle-enabled members and sort by distance QVector sortedAvatars; - foreach(SharedNodePointer node, NodeList::getInstance()->getNodeHash()) { + foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) { if (node->getLinkedData() && node->getType() == NODE_TYPE_AGENT) { SortedAvatar sortedAvatar; sortedAvatar.avatar = (Avatar*)node->getLinkedData(); diff --git a/interface/src/ui/VoxelStatsDialog.cpp b/interface/src/ui/VoxelStatsDialog.cpp index e154e30c74..9bf755b174 100644 --- a/interface/src/ui/VoxelStatsDialog.cpp +++ b/interface/src/ui/VoxelStatsDialog.cpp @@ -244,7 +244,7 @@ void VoxelStatsDialog::showOctreeServersOfType(int& serverCount, NODE_TYPE serve NodeList* nodeList = NodeList::getInstance(); - foreach(SharedNodePointer node, nodeList->getNodeHash()) { + foreach (const SharedNodePointer& node, nodeList->getNodeHash()) { // only send to the NodeTypes that are NODE_TYPE_VOXEL_SERVER if (node->getType() == serverType) { serverCount++; diff --git a/libraries/octree/src/JurisdictionListener.cpp b/libraries/octree/src/JurisdictionListener.cpp index 60a3eddd57..ae27259f83 100644 --- a/libraries/octree/src/JurisdictionListener.cpp +++ b/libraries/octree/src/JurisdictionListener.cpp @@ -44,7 +44,7 @@ bool JurisdictionListener::queueJurisdictionRequest() { NodeList* nodeList = NodeList::getInstance(); - foreach(SharedNodePointer node, nodeList->getNodeHash()) { + foreach (const SharedNodePointer& node, nodeList->getNodeHash()) { if (nodeList->getNodeActiveSocketOrPing(node.data()) && node->getType() == getNodeType()) { const HifiSockAddr* nodeAddress = node->getActiveSocket(); diff --git a/libraries/octree/src/OctreeEditPacketSender.cpp b/libraries/octree/src/OctreeEditPacketSender.cpp index b7a31f166b..4763ed055a 100644 --- a/libraries/octree/src/OctreeEditPacketSender.cpp +++ b/libraries/octree/src/OctreeEditPacketSender.cpp @@ -58,7 +58,7 @@ bool OctreeEditPacketSender::serversExist() const { bool atLeastOnJurisdictionMissing = false; // assume the best NodeList* nodeList = NodeList::getInstance(); - foreach(SharedNodePointer node, nodeList->getNodeHash()) { + foreach (const SharedNodePointer& node, nodeList->getNodeHash()) { // only send to the NodeTypes that are getMyNodeType() if (node->getType() == getMyNodeType()) { if (nodeList->getNodeActiveSocketOrPing(node.data())) { @@ -87,7 +87,7 @@ bool OctreeEditPacketSender::serversExist() const { void OctreeEditPacketSender::queuePacketToNode(const QUuid& nodeUUID, unsigned char* buffer, ssize_t length) { NodeList* nodeList = NodeList::getInstance(); - foreach(SharedNodePointer node, nodeList->getNodeHash()) { + foreach (const SharedNodePointer& node, nodeList->getNodeHash()) { // only send to the NodeTypes that are getMyNodeType() if (node->getType() == getMyNodeType() && ((node->getUUID() == nodeUUID) || (nodeUUID.isNull()))) { @@ -170,7 +170,7 @@ void OctreeEditPacketSender::queuePacketToNodes(unsigned char* buffer, ssize_t l // for a different server... So we need to actually manage multiple queued packets... one // for each server - foreach(SharedNodePointer node, NodeList::getInstance()->getNodeHash()) { + foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) { // only send to the NodeTypes that are getMyNodeType() if (node->getActiveSocket() != NULL && node->getType() == getMyNodeType()) { QUuid nodeUUID = node->getUUID(); @@ -216,7 +216,7 @@ void OctreeEditPacketSender::queueOctreeEditMessage(PACKET_TYPE type, unsigned c // for a different server... So we need to actually manage multiple queued packets... one // for each server - foreach(SharedNodePointer node, NodeList::getInstance()->getNodeHash()) { + foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) { // only send to the NodeTypes that are getMyNodeType() if (node->getActiveSocket() != NULL && node->getType() == getMyNodeType()) { QUuid nodeUUID = node->getUUID(); diff --git a/libraries/particles/src/ParticleCollisionSystem.cpp b/libraries/particles/src/ParticleCollisionSystem.cpp index 3ef831d9c7..0bf5db90f0 100644 --- a/libraries/particles/src/ParticleCollisionSystem.cpp +++ b/libraries/particles/src/ParticleCollisionSystem.cpp @@ -188,7 +188,7 @@ void ParticleCollisionSystem::updateCollisionWithAvatars(Particle* particle) { // loop through all the other avatars for potential interactions... - foreach(SharedNodePointer node, NodeList::getInstance()->getNodeHash()) { + foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) { //qDebug() << "updateCollisionWithAvatars()... node:" << *node << "\n"; if (node->getLinkedData() && node->getType() == NODE_TYPE_AGENT) { // TODO: dot collidingPalm and hand velocities and skip collision when they are moving apart. diff --git a/libraries/shared/src/NodeList.cpp b/libraries/shared/src/NodeList.cpp index b95efb550b..972c617de3 100644 --- a/libraries/shared/src/NodeList.cpp +++ b/libraries/shared/src/NodeList.cpp @@ -110,7 +110,7 @@ void NodeList::setDomainHostname(const QString& domainHostname) { } void NodeList::timePingReply(const HifiSockAddr& nodeAddress, unsigned char *packetData) { - foreach(SharedNodePointer node, _nodeHash) { + foreach (const SharedNodePointer& node, _nodeHash) { if (node->getPublicSocket() == nodeAddress || node->getLocalSocket() == nodeAddress) { @@ -254,7 +254,7 @@ int NodeList::updateNodeWithData(Node *node, const HifiSockAddr& senderSockAddr, SharedNodePointer NodeList::nodeWithAddress(const HifiSockAddr &senderSockAddr) { // naively returns the first node that has a matching active HifiSockAddr // note that there can be multiple nodes that have a matching active socket, so this isn't a good way to uniquely identify - foreach(SharedNodePointer node, _nodeHash) { + foreach (const SharedNodePointer& node, _nodeHash) { if (node->getActiveSocket() && *node->getActiveSocket() == senderSockAddr) { return node; } @@ -721,7 +721,7 @@ SharedNodePointer NodeList::addOrUpdateNode(const QUuid& uuid, char nodeType, unsigned NodeList::broadcastToNodes(unsigned char* broadcastData, size_t dataBytes, const char* nodeTypes, int numNodeTypes) { unsigned n = 0; - foreach(SharedNodePointer node, _nodeHash) { + foreach (const SharedNodePointer& node, _nodeHash) { // only send to the NodeTypes we are asked to send to. if (memchr(nodeTypes, node->getType(), numNodeTypes)) { if (getNodeActiveSocketOrPing(node.data())) { @@ -737,7 +737,7 @@ unsigned NodeList::broadcastToNodes(unsigned char* broadcastData, size_t dataByt } void NodeList::pingInactiveNodes() { - foreach(SharedNodePointer node, _nodeHash) { + foreach (const SharedNodePointer& node, _nodeHash) { if (!node->getActiveSocket()) { // we don't have an active link to this node, ping it to set that up pingPublicAndLocalSocketsForInactiveNode(node.data()); @@ -756,7 +756,7 @@ const HifiSockAddr* NodeList::getNodeActiveSocketOrPing(Node* node) { void NodeList::activateSocketFromNodeCommunication(const HifiSockAddr& nodeAddress) { - foreach(SharedNodePointer node, _nodeHash) { + foreach (const SharedNodePointer& node, _nodeHash) { if (!node->getActiveSocket()) { // check both the public and local addresses for each node to see if we find a match // prioritize the private address so that we prune erroneous local matches @@ -774,7 +774,7 @@ void NodeList::activateSocketFromNodeCommunication(const HifiSockAddr& nodeAddre SharedNodePointer NodeList::soloNodeOfType(char nodeType) { if (memchr(SOLO_NODE_TYPES, nodeType, sizeof(SOLO_NODE_TYPES)) != NULL) { - foreach(SharedNodePointer node, _nodeHash) { + foreach (const SharedNodePointer& node, _nodeHash) { if (node->getType() == nodeType) { return node; }