a/src/Common/Address.cc b/src/Common/Address.cc
...
...
13
// along with this program.  If not, see http://www.gnu.org/licenses/.
13
// along with this program.  If not, see http://www.gnu.org/licenses/.
14
// 
14
// 
15
15
16
#include <Address.h>
16
#include <Address.h>
17
17
18
Address::Address() : ipcAddress(APN()), difName("")
18
Address::Address() : ipcAddress(APN()), difName(""), apname(APN())
19
{
19
{
20
}
21
22
Address::Address(std::string composite)
23
{
24
    std::string delimiter = "_";
25
26
    size_t pos = 0;
27
    std::vector<std::string> tokens;
28
    while ((pos = composite.find(delimiter)) != std::string::npos) {
29
        tokens.push_back(composite.substr(0, pos));
30
        composite.erase(0, pos + delimiter.length());
31
    }
32
    tokens.push_back(composite);
33
34
    if (tokens.size() == 2) {
35
        ipcAddress = APN(tokens.front());
36
        difName = DAP(tokens.back());
37
        std::ostringstream os;
38
        os << ipcAddress << "_" << difName;
39
        apname = APN(os.str().c_str());
40
    }
41
42
20
}
43
}
21
44
22
Address::Address(const char* ipcaddr, const char* difnam) :
45
Address::Address(const char* ipcaddr, const char* difnam) :
23
        ipcAddress(APN(ipcaddr)), difName(DAP(difnam))
46
        ipcAddress(APN(ipcaddr)), difName(DAP(difnam))
24
{
47
{
48
        std::ostringstream os;
49
        os << ipcaddr << "_" << difnam;
50
        apname = APN(os.str().c_str());
25
}
51
}
26
52
27
Address::~Address()
53
Address::~Address()
28
{
54
{
55
    ipcAddress = APN();
56
    difName = DAP();
57
    apname = APN();
29
}
58
}
30
59
31
const DAP& Address::getDifName() const {
60
const DAP& Address::getDifName() const
61
{
32
    return difName;
62
    return difName;
33
}
63
}
34
64
35
void Address::setDifName(const DAP& difName) {
65
void Address::setDifName(const DAP& difName)
66
{
36
    this->difName = difName;
67
    this->difName = difName;
37
}
68
}
38
69
39
const APN& Address::getIpcAddress() const {
70
const APN& Address::getIpcAddress() const
71
{
40
    return ipcAddress;
72
    return ipcAddress;
41
}
73
}
42
74
43
bool Address::operator ==(const Address& other) const {
75
bool Address::operator ==(const Address& other) const
44
    return ipcAddress == other.ipcAddress && difName == other.difName;
76
{
77
    return ipcAddress == other.ipcAddress
78
            && difName == other.difName
79
            && apname == other.apname;
45
}
80
}
46
81
47
std::string Address::info() const {
82
std::string Address::info() const
83
{
48
    std::stringstream os;
84
    std::ostringstream os;
49
    if (!ipcAddress.getName().empty() && !difName.getName().empty())
85
    if (!ipcAddress.getName().empty() && !difName.getName().empty())
50
        os << ipcAddress << "(" << difName << ")";
86
        os << ipcAddress << "(" << difName << ")";
51
    return os.str();
87
    return os.str();
52
}
88
}
53
89
90
bool Address::isUnspecified() const
91
{
92
    return ipcAddress.getName().empty() && difName.getName().empty();
93
}
94
95
const APN& Address::getApname() const
96
{
97
    return apname;
98
}
99
54
void Address::setIpcAddress(const APN& ipcAddress) {
100
void Address::setIpcAddress(const APN& ipcAddress)
101
{
55
    this->ipcAddress = ipcAddress;
102
    this->ipcAddress = ipcAddress;
56
}
103
}
57
104
58
std::ostream& operator <<(std::ostream& os, const Address& addr) {
105
std::ostream& operator <<(std::ostream& os, const Address& addr)
106
{
59
    return os << addr.info();
107
    return os << addr.info();
60
}
108
}
61
109
62
std::ostream& operator <<(std::ostream& os, const Addresses& dims) {
110
std::ostream& operator <<(std::ostream& os, const Addresses& dims)
111
{
63
    for (AddrCItem it = dims.begin(); it != dims.end(); ++it)
112
    for (AddrCItem it = dims.begin(); it != dims.end(); ++it)
64
        os << it->info() << endl;
113
        os << it->info() << endl;
65
    return os;
114
    return os;
66
}
115
}