-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProphetBundle.h
116 lines (102 loc) · 2.81 KB
/
ProphetBundle.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*
* Copyright 2007 Baylor University
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _PROPHET_BUNDLE_H_
#define _PROPHET_BUNDLE_H_
#include "bundling/Bundle.h"
#include "prophet/Bundle.h"
namespace dtn
{
/**
* Unification class that ties together Prophet's metadata view with
* DTN's complete Bundle object.
*/
class ProphetBundle : public prophet::Bundle
{
public:
/**
* Constructor
*/
ProphetBundle(const BundleRef& bundle)
: ref_("ProphetBundle"), str_("")
{
ref_ = bundle.object();
}
/**
* Constructor
*/
ProphetBundle(const ProphetBundle& other)
: prophet::Bundle(other), ref_(other.ref_) {}
/**
* Destructor
*/
virtual ~ProphetBundle()
{
ref_ = NULL;
}
/**
* Assignment operator
*/
ProphetBundle& operator= (const ProphetBundle& other)
{
ref_ = other.ref_;
return *this;
}
/**
* Return const ref to BundleRef member
*/
const BundleRef& ref() const { return ref_; }
///@{ Virtual from prophet::Bundle
virtual const std::string& destination_id() const
{
return (ref_ == NULL) ? str_ : ref()->dest().str();
}
virtual const std::string& source_id() const
{
return (ref_ == NULL) ? str_ : ref()->source().str();
}
virtual u_int32_t creation_ts() const
{
return (ref_ == NULL) ? 0 : ref()->creation_ts().seconds_;
}
virtual u_int32_t sequence_num() const
{
return (ref_ == NULL) ? 0 : ref()->creation_ts().seqno_;
}
virtual u_int32_t expiration_ts() const
{
return (ref_ == NULL) ? 0 : ref()->expiration();
}
virtual u_int size() const
{
return (ref_ == NULL) ? 0 : ref()->payload().length();
}
virtual u_int num_forward() const
{
return (ref_ == NULL) ? 0 :
ref()->fwdlog()->get_count(ForwardingInfo::TRANSMITTED,
ForwardingInfo::COPY_ACTION);
}
virtual bool custody_requested() const
{
return (ref_ == NULL) ? false : ref()->custody_requested();
}
///@}
protected:
BundleRef ref_; ///< DTN bundle object
std::string str_; ///< return value for NULL condition
}; // class ProphetBundle
}; // namespace dtn
#endif // _PROPHET_BUNDLE_H_