From ced61e94d88bf3216d13eddf1a90e1ff9bfdf525 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Thu, 15 Aug 2013 08:48:21 -0700 Subject: [PATCH] added more doxygen comments --- interface/src/VoxelEditPacketSender.h | 15 +++++++++++---- interface/src/VoxelPacketProcessor.h | 5 ++++- libraries/shared/src/GenericThread.h | 2 ++ libraries/shared/src/PacketSender.h | 12 +++++++++--- libraries/shared/src/ReceivedPacketProcessor.h | 4 ++-- 5 files changed, 28 insertions(+), 10 deletions(-) diff --git a/interface/src/VoxelEditPacketSender.h b/interface/src/VoxelEditPacketSender.h index f0d18e85f4..41c15ac8d2 100644 --- a/interface/src/VoxelEditPacketSender.h +++ b/interface/src/VoxelEditPacketSender.h @@ -16,6 +16,7 @@ class Application; +/// Used for construction of edit voxel packets class EditPacketBuffer { public: EditPacketBuffer() { _currentSize = 0; _currentType = PACKET_TYPE_UNKNOWN; _nodeID = UNKNOWN_NODE_ID; } @@ -25,14 +26,20 @@ public: ssize_t _currentSize; }; +/// Threaded processor for queueing and sending of outbound edit voxel packets. class VoxelEditPacketSender : public PacketSender { public: VoxelEditPacketSender(Application* app); - // Some ways you can send voxel edit messages... - void sendVoxelEditMessage(PACKET_TYPE type, VoxelDetail& detail); // sends it right away - void queueVoxelEditMessage(PACKET_TYPE type, unsigned char* codeColorBuffer, ssize_t length); // queues it into a multi-command packet - void flushQueue(); // flushes all queued packets + /// Send voxel edit message immediately + void sendVoxelEditMessage(PACKET_TYPE type, VoxelDetail& detail); + + /// Queues a voxel edit message. Will potentially sends a pending multi-command packet. Determines which voxel-server + /// node or nodes the packet should be sent to. + void queueVoxelEditMessage(PACKET_TYPE type, unsigned char* codeColorBuffer, ssize_t length); + + /// flushes all queued packets for all nodes + void flushQueue(); private: void actuallySendMessage(uint16_t nodeID, unsigned char* bufferOut, ssize_t sizeOut); diff --git a/interface/src/VoxelPacketProcessor.h b/interface/src/VoxelPacketProcessor.h index 725d69e181..f55daf5aba 100644 --- a/interface/src/VoxelPacketProcessor.h +++ b/interface/src/VoxelPacketProcessor.h @@ -15,11 +15,14 @@ class Application; +/// Handles processing of incoming voxel packets for the interface application. class VoxelPacketProcessor : public ReceivedPacketProcessor { public: VoxelPacketProcessor(Application* app); - virtual void processPacket(sockaddr& senderAddress, unsigned char* packetData, ssize_t packetLength); +protected: + virtual void processPacket(sockaddr& senderAddress, unsigned char* packetData, ssize_t packetLength); + private: Application* _app; }; diff --git a/libraries/shared/src/GenericThread.h b/libraries/shared/src/GenericThread.h index aa55adf4bf..2d4c90a469 100644 --- a/libraries/shared/src/GenericThread.h +++ b/libraries/shared/src/GenericThread.h @@ -36,6 +36,8 @@ protected: /// Locks all the resources of the thread. void lock() { pthread_mutex_lock(&_mutex); } + + /// Unlocks all the resources of the thread. void unlock() { pthread_mutex_unlock(&_mutex); } private: diff --git a/libraries/shared/src/PacketSender.h b/libraries/shared/src/PacketSender.h index 72b61011cc..5a1a63695f 100644 --- a/libraries/shared/src/PacketSender.h +++ b/libraries/shared/src/PacketSender.h @@ -14,16 +14,22 @@ #include "GenericThread.h" #include "NetworkPacket.h" +/// Generalized threaded processor for queueing and sending of outbound packets. class PacketSender : public GenericThread { public: PacketSender(); - // Call this when you have a packet you'd like sent... + + /// Add packet to outbound queue. + /// \param sockaddr& address the destination address + /// \param packetData pointer to data + /// \param ssize_t packetLength size of data + /// \thread any thread, typically the application thread void queuePacket(sockaddr& address, unsigned char* packetData, ssize_t packetLength); - virtual bool process(); - private: + virtual bool process(); + std::vector _packets; uint64_t _lastSendTime; diff --git a/libraries/shared/src/ReceivedPacketProcessor.h b/libraries/shared/src/ReceivedPacketProcessor.h index a132267482..0ea1aba2c1 100644 --- a/libraries/shared/src/ReceivedPacketProcessor.h +++ b/libraries/shared/src/ReceivedPacketProcessor.h @@ -14,7 +14,7 @@ #include "GenericThread.h" #include "NetworkPacket.h" -/// Generalized threaded processor for handler received inbound packets. +/// Generalized threaded processor for handling received inbound packets. class ReceivedPacketProcessor : public GenericThread { public: @@ -25,6 +25,7 @@ public: /// \thread network receive thread void queuePacket(sockaddr& senderAddress, unsigned char* packetData, ssize_t packetLength); +protected: /// Callback for processing of recieved packets. Implement this to process the incoming packets. /// \param sockaddr& senderAddress the address of the sender /// \param packetData pointer to received data @@ -32,7 +33,6 @@ public: /// \thread "this" individual processing thread virtual void processPacket(sockaddr& senderAddress, unsigned char* packetData, ssize_t packetLength) = 0; -protected: /// Implements generic processing behavior for this thread. virtual bool process(); private: