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 //
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>
16 using namespace anna::diameter::comm;
18 OriginHost *OriginHostManager::getOriginHost(const std::string &name) const {
19 origin_hosts_it it = a_origin_hosts.find(name);
20 if (it != a_origin_hosts.end())
26 void OriginHostManager::registerOriginHost(const std::string &name, OriginHost* originHost) {
27 if (!originHost) return; // nothing done
28 a_origin_hosts[name] = originHost;
31 void OriginHostManager::registerRemoteOriginHost(const std::string &remoteName, const std::string &ownName) {
32 a_remote_to_own_origin_hosts[remoteName] = ownName;
35 anna::xml::Node* OriginHostManager::asXML(anna::xml::Node* parent) const
37 anna::xml::Node* result = parent->createChild("OriginHostManager");
38 origin_hosts_it it_min(a_origin_hosts.begin());
39 origin_hosts_it it_max(a_origin_hosts.end());
40 for (origin_hosts_it it = it_min; it != it_max; it++)
41 it->second->asXML(result);
47 OriginHost *OriginHostManager::getOriginHost(const anna::U32 &applicationId) const {
51 for (auto it: a_origin_hosts) {
53 if (result->getApplicationId() == applicationId) return result;
59 OriginHost *OriginHostManager::getOriginHostForRemoteOriginHost(const std::string &name) const {
60 auto it = a_remote_to_own_origin_hosts.find(name);
62 if (it != a_remote_to_own_origin_hosts.end())
63 return getOriginHost(it->second);