1 /* 2 * Copyright (c) 2004-2007 Marcus Overhagen <marcus@overhagen.de> 3 * 4 * Permission is hereby granted, free of charge, to any person 5 * obtaining a copy of this software and associated documentation 6 * files (the "Software"), to deal in the Software without restriction, 7 * including without limitation the rights to use, copy, modify, 8 * merge, publish, distribute, sublicense, and/or sell copies of 9 * the Software, and to permit persons to whom the Software is 10 * furnished to do so, subject to the following conditions: 11 * 12 * The above copyright notice and this permission notice shall be 13 * included in all copies or substantial portions of the Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 17 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 19 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 20 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 * OTHER DEALINGS IN THE SOFTWARE. 23 */ 24 25 #ifndef __PACKET_H 26 #define __PACKET_H 27 28 #include <SupportDefs.h> 29 30 class Packet 31 { 32 public: 33 Packet(size_t init_size = 8192); 34 Packet(const Packet &clone); 35 Packet(const void *data, size_t size, bigtime_t time_stamp = 0); 36 ~Packet(); 37 38 void AddData(const void *data, size_t size); 39 40 void MakeEmpty(); 41 42 const uint8 * Data() const; 43 size_t Size() const; 44 45 void SetTimeStamp(bigtime_t time_stamp); 46 bigtime_t TimeStamp() const; 47 48 49 private: 50 // not implemented 51 Packet & operator= (const Packet &clone); 52 53 private: 54 void * fBuffer; 55 size_t fBufferSize; 56 size_t fBufferSizeMax; 57 bigtime_t fTimeStamp; 58 }; 59 60 61 inline const uint8 * 62 Packet::Data() const 63 { 64 return (uint8 *)fBuffer; 65 } 66 67 68 inline size_t 69 Packet::Size() const 70 { 71 return fBufferSize; 72 } 73 74 75 inline void 76 Packet::SetTimeStamp(bigtime_t time_stamp) 77 { 78 fTimeStamp = time_stamp; 79 } 80 81 82 inline bigtime_t 83 Packet::TimeStamp() const 84 { 85 return fTimeStamp; 86 } 87 88 89 inline void 90 Packet::MakeEmpty() 91 { 92 fBufferSize = 0; 93 fTimeStamp = 0; 94 } 95 96 97 #endif 98