Jpp
software
JNet
JPrefix.hh
Go to the documentation of this file.
1
#ifndef __JNET__JCONTROLHOSTPREFIX__
2
#define __JNET__JCONTROLHOSTPREFIX__
3
4
#include <istream>
5
#include <ostream>
6
#include <string>
7
#include <arpa/inet.h>
8
9
#include "
JLang/JException.hh
"
10
#include "
JNet/JTag.hh
"
11
12
13
/**
14
* \author mdejong
15
*/
16
17
namespace
JNET
{}
18
namespace
JPP
{
using namespace
JNET
; }
19
20
namespace
JNET
{
21
22
23
/**
24
* ControlHost prefix.
25
*
26
* The ControlHost prefix is a light-weight data structure which
27
* consists of a tag and a length.
28
* The length is converted to network byte order and vice versa,
29
* using methods setSize() and getSize(), respectively.
30
*/
31
class
JPrefix
:
32
public
JTag
33
{
34
public
:
35
/**
36
* Default constructor.
37
*/
38
JPrefix
() :
39
JTag
(),
40
size
(0)
41
{}
42
43
44
/**
45
* Constructor.
46
*
47
* \param tag tag
48
* \param length number of bytes
49
*/
50
JPrefix
(
const
JTag
&
tag
,
const
long
long
int
length)
51
{
52
setTag
(
tag
);
53
setSize
(length);
54
}
55
56
57
/**
58
* Get size.
59
*
60
* \return number of bytes
61
*/
62
int
getSize
()
const
63
{
64
return
ntohl(
size
);
65
}
66
67
68
/**
69
* Set size.
70
*
71
* \param length number of bytes
72
*/
73
void
setSize
(
const
long
long
int
length)
74
{
75
size
= htonl(length);
76
}
77
78
79
/**
80
* Set prefix.
81
*
82
* \param tag tag
83
* \param length number of bytes
84
* \return true if OK; else false
85
*/
86
void
set
(
const
JTag
&
tag
,
const
long
long
int
length)
87
{
88
setTag
(
tag
);
89
setSize
(length);
90
}
91
92
protected
:
93
long
long
int
size
;
94
};
95
}
96
97
#endif
JException.hh
JNET::JPrefix::JPrefix
JPrefix(const JTag &tag, const long long int length)
Constructor.
Definition:
JPrefix.hh:50
JTag.hh
JNET::JPrefix
ControlHost prefix.
Definition:
JPrefix.hh:31
JNET::JTag::tag
char tag[TAGSIZE]
Definition:
JTag.hh:247
JNET::JPrefix::size
long long int size
Definition:
JPrefix.hh:93
JNET::JPrefix::set
void set(const JTag &tag, const long long int length)
Set prefix.
Definition:
JPrefix.hh:86
JNET
Interprocess communication.
Definition:
JDataFilter.cc:67
JNET::JTag::setTag
void setTag(const JTag &tag)
Set tag.
Definition:
JTag.hh:105
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition:
JAAnetToolkit.hh:37
JNET::JTag
ControlHost tag.
Definition:
JTag.hh:35
JNET::JPrefix::JPrefix
JPrefix()
Default constructor.
Definition:
JPrefix.hh:38
JNET::JPrefix::setSize
void setSize(const long long int length)
Set size.
Definition:
JPrefix.hh:73
JNET::JPrefix::getSize
int getSize() const
Get size.
Definition:
JPrefix.hh:62
Generated by
1.8.16