00001 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*- 00002 00003 // -- BEGIN LICENSE BLOCK ---------------------------------------------- 00004 00024 // -- END LICENSE BLOCK ------------------------------------------------ 00025 00026 //---------------------------------------------------------------------- 00033 //---------------------------------------------------------------------- 00034 00035 #ifndef SICK_SAFETYSCANNERS_DATA_PROCESSING_UDPPACKETMERGER_H 00036 #define SICK_SAFETYSCANNERS_DATA_PROCESSING_UDPPACKETMERGER_H 00037 00038 #include <sick_safetyscanners/datastructure/PacketBuffer.h> 00039 #include <sick_safetyscanners/datastructure/ParsedPacketBuffer.h> 00040 00041 #include <sick_safetyscanners/data_processing/ParseDatagramHeader.h> 00042 00043 #include <algorithm> 00044 00045 namespace sick { 00046 namespace data_processing { 00047 00051 class UDPPacketMerger 00052 { 00053 public: 00057 UDPPacketMerger(); 00058 00064 bool isComplete() const; 00065 00073 bool addUDPPacket(const sick::datastructure::PacketBuffer& buffer); 00074 00080 sick::datastructure::PacketBuffer getDeployedPacketBuffer(); 00081 00082 private: 00083 bool m_is_complete; 00084 sick::datastructure::PacketBuffer m_deployed_packet_buffer; 00085 00086 std::map<uint32_t, sick::datastructure::ParsedPacketBuffer::ParsedPacketBufferVector> 00087 m_parsed_packet_buffer_map; 00088 00089 bool addToMap(const sick::datastructure::PacketBuffer& buffer, 00090 const sick::datastructure::DatagramHeader& header); 00091 bool deployPacketIfComplete(datastructure::DatagramHeader& header); 00092 bool checkIfComplete(sick::datastructure::DatagramHeader& header); 00093 uint32_t calcualteCurrentLengthOfParsedPacketBuffer( 00094 const sick::datastructure::ParsedPacketBuffer::ParsedPacketBufferVector& vec); 00095 sick::datastructure::ParsedPacketBuffer::ParsedPacketBufferVector 00096 getSortedParsedPacketBufferForIdentification(const sick::datastructure::DatagramHeader& header); 00097 sick::datastructure::PacketBuffer::VectorBuffer removeHeaderFromParsedPacketBuffer( 00098 const sick::datastructure::ParsedPacketBuffer::ParsedPacketBufferVector& vec); 00099 }; 00100 00101 } // namespace data_processing 00102 } // namespace sick 00103 00104 #endif // SICK_SAFETYSCANNERS_DATA_PROCESSING_UDPPACKETMERGER_H