00001 /* 00002 * Copyright 2007 Baylor University 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 _PROPHET_BUNDLE_LIST_H_ 00018 #define _PROPHET_BUNDLE_LIST_H_ 00019 00020 #include "prophet/BundleList.h" 00021 #include "prophet/Repository.h" 00022 #include "prophet/BundleCore.h" 00023 #include "ProphetBundle.h" 00024 00025 namespace dtn 00026 { 00027 00032 class ProphetBundleList 00033 { 00034 public: 00038 ProphetBundleList(prophet::Repository::BundleCoreRep* core); 00039 00043 ~ProphetBundleList(); 00044 00048 void add(const BundleRef& b); 00049 void add(const prophet::Bundle* b); 00050 00054 void del(const BundleRef& b); 00055 void del(const prophet::Bundle* b); 00056 00060 const prophet::Bundle* find(const std::string& dst, 00061 u_int creation_ts, 00062 u_int seqno) const; 00063 00064 const prophet::Bundle* find(const Bundle* b) const 00065 { 00066 return find(b->dest().str(), 00067 b->creation_ts().seconds_, 00068 b->creation_ts().seqno_); 00069 } 00070 00074 const BundleRef& find_ref(const prophet::Bundle* b) const; 00075 00079 const prophet::BundleList& get_bundles() const 00080 { 00081 return list_.get_bundles(); 00082 } 00083 00087 prophet::Repository* bundles() { return &list_; } 00088 00092 void clear(); 00093 00095 bool empty() const { return list_.empty(); } 00096 size_t size() const { return list_.size(); } 00098 00099 protected: 00100 typedef prophet::BundleList::const_iterator const_iterator; 00104 bool find(const std::string& dst, u_int creation_ts, 00105 u_int seqno, const_iterator& i) const; 00106 00107 prophet::Repository list_; 00108 static BundleRef NULL_BUNDLE; 00109 00110 }; // class ProphetBundleList 00111 00112 }; // namespace dtn 00113 00114 #endif // _PROPHET_BUNDLE_LIST_H_