CPN
Computational Process Networks
Main Page
Namespaces
Classes
Files
File List
File Members
lib
PacketEncoder.cc
Go to the documentation of this file.
1
//=============================================================================
2
// Computational Process Networks class library
3
// Copyright (C) 1997-2006 Gregory E. Allen and The University of Texas
4
//
5
// This library is free software; you can redistribute it and/or modify it
6
// under the terms of the GNU Library General Public License as published
7
// by the Free Software Foundation; either version 2 of the License, or
8
// (at your option) any later version.
9
//
10
// This library is distributed in the hope that it will be useful,
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
// Library General Public License for more details.
14
//
15
// The GNU Public License is available in the file LICENSE, or you
16
// can write to the Free Software Foundation, Inc., 59 Temple Place -
17
// Suite 330, Boston, MA 02111-1307, USA, or you can find it on the
18
// World Wide Web at http://www.fsf.org.
19
//=============================================================================
23
#include "common_priv.h"
24
#include "
PacketEncoder.h
"
25
26
namespace
CPN {
27
28
PacketEncoder::PacketEncoder
() {}
29
30
PacketEncoder::~PacketEncoder
() {}
31
32
void
PacketEncoder::SendPacket
(
const
Packet
&packet) {
33
iovec iov;
34
iov.iov_base =
const_cast<
PacketHeader
*
>
(&packet.
header
);
35
iov.iov_len =
sizeof
(packet.
header
);
36
WriteBytes
(&iov, 1);
37
}
38
39
void
PacketEncoder::SendPacket
(
const
Packet
&packet,
void
*data) {
40
ASSERT
(data);
41
iovec iov[2];
42
iov[0].iov_base =
const_cast<
PacketHeader
*
>
(&packet.
header
);
43
iov[0].iov_len =
sizeof
(packet.
header
);
44
iov[1].iov_base = data;
45
iov[1].iov_len = packet.
DataLength
();
46
WriteBytes
(&iov[0], 2);
47
}
48
49
}
50
CPN::Packet::header
PacketHeader header
Definition:
PacketHeader.h:148
CPN::PacketEncoder::~PacketEncoder
virtual ~PacketEncoder()
Definition:
PacketEncoder.cc:30
CPN::PacketEncoder::SendPacket
void SendPacket(const Packet &packet)
Definition:
PacketEncoder.cc:32
CPN::PacketEncoder::WriteBytes
virtual void WriteBytes(const iovec *iov, unsigned iovcnt)=0
CPN::Packet::DataLength
uint32_t DataLength() const
Definition:
PacketHeader.h:124
CPN::PacketHeader
Definition:
PacketHeader.h:69
CPN::Packet
Definition:
PacketHeader.h:112
PacketEncoder.h
CPN::PacketEncoder::PacketEncoder
PacketEncoder()
Definition:
PacketEncoder.cc:28
ASSERT
#define ASSERT(exp,...)
Definition:
ThrowingAssert.h:62
Generated by
1.8.5