IBR-DTNSuite
0.12
Main Page
Namespaces
Classes
Files
File List
File Members
SchedulingBlock.cpp
Go to the documentation of this file.
1
/*
2
* SchedulingBlock.cpp
3
*
4
* Copyright (C) 2011 IBR, TU Braunschweig
5
*
6
* Written-by: Johannes Morgenroth <morgenroth@ibr.cs.tu-bs.de>
7
*
8
* Licensed under the Apache License, Version 2.0 (the "License");
9
* you may not use this file except in compliance with the License.
10
* You may obtain a copy of the License at
11
*
12
* http://www.apache.org/licenses/LICENSE-2.0
13
*
14
* Unless required by applicable law or agreed to in writing, software
15
* distributed under the License is distributed on an "AS IS" BASIS,
16
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
* See the License for the specific language governing permissions and
18
* limitations under the License.
19
*
20
*/
21
22
#include "
ibrdtn/data/SchedulingBlock.h
"
23
24
namespace
dtn
25
{
26
namespace
data
27
{
28
const
dtn::data::block_t
SchedulingBlock::BLOCK_TYPE
= 198;
29
30
dtn::data::Block
*
SchedulingBlock::Factory::create
()
31
{
32
return
new
SchedulingBlock
();
33
}
34
35
SchedulingBlock::SchedulingBlock
()
36
: dtn::data::
Block
(
SchedulingBlock
::
BLOCK_TYPE
), _priority(0)
37
{
38
// set the replicate in every fragment bit
39
set
(
REPLICATE_IN_EVERY_FRAGMENT
,
true
);
40
}
41
42
SchedulingBlock::~SchedulingBlock
()
43
{
44
}
45
46
void
SchedulingBlock::setPriority
(
Integer
p)
47
{
48
_flags.
setBit
(HAS_PRIORITY,
true
);
49
_priority = p;
50
}
51
52
Integer
SchedulingBlock::getPriority
()
const
53
{
54
return
_priority;
55
}
56
57
Length
SchedulingBlock::getLength
()
const
58
{
59
Length
len = _flags.
getLength
();
60
61
if
(_flags.
getBit
(HAS_PRIORITY)) _priority.
getLength
();
62
63
return
len;
64
}
65
66
std::ostream&
SchedulingBlock::serialize
(std::ostream &stream,
Length
&length)
const
67
{
68
stream << _flags;
69
70
if
(_flags.getBit(HAS_PRIORITY)) {
71
stream << _priority;
72
}
73
74
length +=
getLength
();
75
return
stream;
76
}
77
78
std::istream&
SchedulingBlock::deserialize
(std::istream &stream,
const
Length
&)
79
{
80
stream >> _flags;
81
82
if
(_flags.getBit(HAS_PRIORITY)) {
83
stream >> _priority;
84
}
85
86
return
stream;
87
}
88
}
/* namespace data */
89
}
/* namespace dtn */
ibrdtn
ibrdtn
data
SchedulingBlock.cpp
Generated on Thu Mar 27 2014 09:26:21 for IBR-DTNSuite by
1.8.4