mySQL 5.0.11 sources for tomato
[tomato.git] / release / src / router / mysql / storage / ndb / src / common / transporter / Packer.hpp
blob119f01ea286a0254d115775e76d9d86141f6f95a
1 /* Copyright (c) 2003, 2005 MySQL AB
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; version 2 of the License.
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 GNU General Public License for more details.
12 You should have received a copy of the GNU General Public License
13 along with this program; if not, write to the Free Software
14 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
16 #ifndef PACKER_HPP
17 #define PACKER_HPP
19 #include <TransporterDefinitions.hpp>
20 #include "TransporterInternalDefinitions.hpp"
22 class Packer {
23 Uint32 preComputedWord1;
24 Uint32 checksumUsed; // Checksum shall be included in the message
25 Uint32 signalIdUsed; // Senders signal id shall be included in the message
26 public:
27 Packer(bool signalId, bool checksum);
29 Uint32 getMessageLength(const SignalHeader* header,
30 const LinearSectionPtr ptr[3]) const ;
33 Uint32 getMessageLength(const SignalHeader* header,
34 const SegmentedSectionPtr ptr[3]) const ;
36 void pack(Uint32 * insertPtr,
37 Uint32 prio,
38 const SignalHeader* header,
39 const Uint32* data,
40 const LinearSectionPtr ptr[3]) const ;
42 void pack(Uint32 * insertPtr,
43 Uint32 prio,
44 const SignalHeader* header,
45 const Uint32* data,
46 class SectionSegmentPool & thePool,
47 const SegmentedSectionPtr ptr[3]) const ;
50 inline
51 Uint32
52 Packer::getMessageLength(const SignalHeader* header,
53 const LinearSectionPtr ptr[3]) const {
54 Uint32 tLen32 = header->theLength;
55 Uint32 no_seg = header->m_noOfSections;
56 tLen32 += checksumUsed;
57 tLen32 += signalIdUsed;
58 tLen32 += no_seg;
60 for(Uint32 i = 0; i<no_seg; i++){
61 tLen32 += ptr[i].sz;
64 return (tLen32 * 4) + sizeof(Protocol6);
67 inline
68 Uint32
69 Packer::getMessageLength(const SignalHeader* header,
70 const SegmentedSectionPtr ptr[3]) const {
71 Uint32 tLen32 = header->theLength;
72 Uint32 no_seg = header->m_noOfSections;
73 tLen32 += checksumUsed;
74 tLen32 += signalIdUsed;
75 tLen32 += no_seg;
77 for(Uint32 i = 0; i<no_seg; i++){
78 tLen32 += ptr[i].sz;
81 return (tLen32 * 4) + sizeof(Protocol6);
84 #endif