00001 /* 00002 * Copyright 2005-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 _FORWARDINGLOG_H_ 00018 #define _FORWARDINGLOG_H_ 00019 00020 #include <vector> 00021 00022 #include <oasys/serialize/SerializableVector.h> 00023 #include "ForwardingInfo.h" 00024 00025 namespace oasys { 00026 class SpinLock; 00027 class StringBuffer; 00028 } 00029 00030 namespace dtn { 00031 00032 class Link; 00033 class ForwardingLog; 00034 00051 class ForwardingLog : public oasys::SerializableVector<ForwardingInfo>{ 00052 public: 00053 typedef ForwardingInfo::state_t state_t; 00054 00059 ForwardingLog(oasys::SpinLock* lock); 00060 00064 bool get_latest_entry(Link* link, ForwardingInfo* info) const; 00065 00069 state_t get_latest_entry(Link* link) const; 00070 00077 size_t get_transmission_count(ForwardingInfo::action_t action = 00078 ForwardingInfo::INVALID_ACTION, 00079 bool include_inflight = false) const; 00080 00084 void add_entry(Link* link, 00085 ForwardingInfo::action_t action, 00086 state_t state, 00087 const CustodyTimerSpec& custody_timer); 00088 00095 bool update(Link* link, state_t state); 00096 00100 size_t get_count(state_t state) const; 00101 00105 void dump(oasys::StringBuffer* buf) const; 00106 00110 typedef std::vector<ForwardingInfo> Log; 00111 00112 protected: 00113 Log log_; 00114 oasys::SpinLock* lock_; 00115 }; 00116 00117 } // namespace dtn 00118 00119 00120 #endif /* _FORWARDINGLOG_H_ */