00001 /* 00002 * Copyright 2005-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 #ifdef HAVE_CONFIG_H 00018 # include <dtn-config.h> 00019 #endif 00020 00021 #include "SchemeTable.h" 00022 #include "DTNScheme.h" 00023 #include "EthernetScheme.h" 00024 #include "SessionScheme.h" 00025 #include "StringScheme.h" 00026 #include "WildcardScheme.h" 00027 #include "TCAScheme.h" 00028 00029 namespace dtn { 00030 00031 template <> 00032 SchemeTable* oasys::Singleton<SchemeTable>::instance_ = 0; 00033 00034 //---------------------------------------------------------------------- 00035 SchemeTable::SchemeTable() 00036 { 00037 table_["dtn"] = DTNScheme::instance(); 00038 table_["str"] = StringScheme::instance(); 00039 table_["*"] = WildcardScheme::instance(); 00040 #ifdef __linux__ 00041 table_["eth"] = EthernetScheme::instance(); 00042 #endif 00043 table_["tca"] = TCAScheme::instance(); 00044 table_["dtn-session"] = SessionScheme::instance(); 00045 } 00046 00047 //---------------------------------------------------------------------- 00048 SchemeTable::~SchemeTable() 00049 { 00050 table_.clear(); 00051 } 00052 00053 //---------------------------------------------------------------------- 00054 void 00055 SchemeTable::register_scheme(const std::string& scheme_str, 00056 Scheme* scheme) 00057 { 00058 table_[scheme_str] = scheme; 00059 } 00060 00061 //---------------------------------------------------------------------- 00062 Scheme* 00063 SchemeTable::lookup(const std::string& scheme_str) 00064 { 00065 SchemeMap::iterator iter = table_.find(scheme_str); 00066 if (iter == table_.end()) { 00067 return NULL; 00068 } 00069 00070 return (*iter).second; 00071 } 00072 00073 }