servlib/session/SessionTable.h
changeset 0 2b3e5ec03512
equal deleted inserted replaced
-1:000000000000 0:2b3e5ec03512
       
     1 /*
       
     2  *    Copyright 2007 Intel Corporation
       
     3  * 
       
     4  *    Licensed under the Apache License, Version 2.0 (the "License");
       
     5  *    you may not use this file except in compliance with the License.
       
     6  *    You may obtain a copy of the License at
       
     7  * 
       
     8  *        http://www.apache.org/licenses/LICENSE-2.0
       
     9  * 
       
    10  *    Unless required by applicable law or agreed to in writing, software
       
    11  *    distributed under the License is distributed on an "AS IS" BASIS,
       
    12  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       
    13  *    See the License for the specific language governing permissions and
       
    14  *    limitations under the License.
       
    15  */
       
    16 
       
    17 #ifndef _SESSION_TABLE_H_
       
    18 #define _SESSION_TABLE_H_
       
    19 
       
    20 #include <map>
       
    21 
       
    22 namespace oasys {
       
    23 class StringBuffer;
       
    24 }
       
    25 
       
    26 namespace dtn {
       
    27 
       
    28 class EndpointID;
       
    29 class Session;
       
    30 
       
    31 /**
       
    32  * Table to manage the open sessions.
       
    33  */
       
    34 class SessionTable {
       
    35 public:
       
    36     typedef std::map<EndpointID, Session*> SessionMap;
       
    37     typedef SessionMap::const_iterator iterator;
       
    38     
       
    39 public:
       
    40     SessionTable();
       
    41     Session* lookup_session(const EndpointID& eid) const;
       
    42     void     add_session(Session* s);
       
    43     Session* get_session(const EndpointID& eid);
       
    44 
       
    45     bool     empty() const { return table_.empty(); }
       
    46     size_t   size()  const { return table_.size(); }
       
    47     void     dump(oasys::StringBuffer* buf) const;
       
    48 
       
    49     iterator begin() const { return table_.begin(); }
       
    50     iterator end()   const { return table_.end(); }
       
    51     
       
    52 protected:
       
    53     SessionMap table_;
       
    54 };
       
    55 
       
    56 } // namespace dtn
       
    57 
       
    58 
       
    59 #endif /* _SESSION_TABLE_H_ */