00001 /********************************************************************** 00002 ** This program is part of 'MOOSE', the 00003 ** Messaging Object Oriented Simulation Environment. 00004 ** Copyright (C) 2003-2010 Upinder S. Bhalla. and NCBS 00005 ** It is made available under the terms of the 00006 ** GNU Lesser General Public License version 2.1 00007 ** See the file COPYING.LIB for the full notice. 00008 **********************************************************************/ 00009 00015 class PrepackedBuffer 00016 { 00017 public: 00026 PrepackedBuffer( const char* data, unsigned int dataSize, 00027 unsigned int numEntries = 0 ); 00028 00029 PrepackedBuffer( const PrepackedBuffer& other ); 00030 00036 PrepackedBuffer( const char* buf ); 00037 00038 PrepackedBuffer(); 00039 00040 ~PrepackedBuffer(); 00041 00042 const char* data() const { 00043 return data_; 00044 } 00045 00051 const char* operator[]( unsigned int index ) const; 00052 00056 unsigned int dataSize() const { 00057 return dataSize_; 00058 } 00059 00063 unsigned int size() const { 00064 return dataSize_ + 2 * sizeof( unsigned int ); 00065 } 00066 00070 unsigned int conv2buf( char* buf ) const; 00071 00075 unsigned int numEntries() const { 00076 return numEntries_; 00077 } 00078 00082 bool isVector() const { 00083 return numEntries_ > 0; 00084 } 00085 private: 00086 unsigned int dataSize_; // Size of data. 00087 unsigned int numEntries_; // Number of data entries, if array. 00088 unsigned int individualDataSize_; // size of each entry. 00089 char* data_; // Converted data. 00090 };