|
1 /* Copyright 2004-2006 BBN Technologies Corporation |
|
2 * |
|
3 * Licensed under the Apache License, Version 2.0 (the "License"); you may not |
|
4 * use this file except in compliance with the License. You may obtain a copy |
|
5 * of the License at http://www.apache.org/licenses/LICENSE-2.0 |
|
6 * |
|
7 * Unless required by applicable law or agreed to in writing, software |
|
8 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
|
9 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
10 * |
|
11 * See the License for the specific language governing permissions and |
|
12 * limitations under the License. |
|
13 * |
|
14 * |
|
15 * $Id$ |
|
16 */ |
|
17 |
|
18 #ifndef _GBOFID_H_ |
|
19 #define _GBOFID_H_ |
|
20 |
|
21 #include <oasys/debug/InlineFormatter.h> |
|
22 |
|
23 #include "naming/EndpointID.h" |
|
24 #include "bundling/BundleTimestamp.h" |
|
25 |
|
26 namespace dtn { |
|
27 |
|
28 /** |
|
29 * Class definition for a GBOF ID (Global Bundle Or Fragment ID) |
|
30 */ |
|
31 class GbofId |
|
32 { |
|
33 public: |
|
34 GbofId(); |
|
35 GbofId(EndpointID source, |
|
36 BundleTimestamp creation_ts, |
|
37 bool is_fragment, |
|
38 u_int32_t frag_length, |
|
39 u_int32_t frag_offset); |
|
40 ~GbofId(); |
|
41 |
|
42 /** |
|
43 * Compares if GBOF IDs are the same. |
|
44 */ |
|
45 bool equals(const GbofId& id) const; |
|
46 |
|
47 /** |
|
48 * Compares if fields match those of this GBOF ID |
|
49 */ |
|
50 bool equals(EndpointID, |
|
51 BundleTimestamp, |
|
52 bool, |
|
53 u_int32_t, |
|
54 u_int32_t) const; |
|
55 |
|
56 /** |
|
57 * Equality operator. |
|
58 */ |
|
59 bool operator==(const GbofId& id) const { |
|
60 return equals(id); |
|
61 } |
|
62 |
|
63 /** |
|
64 * Comparison operator. |
|
65 */ |
|
66 bool operator<(const GbofId& other) const; |
|
67 |
|
68 /** |
|
69 * Returns a string version of the gbof |
|
70 */ |
|
71 std::string str() const; |
|
72 |
|
73 EndpointID source_; ///< Source eid |
|
74 BundleTimestamp creation_ts_; ///< Creation timestamp |
|
75 bool is_fragment_; ///< Fragmentary Bundle |
|
76 u_int32_t frag_length_; ///< Length of original bundle |
|
77 u_int32_t frag_offset_; ///< Offset of fragment in original bundle |
|
78 |
|
79 friend class oasys::InlineFormatter<GbofId>; |
|
80 }; |
|
81 |
|
82 } // namespace dtn |
|
83 |
|
84 #endif /* _GBOFID_H_ */ |