IBR-DTNSuite  0.10
LinkManager.h
Go to the documentation of this file.
1 /*
2  * LinkManager.h
3  *
4  * Copyright (C) 2011 IBR, TU Braunschweig
5  *
6  * Written-by: Johannes Morgenroth <morgenroth@ibr.cs.tu-bs.de>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21 
22 #ifndef LINKMANAGER_H_
23 #define LINKMANAGER_H_
24 
27 #include "ibrcommon/net/vaddress.h"
28 #include "ibrcommon/thread/Mutex.h"
29 #include <string>
30 #include <map>
31 #include <set>
32 
33 namespace ibrcommon
34 {
36  {
37  public:
39  {
40  public:
41  virtual ~EventCallback() {};
42  virtual void eventNotify(const LinkEvent&) = 0;
43  };
44 
45  virtual ~LinkManager() {};
46 
47  virtual void up() throw () { };
48  virtual void down() throw () { };
49 
50  virtual const ibrcommon::vinterface getInterface(int index) const = 0;
51  virtual const std::list<vaddress> getAddressList(const vinterface &iface, const std::string &scope = "") = 0;
52 
53  virtual void addEventListener(const vinterface&, LinkManager::EventCallback*) throw ();
54  virtual void removeEventListener(const vinterface&, LinkManager::EventCallback*) throw ();
55  virtual void removeEventListener(LinkManager::EventCallback*) throw ();
56 
57  void raiseEvent(const LinkEvent &lme);
58 
59  static LinkManager& getInstance();
60  static void initialize();
61 
62  protected:
63  ibrcommon::Mutex _listener_mutex;
64  std::map<ibrcommon::vinterface, std::set<LinkManager::EventCallback* > > _listener;
65  };
66 }
67 
68 #endif /* LINKMANAGER_H_ */