servlib/discovery/DiscoveryTable.h
changeset 0 2b3e5ec03512
equal deleted inserted replaced
-1:000000000000 0:2b3e5ec03512
       
     1 /*
       
     2  *    Copyright 2006 Baylor University
       
     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 _DISCOVERY_TABLE_H_
       
    18 #define _DISCOVERY_TABLE_H_
       
    19 
       
    20 #include <list>
       
    21 #include <oasys/debug/Log.h>
       
    22 #include <oasys/util/StringBuffer.h>
       
    23 #include <oasys/util/Singleton.h>
       
    24 
       
    25 namespace dtn {
       
    26 
       
    27 class Discovery;
       
    28 
       
    29 typedef std::list<Discovery*> DiscoveryList;
       
    30 
       
    31 class DiscoveryTable : public oasys::Singleton<DiscoveryTable,false>,
       
    32                        public oasys::Logger
       
    33 {
       
    34 public:
       
    35     virtual ~DiscoveryTable();
       
    36 
       
    37     static void init()
       
    38     {
       
    39         if (instance_ != NULL)
       
    40         {
       
    41             PANIC("DiscoveryTable already initialized");
       
    42         }
       
    43         instance_ = new DiscoveryTable();
       
    44     }
       
    45 
       
    46     bool add(const std::string& name, const char* addr_family,
       
    47              int argc, const char* argv[], const char** error);
       
    48 
       
    49     bool del(const std::string& name);
       
    50 
       
    51     void dump(oasys::StringBuffer* buf);
       
    52 
       
    53     void shutdown();
       
    54 
       
    55 protected:
       
    56     friend class DiscoveryCommand;
       
    57     friend class oasys::Singleton<DiscoveryTable>;
       
    58 
       
    59     DiscoveryTable();
       
    60 
       
    61     bool find(const std::string& name, DiscoveryList::iterator* iter);
       
    62 
       
    63     DiscoveryList dlist_;
       
    64 }; // class DiscoveryTable
       
    65     
       
    66 }; // namespace dtn
       
    67 
       
    68 #endif // _DISCOVERY_TABLE_H_