m_ShuttingDown = true;
/* stop all components */
- Component::Ptr component;
- BOOST_FOREACH(tie(tuples::ignore, component), m_Components) {
+ BOOST_FOREACH(const Component::Ptr& component, m_Components | map_values) {
component->Stop();
}
#include <boost/lexical_cast.hpp>
#include <boost/foreach.hpp>
#include <boost/tuple/tuple.hpp>
+#include <boost/range.hpp>
+#include <boost/range/adaptor/map.hpp>
using boost::shared_ptr;
using boost::weak_ptr;
using boost::condition_variable;
using boost::system_time;
using boost::tie;
-
-namespace tuples = boost::tuples;
+using boost::adaptors::map_keys;
+using boost::adaptors::map_values;
#if defined(__APPLE__) && defined(__MACH__)
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
FD_ZERO(&readfds);
- int fd;
- BOOST_FOREACH(tie(fd, tuples::ignore), tasks) {
+ BOOST_FOREACH(int fd, tasks | map_keys) {
if (fd > nfds)
nfds = fd;
if (GetProperty("dependencies", &dependencies)) {
dependencies = Service::ResolveDependencies(*this, dependencies);
- Variant dependency;
- BOOST_FOREACH(tie(tuples::ignore, dependency), dependencies) {
+ BOOST_FOREACH(const Variant& dependency, dependencies | map_values) {
Service service = Service::GetByName(dependency);
string parent = service.GetHost().GetName();
if (GetProperty("dependencies", &dependencies)) {
dependencies = Service::ResolveDependencies(*this, dependencies);
- Variant dependency;
- BOOST_FOREACH(tie(tuples::ignore, dependency), dependencies) {
+ BOOST_FOREACH(const Variant& dependency, dependencies | map_values) {
Service service = Service::GetByName(dependency);
if (!service.IsReachable() ||
if (GetProperty("hostchecks", &hostchecks)) {
hostchecks = Service::ResolveDependencies(*this, hostchecks);
- Variant hostcheck;
- BOOST_FOREACH(tie(tuples::ignore, hostcheck), hostchecks) {
+ BOOST_FOREACH(const Variant& hostcheck, hostchecks | map_values) {
Service service = Service::GetByName(hostcheck);
if (service.GetState() != StateOK && service.GetState() != StateWarning) {
if (!dependencies)
return;
- Variant dependency;
- BOOST_FOREACH(tie(tuples::ignore, dependency), dependencies) {
+ BOOST_FOREACH(const Variant& dependency, dependencies | map_values) {
if (result->Contains(dependency))
continue;
Dictionary::Ptr dependencies = boost::make_shared<Dictionary>();
GetDependenciesRecursive(dependencies);
- Variant dependency;
- BOOST_FOREACH(tie(tuples::ignore, dependency), dependencies) {
+ BOOST_FOREACH(const Variant& dependency, dependencies | map_values) {
Service service = Service::GetByName(dependency);
/* ignore ourselves */
if (!checkers)
return true;
- Variant pattern;
- BOOST_FOREACH(tie(tuples::ignore, pattern), checkers) {
+ BOOST_FOREACH(const Variant& pattern, checkers | map_values) {
if (Utility::Match(pattern, checker))
return true;
}
Dictionary::Ptr result = boost::make_shared<Dictionary>();
- Variant dependency;
- BOOST_FOREACH(tie(tuples::ignore, dependency), dependencies) {
+ BOOST_FOREACH(const Variant& dependency, dependencies | map_values) {
string name;
if (services && services->Contains(dependency))
ConfigObject::TMap::Range range;
range = ConfigObject::GetObjects("host");
- ConfigObject::Ptr object;
- BOOST_FOREACH(tie(tuples::ignore, object), range) {
+ BOOST_FOREACH(const ConfigObject::Ptr& object, range | map_values) {
Host host = object;
Dictionary::Ptr dict;
dict = host.GetGroups();
if (dict) {
- Variant hostgroup;
- BOOST_FOREACH(tie(tuples::ignore, hostgroup), dict) {
+ BOOST_FOREACH(const Variant& hostgroup, dict | map_values) {
hostgroups[hostgroup].push_back(host.GetName());
}
}
map<string, vector<Service> > servicegroups;
- BOOST_FOREACH(tie(tuples::ignore, object), range) {
+ BOOST_FOREACH(const ConfigObject::Ptr& object, range | map_values) {
Service service = object;
Dictionary::Ptr dict;
dict = service.GetGroups();
if (dict) {
- Variant servicegroup;
- BOOST_FOREACH(tie(tuples::ignore, servicegroup), dict) {
+ BOOST_FOREACH(const Variant& servicegroup, dict | map_values) {
servicegroups[servicegroup].push_back(service);
}
}
}
if (oldServices) {
- ConfigItem::Ptr service;
- BOOST_FOREACH(tie(tuples::ignore, service), oldServices) {
+ BOOST_FOREACH(const ConfigItem::Ptr& service, oldServices | map_values) {
if (!newServices->Contains(service->GetName()))
service->Unregister();
}
if (!services)
return;
- ConfigItem::Ptr service;
- BOOST_FOREACH(tie(tuples::ignore, service), services) {
+ BOOST_FOREACH(const ConfigItem::Ptr& service, services | map_values) {
service->Unregister();
}
}
if (delegated > 0) {
if (need_clear) {
- Endpoint::Ptr endpoint;
- BOOST_FOREACH(tie(endpoint, tuples::ignore), histogram) {
+ BOOST_FOREACH(const Endpoint::Ptr& endpoint, histogram | map_keys) {
ClearServices(endpoint);
}
}
- BOOST_FOREACH(Service& service, services) {
+ BOOST_FOREACH(const Service& service, services) {
string checker = service.GetChecker();
Endpoint::Ptr endpoint = EndpointManager::GetInstance()->GetEndpointByIdentity(checker);
// register published/subscribed topics for this endpoint
ComponentDiscoveryInfo::Ptr info = ic->second;
- BOOST_FOREACH(string publication, info->Publications) {
+ BOOST_FOREACH(const string& publication, info->Publications) {
endpoint->RegisterPublication(publication);
}
- BOOST_FOREACH(string subscription, info->Subscriptions) {
+ BOOST_FOREACH(const string& subscription, info->Subscriptions) {
endpoint->RegisterSubscription(subscription);
}
set<string>::iterator i;
Dictionary::Ptr subscriptions = boost::make_shared<Dictionary>();
- BOOST_FOREACH(string subscription, info->Subscriptions) {
+ BOOST_FOREACH(const string &subscription, info->Subscriptions) {
subscriptions->Add(subscription);
}
params.SetSubscriptions(subscriptions);
Dictionary::Ptr publications = boost::make_shared<Dictionary>();
- BOOST_FOREACH(string publication, info->Publications) {
+ BOOST_FOREACH(const string& publication, info->Publications) {
publications->Add(publication);
}
ConfigObject::TMap::Range range = ConfigObject::GetObjects("role");
- ConfigObject::Ptr role;
- BOOST_FOREACH(tie(tuples::ignore, role), range) {
+ BOOST_FOREACH(const ConfigObject::Ptr& role, range | map_values) {
Dictionary::Ptr permissions;
if (!role->GetProperty(messageType, &permissions))
continue;
- Variant permission;
- BOOST_FOREACH(tie(tuples::ignore, permission), permissions) {
+ BOOST_FOREACH(const Variant& permission, permissions | map_values) {
if (Utility::Match(permission, message))
return true;
}
Dictionary::Ptr publications;
if (message.GetPublications(&publications)) {
- Variant publication;
- BOOST_FOREACH(tie(tuples::ignore, publication), publications) {
+ BOOST_FOREACH(const Variant& publication, publications | map_values) {
if (trusted || HasMessagePermission(roles, "publications", publication)) {
info->Publications.insert(publication);
if (endpoint)
Dictionary::Ptr subscriptions;
if (message.GetSubscriptions(&subscriptions)) {
- Variant subscription;
- BOOST_FOREACH(tie(tuples::ignore, subscription), subscriptions) {
+ BOOST_FOREACH(const Variant& subscription, subscriptions | map_values) {
if (trusted || HasMessagePermission(roles, "subscriptions", subscription)) {
info->Subscriptions.insert(subscription);
if (endpoint)
/* check whether we have to reconnect to one of our upstream endpoints */
ConfigObject::TMap::Range range = ConfigObject::GetObjects("endpoint");
- ConfigObject::Ptr object;
- BOOST_FOREACH(tie(tuples::ignore, object), range) {
+ BOOST_FOREACH(const ConfigObject::Ptr& object, range | map_values) {
/* Check if we're already connected to this endpoint. */
if (endpointManager->GetEndpointByIdentity(object->GetName()))
continue;
throw invalid_argument("Message is missing the 'method' property.");
vector<Endpoint::Ptr> candidates;
- Endpoint::Ptr endpoint;
- BOOST_FOREACH(tie(tuples::ignore, endpoint), m_Endpoints) {
+ BOOST_FOREACH(const Endpoint::Ptr& endpoint, m_Endpoints | map_values) {
/* don't forward messages between non-local endpoints */
if (!sender->IsLocal() && !endpoint->IsLocal())
continue;
if (!message.GetMethod(&method))
throw invalid_argument("Message is missing the 'method' property.");
- Endpoint::Ptr recipient;
- BOOST_FOREACH(tie(tuples::ignore, recipient), m_Endpoints) {
+ BOOST_FOREACH(const Endpoint::Ptr& recipient, m_Endpoints | map_values) {
/* don't forward messages back to the sender */
if (sender == recipient)
continue;