00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
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 #include "contacts/Link.h"
00025
00026 namespace oasys {
00027 class SpinLock;
00028 class StringBuffer;
00029 }
00030
00031 namespace dtn {
00032
00033 class ForwardingLog;
00034 class Registration;
00035
00052 class ForwardingLog : public oasys::SerializableVector<ForwardingInfo> {
00053 public:
00054 typedef ForwardingInfo::state_t state_t;
00055
00060 ForwardingLog(oasys::SpinLock* lock);
00061
00065 bool get_latest_entry(const LinkRef& link, ForwardingInfo* info) const;
00066
00070 state_t get_latest_entry(const LinkRef& link) const;
00071
00075 bool get_latest_entry(const Registration* reg, ForwardingInfo* info) const;
00076
00080 state_t get_latest_entry(const Registration* reg) const;
00081
00085 bool get_latest_entry(state_t state, ForwardingInfo* info) const;
00086
00092 size_t get_count(unsigned int states = ForwardingInfo::ANY_STATE,
00093 unsigned int actions = ForwardingInfo::ANY_ACTION) const;
00094
00101 size_t get_count(const EndpointID& eid,
00102 unsigned int states = ForwardingInfo::ANY_STATE,
00103 unsigned int actions = ForwardingInfo::ANY_ACTION) const;
00104
00108 void add_entry(const LinkRef& link,
00109 ForwardingInfo::action_t action,
00110 state_t state,
00111 const CustodyTimerSpec& custody_timer);
00112
00118 void add_entry(const LinkRef& link,
00119 ForwardingInfo::action_t action,
00120 state_t state);
00121
00125 void add_entry(const Registration* reg,
00126 ForwardingInfo::action_t action,
00127 state_t state);
00128
00137 void add_entry(const EndpointID& eid,
00138 ForwardingInfo::action_t action,
00139 state_t state);
00140
00147 bool update(const LinkRef& link, state_t state);
00148
00152 void update_all(state_t old_state, state_t new_state);
00153
00157 void dump(oasys::StringBuffer* buf) const;
00158
00162 void clear();
00163
00167 typedef std::vector<ForwardingInfo> Log;
00168
00169 protected:
00170 Log log_;
00171 oasys::SpinLock* lock_;
00172 };
00173
00174 }
00175
00176
00177 #endif