Parent: [6a85b3] (diff)

Download this file

Address.h    151 lines (128 with data), 4.3 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see http://www.gnu.org/licenses/.
//
#ifndef ADDRESS_H_
#define ADDRESS_H_
//Standard libraries
#include <string>
#include <sstream>
//RINASim libraries
#include "APN.h"
#include "DAP.h"
/**
* @brief Address class holds IPC Process identification
*
* Class contains three attributes: IPC address identifier, common DIF name
* and concatenation of previous two that should be used as unique APN.
*
* @authors Vladimir Vesely (ivesely@fit.vutbr.cz)
* @date Last refactorized and documented on 2014-10-29
*/
class Address {
public:
/**
* @brief Constructor of blank Address
*/
Address();
/**
* @brief Address constructor from unique APN
* @param composite Expected is a string with following syntax @<ipcaddress@>_@<difname@>
*/
Address(std::string composite);
/**
* @brief Address constructor from both IPC address and DIF name
* @param ipcaddr IPC Process address unambiguos inside a given DIF
* @param difnam DIF name that this IPC Process is a member
*/
Address(const char* ipcaddr, const char* difnam);
/**
* @brief Destructor assigning default values
*/
virtual ~Address();
/**
* Equal operator overload
* @param other Address for comparison
* @return Returns true if IPC address, DIF name and AP Name
* are equal between this and other Address
*/
bool operator== (const Address& other) const;
/**
* @brief Info text output suitable for << string streams and WATCH
* @return Address string representation
*/
std::string info() const;
/**
* @brief Checks whether a given Address is unspecified which means that it has
* empty attributes
* @return True if it is unspecified, else returns false
*/
bool isUnspecified() const;
/**
* @brief Getter of unique APN which is initialized during object construction
* @return Returns APN in form of @<ipcaddress@>_@<difname@>
*/
const APN& getApname() const;
/**
* @brief Getter of common DIF name
* @return DIF name as string
*/
const DAP& getDifName() const;
/**
* @brief Setter of common DIF name
* @param difName A new DIF name value
*/
void setDifName(const DAP& difName);
/**
* @brief Getter of IPC Process address which should be unambiguous within DIF
* @return IPC Process address
*/
const APN& getIpcAddress() const;
/**
* @brief Setter of IPC Process address which should be unambiguous within DIF
* @param ipcAddress A new IPC Process address value
*/
void setIpcAddress(const APN& ipcAddress);
protected:
/**
* @brief IPC Process address represented by APN
*/
APN ipcAddress;
/**
* @brief Commong DIF name represented by DAP
*/
DAP difName;
/**
* @brief Concatenation of IPC Process address and DIF name represented as APN
*/
APN apname;
};
typedef std::list<Address> Addresses;
typedef Addresses::const_iterator AddrCItem;
typedef Addresses::iterator AddrItem;
//Free function
/**
* @brief << operator overload that calls Address.info() method
* @param os Resulting ostream
* @param addr Address class that is being converted to string
* @return Infotext representing Address
*/
std::ostream& operator<< (std::ostream& os, const Address& addr);
/**
* @brief << operator overload that calls Address.info() method for each and every list member
* @param os Resulting ostream
* @param dims List of Addresses
* @return Infotext representing Address
*/
std::ostream& operator<< (std::ostream& os, const Addresses& dims);
#endif /* ADDRESS_H_ */