Fix bug in json to xml convert library
[anna.git] / source / diameter.comm / OriginHostManager.cpp
1 // ANNA - Anna is Not Nothingness Anymore                                                         //
2 //                                                                                                //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo                         //
4 //                                                                                                //
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 //
7
8
9 // Project
10 #include <anna/diameter.comm/OriginHostManager.hpp>
11 #include <anna/diameter.comm/OriginHost.hpp>
12 #include <anna/core/tracing/Logger.hpp>
13 #include <anna/xml/Node.hpp>
14
15
16 using namespace anna::diameter::comm;
17
18 OriginHost *OriginHostManager::getOriginHost(const std::string &name) const throw() {
19   origin_hosts_it it = a_origin_hosts.find(name);
20   if (it != a_origin_hosts.end())
21     return it->second;
22
23   return NULL;
24 }
25
26 void OriginHostManager::registerOriginHost(const std::string &name, OriginHost* originHost) throw() {
27   if (!originHost) return; // nothing done
28   a_origin_hosts[name] = originHost;
29 }
30
31 anna::xml::Node* OriginHostManager::asXML(anna::xml::Node* parent) const
32 throw() {
33   anna::xml::Node* result = parent->createChild("OriginHostManager");
34   origin_hosts_it it_min(a_origin_hosts.begin());
35   origin_hosts_it it_max(a_origin_hosts.end());
36   for (origin_hosts_it it = it_min; it != it_max; it++)
37     it->second->asXML(result);
38
39   return result;
40 }
41