IBR-DTNSuite  0.12
MetaBundle.cpp
Go to the documentation of this file.
1 /*
2  * MetaBundle.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 #ifndef METABUNDLE_CPP_
23 #define METABUNDLE_CPP_
24 
25 #include "ibrdtn/data/MetaBundle.h"
26 #include "ibrdtn/utils/Clock.h"
29 
30 namespace dtn
31 {
32  namespace data
33  {
35  {
36  return MetaBundle(id);
37  }
38 
40  {
41  return MetaBundle(bundle);
42  }
43 
45  : BundleID(), lifetime(0), destination(), reportto(),
46  custodian(), appdatalength(0), procflags(0), expiretime(0), hopcount(Number::max()), net_priority(0)
47  {
48  }
49 
51  : BundleID(id), lifetime(0), destination(), reportto(),
52  custodian(), appdatalength(0), procflags(0), expiretime(0), hopcount(Number::max()), net_priority(0)
53  {
54  // apply fragment bit
55  setFragment(id.isFragment());
56  }
57 
59  : BundleID(b), lifetime(b.lifetime), destination(b.destination), reportto(b.reportto),
60  custodian(b.custodian), appdatalength(b.appdatalength), procflags(b.procflags), expiretime(0), hopcount(Number::max()), net_priority(0)
61  {
63 
67  try {
69  hopcount = schl.getHopsToLive();
71 
75  try {
77  net_priority = sblock.getPriority();
79  }
80 
82  {}
83 
84  bool MetaBundle::operator<(const MetaBundle& other) const
85  {
86  return (const BundleID&)*this < (const BundleID&)other;
87  }
88 
89  bool MetaBundle::operator>(const MetaBundle& other) const
90  {
91  return (const BundleID&)*this > (const BundleID&)other;
92  }
93 
94  bool MetaBundle::operator!=(const MetaBundle& other) const
95  {
96  return (const BundleID&)*this != (const BundleID&)other;
97  }
98 
99  bool MetaBundle::operator==(const MetaBundle& other) const
100  {
101  return (const BundleID&)*this == (const BundleID&)other;
102  }
103 
104  bool MetaBundle::operator<(const BundleID& other) const
105  {
106  return (const BundleID&)*this < other;
107  }
108 
109  bool MetaBundle::operator>(const BundleID& other) const
110  {
111  return (const BundleID&)*this > other;
112  }
113 
114  bool MetaBundle::operator!=(const BundleID& other) const
115  {
116  return (const BundleID&)*this != other;
117  }
118 
119  bool MetaBundle::operator==(const BundleID& other) const
120  {
121  return (const BundleID&)*this == other;
122  }
123 
124  bool MetaBundle::operator<(const PrimaryBlock& other) const
125  {
126  return (const BundleID&)*this < other;
127  }
128 
129  bool MetaBundle::operator>(const PrimaryBlock& other) const
130  {
131  return (const BundleID&)*this > other;
132  }
133 
134  bool MetaBundle::operator!=(const PrimaryBlock& other) const
135  {
136  return (const BundleID&)*this != other;
137  }
138 
139  bool MetaBundle::operator==(const PrimaryBlock& other) const
140  {
141  return (const BundleID&)*this == other;
142  }
143 
145  {
146  // read priority
148  {
149  return 0;
150  }
151 
153  {
154  return 1;
155  }
156 
157  return -1;
158  }
159 
161  {
162  return procflags.getBit(flag);
163  }
164 
166  {
168  }
169 
170  void MetaBundle::setFragment(bool val)
171  {
173  }
174  }
175 }
176 
177 #endif /* METABUNDLE_CPP_ */