Switch to unified view

a b/src/policies/DIF/Routing/IntRouting.cc
1
#include "IntRouting.h"
2
3
void IntRouting::finish(){
4
5
    cModule* catcher = this->getParentModule();
6
    catcher->unsubscribe(SIG_RIBD_RoutingUpdateReceived, listener);
7
    delete listener;
8
}
9
10
void IntRouting::initialize(){
11
12
    // IPCProcess module.
13
    cModule * ipcModule = getParentModule();
14
15
    myAddress   = Address(
16
        ipcModule->par("ipcAddress").stringValue(),
17
        ipcModule->par("difName").stringValue());
18
19
    check_and_cast<cObject *>
20
            (getModuleByPath("^.resourceAllocator.pduFwdGenerator"));
21
22
    //Set FWDGenerator
23
    fwdg = check_and_cast<IntPDUFG *>
24
        (getModuleByPath("^.resourceAllocator.pduFwdGenerator"));
25
26
    // Display active policy name.
27
    cDisplayString& disp = getDisplayString();
28
    disp.setTagArg("t", 1, "t");
29
    disp.setTagArg("t", 0, getClassName());
30
31
    cModule* catcher = this->getParentModule();
32
33
    // Signal emitters; there will be part of our outputs.
34
    sigRoutingUpdate = registerSignal(SIG_RIBD_RoutingUpdate);
35
36
    // Signal receivers; there will be part of our inputs.
37
    listener = new LisRoutingRecv(this);
38
    catcher->subscribe(SIG_RIBD_RoutingUpdateReceived, listener);
39
40
    onPolicyInit();
41
42
}
43
44
void IntRouting::sendUpdate(IntRoutingUpdate * update) {
45
    update->setSource(myAddress);
46
    emit(sigRoutingUpdate, update);
47
}
48
49
void IntRouting::receiveUpdate(IntRoutingUpdate * update) {
50
    if(processUpdate(update)) {
51
        fwdg->routingUpdated();
52
    }
53
}
54
55
56
LisRoutingRecv::LisRoutingRecv(IntRouting * _module){
57
    module = _module;
58
}
59
60
void LisRoutingRecv::receiveSignal(cComponent *src, simsignal_t id, cObject *obj){
61
    EV << "RoutingUpdate initiated by " << src->getFullPath()
62
       << " and processed by " << module->getFullPath() << endl;
63
64
    IntRoutingUpdate * update = dynamic_cast<IntRoutingUpdate *>(obj);
65
66
    if (update) {
67
        module->receiveUpdate(update);
68
    } else {
69
        EV << "RoutingUpdate received unknown object!" << endl;
70
    }
71
72
    delete update;
73
}