RINASim  October 2016
Documentation of framework for OMNeT++
rModule.h
Go to the documentation of this file.
1 // The MIT License (MIT)
2 //
3 // Copyright (c) 2014-2016 Brno University of Technology, PRISTINE project
4 //
5 // Permission is hereby granted, free of charge, to any person obtaining a copy
6 // of this software and associated documentation files (the "Software"), to deal
7 // in the Software without restriction, including without limitation the rights
8 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 // copies of the Software, and to permit persons to whom the Software is
10 // furnished to do so, subject to the following conditions:
11 //
12 // The above copyright notice and this permission notice shall be included in
13 // all copies or substantial portions of the Software.
14 //
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 // THE SOFTWARE.
22 
23 /*
24  * DomainModule.h
25  *
26  * Created on: Mar 23, 2015
27  * Author: gaixas1
28  */
29 
30 #ifndef DOMAINMODULE_H_
31 #define DOMAINMODULE_H_
32 
33 #include <omnetpp.h>
34 #include <IntRouting.h>
35 
36 #include <string>
37 
38 namespace DMRnms {
39 
40 class Routing;
41 
42 typedef std::map<std::string, std::string> s2s;
43 typedef std::map<std::string, Address> s2A;
44 struct dmNxt {
45  std::string domain;
46  s2A entries;
47  dmNxt(const std::string &_domain)
48  :domain(_domain){}
49  dmNxt(const std::string &_domain, const s2A &_entries)
50  :domain(_domain), entries(_entries){}
51 };
52 typedef std::vector<dmNxt> dmUpdateM;
53 
54 typedef s2A::iterator s2AIt;
55 typedef s2s::iterator s2sIt;
56 typedef dmUpdateM::iterator dmUpdateMIt;
57 
59 public:
60  RoutingUpdate(const Address &_addr, const std::string &_domain);
61  std::string domain;
62 };
63 
64 //Predefining class
65 
66 
67 class rModule {
68 public:
69  rModule(Routing * _parent, const Address &_nAddr, const std::string &_domain, const std::string &_addr);
70  virtual ~rModule(){};
71 
72  virtual bool processUpdate(RoutingUpdate * update) = 0;
73  virtual void addFlow(const Address &_nAddr, const std::string &_addr, const unsigned short &_metric) = 0;
74  virtual void removeFlow(const Address &_nAddr, const std::string &_addr) = 0;
75 
76  virtual void addAddr(const std::string &_addr) = 0;
77  virtual void removeAddr(const std::string &_addr) = 0;
78 
79  virtual void setInfMetric(const unsigned short &inf) = 0;
80 
81  virtual dmNxt getChanges() = 0;
82  virtual dmNxt getAll() = 0;
83 
84  virtual void handleMessage(cMessage *msg) = 0;
85 
86 protected:
89  std::string domain;
90  std::string myAddr;
91 
92  void scheduleAt(const double & time, cMessage *);
93 };
94 
95 } /* namespace DomainRouting */
96 
97 #endif /* DOMAINMODULE_H_ */
virtual void addAddr(const std::string &_addr)=0
dmNxt(const std::string &_domain)
Definition: rModule.h:47
virtual dmNxt getAll()=0
s2A::iterator s2AIt
Definition: rModule.h:54
virtual void handleMessage(cMessage *msg)=0
dmNxt(const std::string &_domain, const s2A &_entries)
Definition: rModule.h:49
virtual void removeFlow(const Address &_nAddr, const std::string &_addr)=0
s2s::iterator s2sIt
Definition: rModule.h:55
s2A entries
Definition: rModule.h:46
Routing * parent
Definition: rModule.h:87
rModule(Routing *_parent, const Address &_nAddr, const std::string &_domain, const std::string &_addr)
Definition: rModule.cc:39
std::string myAddr
Definition: rModule.h:90
std::map< std::string, std::string > s2s
Definition: rModule.h:40
RoutingUpdate(const Address &_addr, const std::string &_domain)
Definition: rModule.cc:35
dmUpdateM::iterator dmUpdateMIt
Definition: rModule.h:56
virtual bool processUpdate(RoutingUpdate *update)=0
virtual void setInfMetric(const unsigned short &inf)=0
virtual ~rModule()
Definition: rModule.h:70
void scheduleAt(const double &time, cMessage *)
Definition: rModule.cc:42
virtual void removeAddr(const std::string &_addr)=0
Address myNAddress
Definition: rModule.h:88
virtual dmNxt getChanges()=0
std::map< std::string, Address > s2A
Definition: rModule.h:43
std::string domain
Definition: rModule.h:45
std::vector< dmNxt > dmUpdateM
Definition: rModule.h:52
std::string domain
Definition: rModule.h:89
Address class holds IPC Process identification.
Definition: Address.h:42
virtual void addFlow(const Address &_nAddr, const std::string &_addr, const unsigned short &_metric)=0
std::string domain
Definition: rModule.h:61