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 _REGISTRATION_TABLE_H_ 00018 #define _REGISTRATION_TABLE_H_ 00019 00020 #include <string> 00021 #include <oasys/debug/DebugUtils.h> 00022 #include <oasys/util/StringBuffer.h> 00023 00024 #include "Registration.h" 00025 00026 namespace dtn { 00027 00032 class RegistrationTable : public oasys::Logger { 00033 public: 00037 RegistrationTable(); 00038 00042 virtual ~RegistrationTable(); 00043 00053 bool add(Registration* reg, bool add_to_store = true); 00054 00058 Registration* get(u_int32_t regid) const; 00059 00064 Registration* get(const EndpointIDPattern& eid) const; 00065 00070 bool del(u_int32_t regid); 00071 00076 bool update(Registration* reg); 00077 00084 int get_matching(const EndpointID& eid, RegistrationList* reg_list) const; 00085 00091 int delete_expired(const time_t now); 00092 00096 void dump(oasys::StringBuffer* buf) const; 00097 00102 const RegistrationList *reg_list() const; 00103 00107 oasys::Lock* lock() const { return &lock_; } 00108 00109 protected: 00113 bool find(u_int32_t regid, RegistrationList::iterator* iter); 00114 00120 RegistrationList reglist_; 00121 00125 mutable oasys::SpinLock lock_; 00126 }; 00127 00128 } // namespace dtn 00129 00130 #endif /* _REGISTRATION_TABLE_H_ */