IBR-DTNSuite
0.12
Main Page
Namespaces
Classes
Files
File List
File Members
Block.cpp
Go to the documentation of this file.
1
/*
2
* Block.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/Block.h
"
23
#include "
ibrdtn/data/Bundle.h
"
24
#include <iostream>
25
26
using namespace
std;
27
28
namespace
dtn
29
{
30
namespace
data
31
{
32
Block::Block(
block_t
blocktype)
33
: _blocktype(blocktype)
34
{
35
}
36
37
Block::~Block
()
38
{
39
}
40
41
Block
&
Block::operator=
(
const
Block
&block)
42
{
43
bool
last_block = _procflags.
getBit
(
LAST_BLOCK
);
44
_procflags = block._procflags;
45
_procflags.
setBit
(
LAST_BLOCK
, last_block);
46
47
_eids
= block.
_eids
;
48
return
(*
this
);
49
}
50
51
bool
Block::operator==
(
const
block_t
&
id
)
const
52
{
53
return
(
id
==
_blocktype
);
54
}
55
56
void
Block::addEID
(
const
EID
&eid)
57
{
58
_eids
.push_back(eid);
59
60
// add proc. flag
61
_procflags.
setBit
(
Block::BLOCK_CONTAINS_EIDS
,
true
);
62
}
63
64
void
Block::clearEIDs
()
65
{
66
_eids
.clear();
67
68
// clear proc. flag
69
_procflags.
setBit
(
Block::BLOCK_CONTAINS_EIDS
,
false
);
70
}
71
72
const
Block::eid_list
&
Block::getEIDList
()
const
73
{
74
return
_eids
;
75
}
76
77
void
Block::set
(
ProcFlags
flag,
const
bool
&value)
78
{
79
_procflags.
setBit
(flag, value);
80
}
81
82
bool
Block::get
(
ProcFlags
flag)
const
83
{
84
return
_procflags.
getBit
(flag);
85
}
86
87
const
Bitset<Block::ProcFlags>
&
Block::getProcessingFlags
()
const
88
{
89
return
_procflags;
90
}
91
92
Length
Block::getLength_strict
()
const
93
{
94
return
getLength
();
95
}
96
97
std::ostream&
Block::serialize_strict
(std::ostream &stream,
Length
&length)
const
98
{
99
return
serialize
(stream, length);
100
}
101
}
102
}
ibrdtn
ibrdtn
data
Block.cpp
Generated on Thu Mar 27 2014 09:26:21 for IBR-DTNSuite by
1.8.4