CustodyTimer.h

Go to the documentation of this file.
00001 /*
00002  *    Copyright 2006 Intel Corporation
00003  * 
00004  *    Licensed under the Apache License, Version 2.0 (the "License");
00005  *    you may not use this file except in compliance with the License.
00006  *    You may obtain a copy of the License at
00007  * 
00008  *        http://www.apache.org/licenses/LICENSE-2.0
00009  * 
00010  *    Unless required by applicable law or agreed to in writing, software
00011  *    distributed under the License is distributed on an "AS IS" BASIS,
00012  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  *    See the License for the specific language governing permissions and
00014  *    limitations under the License.
00015  */
00016 
00017 #ifndef _CUSTODYTIMER_H_
00018 #define _CUSTODYTIMER_H_
00019 
00020 #include <oasys/thread/Timer.h>
00021 #include "bundling/BundleRef.h"
00022 
00023 namespace dtn {
00024 
00025 class Bundle;
00026 class Link;
00027 
00045 class CustodyTimerSpec {
00046 public:
00050     static CustodyTimerSpec defaults_;
00051     
00055     CustodyTimerSpec(u_int32_t min,
00056                      u_int32_t lifetime_pct,
00057                      u_int32_t max)
00058         : min_(min), lifetime_pct_(lifetime_pct), max_(max) {}
00059 
00063     CustodyTimerSpec()
00064         : min_(defaults_.min_),
00065           lifetime_pct_(defaults_.lifetime_pct_),
00066           max_(defaults_.max_) {}
00067 
00071     u_int32_t calculate_timeout(const Bundle* bundle) const;
00072 
00080     int parse_options(int argc, const char* argv[],
00081                       const char** invalidp = NULL);
00082 
00083     u_int32_t min_;             
00084     u_int32_t lifetime_pct_;    
00085     u_int32_t max_;             
00086 };
00087 
00101 class CustodyTimer : public oasys::Timer, public oasys::Logger {
00102 public:
00104     CustodyTimer(const struct timeval& xmit_time,
00105                  const CustodyTimerSpec& spec,
00106                  Bundle* bundle, Link* link);
00107 
00109     void timeout(const struct timeval& now);
00110 
00112     BundleRef bundle_;
00113 
00115     Link* link_;
00116 };
00117 
00121 class CustodyTimerVec : public std::vector<CustodyTimer*> {};
00122 
00123 } // namespace dtn
00124 
00125 #endif /* _CUSTODYTIMER_H_ */

Generated on Sat Sep 8 08:36:16 2007 for DTN Reference Implementation by  doxygen 1.5.3