00001 /* 00002 * Copyright 2007 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 _SESSION_TABLE_H_ 00018 #define _SESSION_TABLE_H_ 00019 00020 #include <map> 00021 00022 namespace oasys { 00023 class StringBuffer; 00024 } 00025 00026 namespace dtn { 00027 00028 class EndpointID; 00029 class Session; 00030 00034 class SessionTable { 00035 public: 00036 typedef std::map<EndpointID, Session*> SessionMap; 00037 typedef SessionMap::const_iterator iterator; 00038 00039 public: 00040 SessionTable(); 00041 Session* lookup_session(const EndpointID& eid) const; 00042 void add_session(Session* s); 00043 Session* get_session(const EndpointID& eid); 00044 00045 bool empty() const { return table_.empty(); } 00046 size_t size() const { return table_.size(); } 00047 void dump(oasys::StringBuffer* buf) const; 00048 00049 iterator begin() const { return table_.begin(); } 00050 iterator end() const { return table_.end(); } 00051 00052 protected: 00053 SessionMap table_; 00054 }; 00055 00056 } // namespace dtn 00057 00058 00059 #endif /* _SESSION_TABLE_H_ */