Switch to unified view

a b/src/policies/DIF/RMT/PDUForwarding/SimpleTable/SimpleTable.h
1
//
2
// This program is free software: you can redistribute it and/or modify
3
// it under the terms of the GNU Lesser General Public License as published by
4
// the Free Software Foundation, either version 3 of the License, or
5
// (at your option) any later version.
6
// 
7
// This program is distributed in the hope that it will be useful,
8
// but WITHOUT ANY WARRANTY; without even the implied warranty of
9
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
// GNU Lesser General Public License for more details.
11
// 
12
// You should have received a copy of the GNU Lesser General Public License
13
// along with this program.  If not, see http://www.gnu.org/licenses/.
14
// 
15
16
#ifndef SimpleTable_H_
17
#define SimpleTable_H_
18
19
#include <IntPDUForwarding.h>
20
21
#include <map>
22
#include <string>
23
#include <vector>
24
25
namespace SimpleTable {
26
27
using namespace std;
28
29
typedef map<unsigned short, RMTPort*> qos2Port;
30
typedef map<string, qos2Port> FWDTable;
31
32
typedef qos2Port::iterator qos2PortIt;
33
typedef FWDTable::iterator FWDTableIt;
34
35
class SimpleTable: public IntPDUForwarding {
36
37
public:
38
    // Lookup function, return a list of RMTPorts to forward a PDU/Address+qos.
39
    vector<RMTPort * > lookup(const PDU * pdu);
40
    vector<RMTPort * > lookup(const Address &dst, const unsigned short &qos);
41
42
    // Returns a representation of the Forwarding Knowledge
43
    string toString();
44
45
    //Insert/Remove an entry
46
    void insert(const std::string &addr, const unsigned short &qos, RMTPort * port);
47
    void insert(const Address &addr, const unsigned short &qos, RMTPort * port);
48
    void remove(const std::string &addr, const unsigned short &qos);
49
    void remove(const Address &addr, const unsigned short &qos);
50
51
    void finish();
52
53
protected:
54
    FWDTable table;
55
56
    // Called after initialize
57
    void onPolicyInit();
58
};
59
60
}
61
62
#endif /* SimpleTable_H_ */