Discovery.h

Go to the documentation of this file.
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_H_
00018 #define _DISCOVERY_H_
00019 
00020 #include <oasys/debug/Log.h>
00021 #include <string>
00022 #include <list>
00023 #include "naming/EndpointID.h"
00024 #include "Announce.h"
00025 
00026 namespace dtn {
00027 
00043 class Discovery : public oasys::Logger {
00044 public:
00045 
00049     const std::string& name() const { return name_; }
00050 
00054     const std::string& af() const { return af_; }
00055 
00059     const std::string& to_addr() const { return to_addr_; }
00060 
00064     const std::string& local_addr() const { return local_; }
00065 
00070     static Discovery* create_discovery(const std::string& name,
00071                                        const std::string& afname,
00072                                        int argc, const char* argv[]);
00076     void dump(oasys::StringBuffer* buf);
00077 
00082     virtual void shutdown() = 0;
00083 
00088     bool announce(const char* name, int argc, const char* argv[]);
00089 
00093     bool remove(const char* name);
00094 
00098     void handle_neighbor_discovered(const std::string& cl_type,
00099                                     const std::string& cl_addr,
00100                                     const EndpointID& remote_eid);
00101 
00102     virtual ~Discovery();
00103 protected:
00104     typedef std::list<Announce*> List;
00105     typedef std::list<Announce*>::iterator iterator;
00106 
00110     Discovery(const std::string& name,
00111               const std::string& af);
00112 
00116     virtual bool configure(int argc, const char* argv[]) = 0;
00117 
00121     virtual void handle_announce() {}
00122 
00126     bool find(const char *name, iterator* iter);
00127 
00128     std::string name_; 
00129     std::string af_; 
00130     std::string to_addr_; 
00131     std::string local_;   
00132     List list_; 
00133 private:
00134     Discovery(const Discovery&)
00135         : oasys::Logger("Discovery","/no/loggy/here")
00136     {}
00137 }; // class Discovery
00138 
00139 }; // namespace dtn
00140 
00141 #endif // _DISCOVERY_H_

Generated on Thu Jun 7 16:56:49 2007 for DTN Reference Implementation by  doxygen 1.5.1