RINASim  October 2016
Documentation of framework for OMNeT++
DirectoryEntry.cc
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 #include <DirectoryEntry.h>
24 
25 /*
26 DirectoryEntry::DirectoryEntry() :
27  ipcPath(""), FlowAlloc(NULL)
28 {
29 
30 }
31 
32 DirectoryEntry::DirectoryEntry(APNamingInfo napni, Address naddr, std::string path,
33  FABase* fa) :
34  apni(napni),
35  addr(naddr),
36  ipcPath(path), FlowAlloc(fa)
37 {
38 }
39 */
41  Apn(napn)
42 {
43 }
44 
46  SupportedDifs.clear();
47 }
48 
49 std::ostream& operator <<(std::ostream& os, const DirectoryEntry& dte) {
50  return os << dte.info();
51 }
52 
53 std::string DirectoryEntry::info() const {
54  std::ostringstream os;
55  os << "APN: " << Apn << " is available via: ";
56  for (AddrCItem it = SupportedDifs.begin(); it != SupportedDifs.end(); ++it)
57  os << "\n DIF: " << it->getDifName() << ", IPCaddress: " << it->getIpcAddress();
58  return os.str();
59 }
60 
61 const APN& DirectoryEntry::getApn() const {
62  return Apn;
63 }
64 
65 void DirectoryEntry::setApn(const APN& apn) {
66  Apn = apn;
67 }
68 
70  return SupportedDifs;
71 }
72 
73 void DirectoryEntry::setSupportedDifs(const Addresses& supportedDifs) {
74  SupportedDifs = supportedDifs;
75 }
76 
77 
78 
79 bool DirectoryEntry::hasDif(const Address& member) {
80  for (AddrCItem it = SupportedDifs.begin(); it != SupportedDifs.end(); ++it) {
81  if (*it == member)
82  return true;
83  }
84  return false;
85 }
86 
87 void DirectoryEntry::addDif(const Address& member) {
88  SupportedDifs.push_back(member);
89 }
90 
91 bool DirectoryEntry::operator ==(const DirectoryEntry& other) const {
92  return Apn == other.Apn && SupportedDifs == other.SupportedDifs;
93 }
94 /*
95 const APNamingInfo& DirectoryEntry::getApni() const {
96  return apni;
97 }
98 
99 void DirectoryEntry::setApni(const APNamingInfo& apni) {
100  this->apni = apni;
101 }
102 
103 FABase* DirectoryEntry::getFlowAlloc() const {
104  return FlowAlloc;
105 }
106 
107 void DirectoryEntry::setFlowAlloc(FABase* flowAlloc) {
108  FlowAlloc = flowAlloc;
109 }
110 
111 const std::string& DirectoryEntry::getIpcPath() const {
112  return ipcPath;
113 }
114 
115 void DirectoryEntry::setIpcPath(const std::string& ipcPath) {
116  this->ipcPath = ipcPath;
117 }
118 */
119 /*
120 const Address& DirectoryEntry::getAddr() const {
121  return addr;
122 }
123 
124 void DirectoryEntry::setAddr(const Address& addr) {
125  this->addr = addr;
126 }
127 
128 cModule* DirectoryEntry::getIpc() {
129  return getFlowAlloc() ? getFlowAlloc()->getModuleByPath("^.^") : NULL;
130 }
131 */
std::string info() const
std::list< Address > Addresses
Definition: Address.h:146
APN Apn
Application Process Name class.
Definition: APN.h:36
void addDif(const Address &member)
virtual ~DirectoryEntry()
Addresses::const_iterator AddrCItem
Definition: Address.h:147
Addresses SupportedDifs
DirectoryEntry(const APN &napn)
void setApn(const APN &apn)
bool hasDif(const Address &member)
std::ostream & operator<<(std::ostream &os, const DirectoryEntry &dte)
const APN & getApn() const
bool operator==(const DirectoryEntry &other) const
void setSupportedDifs(const Addresses &supportedDifs)
const Addresses & getSupportedDifs() const
Address class holds IPC Process identification.
Definition: Address.h:42