00001 /* 00002 * Copyright 2004-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 _CONTACT_H_ 00018 #define _CONTACT_H_ 00019 00020 #include <oasys/debug/DebugUtils.h> 00021 #include <oasys/debug/Formatter.h> 00022 #include <oasys/serialize/Serialize.h> 00023 #include <oasys/util/Ref.h> 00024 #include <oasys/util/RefCountedObject.h> 00025 #include <oasys/util/Time.h> 00026 00027 namespace dtn { 00028 00029 class Bundle; 00030 class ConvergenceLayer; 00031 class CLInfo; 00032 class Link; 00033 00034 // re-defined from Link.h 00035 typedef oasys::Ref<Link> LinkRef; 00036 00052 class Contact : public oasys::RefCountedObject, 00053 public oasys::Logger, 00054 public oasys::SerializableObject 00055 { 00056 public: 00060 Contact(const LinkRef& link); 00061 00062 private: 00067 virtual ~Contact(); 00068 friend class oasys::RefCountedObject; 00069 00070 public: 00074 void set_cl_info(CLInfo* cl_info) 00075 { 00076 ASSERT((cl_info_ == NULL && cl_info != NULL) || 00077 (cl_info_ != NULL && cl_info == NULL)); 00078 00079 cl_info_ = cl_info; 00080 } 00081 00085 CLInfo* cl_info() { return cl_info_; } 00086 00090 const LinkRef& link() { return link_; } 00091 00095 int format(char* buf, size_t sz) const; 00096 00100 virtual void serialize( oasys::SerializeAction *a ); 00101 00102 00104 const oasys::Time& start_time() const { return start_time_; } 00105 u_int32_t duration() const { return duration_; } 00106 u_int32_t bps() const { return bps_; } 00107 u_int32_t latency() const { return latency_; } 00108 00109 void set_start_time(const oasys::Time& t) { start_time_ = t; } 00110 void set_duration(u_int32_t duration) { duration_ = duration; } 00111 void set_bps(u_int32_t bps) { bps_ = bps; } 00112 void set_latency(u_int32_t latency) { latency_ = latency; } 00114 00115 protected: 00117 oasys::Time start_time_; 00118 00120 u_int32_t duration_; 00121 00123 u_int32_t bps_; 00124 00126 u_int32_t latency_; 00127 00128 LinkRef link_ ; 00129 00130 CLInfo* cl_info_; 00131 }; 00132 00136 typedef oasys::Ref<Contact> ContactRef; 00137 00138 } // namespace dtn 00139 00140 #endif /* _CONTACT_H_ */