00001 /*---------------------------------------------------------------------------*\ 00002 * OpenSG * 00003 * * 00004 * * 00005 * Copyright (C) 2000-2002 by the OpenSG Forum * 00006 * * 00007 * www.opensg.org * 00008 * * 00009 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de * 00010 * * 00011 \*---------------------------------------------------------------------------*/ 00012 /*---------------------------------------------------------------------------*\ 00013 * License * 00014 * * 00015 * This library is free software; you can redistribute it and/or modify it * 00016 * under the terms of the GNU Library General Public License as published * 00017 * by the Free Software Foundation, version 2. * 00018 * * 00019 * This library is distributed in the hope that it will be useful, but * 00020 * WITHOUT ANY WARRANTY; without even the implied warranty of * 00021 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00022 * Library General Public License for more details. * 00023 * * 00024 * You should have received a copy of the GNU Library General Public * 00025 * License along with this library; if not, write to the Free Software * 00026 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 00027 * * 00028 \*---------------------------------------------------------------------------*/ 00029 /*---------------------------------------------------------------------------*\ 00030 * Changes * 00031 * * 00032 * * 00033 * * 00034 * * 00035 * * 00036 * * 00037 \*---------------------------------------------------------------------------*/ 00038 00039 #ifndef _DGRAM_INL_ 00040 #define _DGRAM_INL_ 00041 00042 OSG_BEGIN_NAMESPACE 00043 00044 /*---------------------------------------------------------------------*/ 00045 /* get */ 00046 00047 UInt32 Dgram::getCapacity(void) const 00048 { 00049 return sizeof(_buffer) - sizeof(_buffer._id); 00050 } 00051 00052 UInt16 Dgram::getId(void) const 00053 { 00054 return osgntohs(_buffer._id); 00055 } 00056 00057 UInt32 Dgram::getSize(void) const 00058 { 00059 return _size; 00060 } 00061 00062 UChar8 *Dgram::getData(void) 00063 { 00064 return _buffer._data; 00065 } 00066 00067 const UChar8 *Dgram::getData(void) const 00068 { 00069 return _buffer._data; 00070 } 00071 00072 UChar8 *Dgram::getBuffer(void) 00073 { 00074 return (UChar8 *)&_buffer; 00075 } 00076 00077 UInt32 Dgram::getBufferSize(void) const 00078 { 00079 return _size + sizeof(_buffer._id); 00080 } 00081 00082 UInt32 Dgram::getBufferCapacity(void) const 00083 { 00084 return sizeof(_buffer); 00085 } 00086 00087 bool Dgram::getResponseAck(void) const 00088 { 00089 return _buffer._data[0]; 00090 } 00091 00092 bool Dgram::getEarlySend(void) const 00093 { 00094 return _earlySend; 00095 } 00096 00097 /*---------------------------------------------------------------------*/ 00098 /* set */ 00099 00100 inline void Dgram::setSize(UInt32 size) 00101 { 00102 _size = size; 00103 } 00104 00105 inline void Dgram::setResponseSize(void) 00106 { 00107 _size = sizeof(UChar8); 00108 } 00109 00110 inline void Dgram::setId(UInt16 id) 00111 { 00112 _buffer._id = osghtons(id); 00113 } 00114 00115 inline void Dgram::setBufferSize(UInt32 size) 00116 { 00117 _size = size - sizeof(_buffer._id); 00118 } 00119 00120 inline void Dgram::setResponseAck(bool value) 00121 { 00122 _buffer._data[0] = value; 00123 } 00124 00125 inline void Dgram::setEarlySend(bool value) 00126 { 00127 _earlySend = value; 00128 } 00129 00130 /*---------------------------------------------------------------------*/ 00131 /* compare */ 00132 00135 inline bool Dgram::operator <(const Dgram &other) const 00136 { 00137 return less(this->getId(),other.getId()); 00138 } 00139 00142 inline bool Dgram::less(UInt16 a,UInt16 b) 00143 { 00144 a = a - b; 00145 00146 if(a & 0x8000) 00147 return true; 00148 else 00149 return false; 00150 } 00151 00152 OSG_END_NAMESPACE 00153 00154 #define OSG_DGRAMINLINE_CVSID "@(#)$Id:$" 00155 00156 #endif 00157 00158 00159 00160 00161 00162 00163
1.4.3