Jpp 19.3.0-rc.3
the software that should make you happy
Loading...
Searching...
No Matches
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
17namespace JNET {}
18namespace JPP { using namespace JNET; }
19
20namespace 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 */
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 */
85 void set(const JTag& tag, const long long int length)
86 {
87 setTag (tag);
88 setSize(length);
89 }
90
91 protected:
92 long long int size;
93 };
94}
95
96#endif
Exceptions.
ControlHost tag.
ControlHost prefix.
Definition JPrefix.hh:33
int getSize() const
Get size.
Definition JPrefix.hh:62
void setSize(const long long int length)
Set size.
Definition JPrefix.hh:73
void set(const JTag &tag, const long long int length)
Set prefix.
Definition JPrefix.hh:85
JPrefix()
Default constructor.
Definition JPrefix.hh:38
long long int size
Definition JPrefix.hh:92
JPrefix(const JTag &tag, const long long int length)
Constructor.
Definition JPrefix.hh:50
ControlHost tag.
Definition JTag.hh:38
void setTag(const JTag &tag)
Set tag.
Definition JTag.hh:108
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).