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_H_ 00018 #define _PROPHET_BUNDLE_H_ 00019 00020 #include "bundling/Bundle.h" 00021 #include "prophet/Bundle.h" 00022 00023 namespace dtn 00024 { 00025 00030 class ProphetBundle : public prophet::Bundle 00031 { 00032 public: 00036 ProphetBundle(const BundleRef& bundle) 00037 : ref_("ProphetBundle"), str_("") 00038 { 00039 ref_ = bundle.object(); 00040 } 00041 00045 ProphetBundle(const ProphetBundle& other) 00046 : prophet::Bundle(other), ref_(other.ref_) {} 00047 00051 virtual ~ProphetBundle() 00052 { 00053 ref_ = NULL; 00054 } 00055 00059 ProphetBundle& operator= (const ProphetBundle& other) 00060 { 00061 ref_ = other.ref_; 00062 return *this; 00063 } 00064 00068 const BundleRef& ref() const { return ref_; } 00069 00071 virtual const std::string& destination_id() const 00072 { 00073 return (ref_ == NULL) ? str_ : ref()->dest().str(); 00074 } 00075 virtual const std::string& source_id() const 00076 { 00077 return (ref_ == NULL) ? str_ : ref()->source().str(); 00078 } 00079 virtual u_int32_t creation_ts() const 00080 { 00081 return (ref_ == NULL) ? 0 : ref()->creation_ts().seconds_; 00082 } 00083 virtual u_int32_t sequence_num() const 00084 { 00085 return (ref_ == NULL) ? 0 : ref()->creation_ts().seqno_; 00086 } 00087 virtual u_int32_t expiration_ts() const 00088 { 00089 return (ref_ == NULL) ? 0 : ref()->expiration(); 00090 } 00091 virtual u_int size() const 00092 { 00093 return (ref_ == NULL) ? 0 : ref()->payload().length(); 00094 } 00095 virtual u_int num_forward() const 00096 { 00097 return (ref_ == NULL) ? 0 : 00098 ref()->fwdlog()->get_count(ForwardingInfo::TRANSMITTED, 00099 ForwardingInfo::COPY_ACTION); 00100 } 00101 virtual bool custody_requested() const 00102 { 00103 return (ref_ == NULL) ? false : ref()->custody_requested(); 00104 } 00106 00107 protected: 00108 00109 BundleRef ref_; 00110 std::string str_; 00111 00112 }; // class ProphetBundle 00113 00114 }; // namespace dtn 00115 00116 #endif // _PROPHET_BUNDLE_H_