00001 /* 00002 * Copyright 2006 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 _DISCOVERY_TABLE_H_ 00018 #define _DISCOVERY_TABLE_H_ 00019 00020 #include <list> 00021 #include <oasys/debug/Log.h> 00022 #include <oasys/util/StringBuffer.h> 00023 #include <oasys/util/Singleton.h> 00024 00025 namespace dtn { 00026 00027 class Discovery; 00028 00029 typedef std::list<Discovery*> DiscoveryList; 00030 00031 class DiscoveryTable : public oasys::Singleton<DiscoveryTable,false>, 00032 public oasys::Logger 00033 { 00034 public: 00035 virtual ~DiscoveryTable(); 00036 00037 static void init() 00038 { 00039 if (instance_ != NULL) 00040 { 00041 PANIC("DiscoveryTable already initialized"); 00042 } 00043 instance_ = new DiscoveryTable(); 00044 } 00045 00046 bool add(const std::string& name, const char* addr_family, 00047 int argc, const char* argv[]); 00048 00049 bool del(const std::string& name); 00050 00051 void dump(oasys::StringBuffer* buf); 00052 00053 void shutdown(); 00054 00055 protected: 00056 friend class DiscoveryCommand; 00057 friend class oasys::Singleton<DiscoveryTable>; 00058 00059 DiscoveryTable(); 00060 00061 bool find(const std::string& name, DiscoveryList::iterator* iter); 00062 00063 DiscoveryList dlist_; 00064 }; // class DiscoveryTable 00065 00066 }; // namespace dtn 00067 00068 #endif // _DISCOVERY_TABLE_H_