1 // ANNA - Anna is Not Nothingness Anymore //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo //
5 // See project site at http://redmine.teslayout.com/projects/anna-suite //
6 // See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
9 #include <anna/core/functions.hpp>
11 #include <anna/comm/Device.hpp>
12 #include <anna/comm/functions.hpp>
14 #include <anna/xml/Node.hpp>
15 #include <anna/xml/Attribute.hpp>
20 string comm::Device::asString() const
22 string result("comm::Device { IP: ");
23 result += asString(a_address);
24 return result += anna::functions::asString(" | Status: %s }", (a_status == Status::Up) ? "Up" : "Down");
27 xml::Node* comm::Device::asXML(xml::Node* parent) const
28 throw(RuntimeException) {
29 xml::Node* result = parent->createChild("comm.Device");
30 result->createAttribute("IP", asString(a_address));
31 result->createAttribute("Status", (a_status == Status::Up) ? "Up" : "Down");
35 void comm::Device::asAttribute(xml::Node* node) const
36 throw(RuntimeException) {
37 node->createAttribute("IP", asString(a_address));
38 node->createAttribute("Status", (a_status == Status::Up) ? "Up" : "Down");
41 std::string comm::Device::asString(const in_addr_t& address)
45 return string(inet_ntoa(in));