From 7b1fb02d6a252c499432b7c90e2d08d5da05b66e Mon Sep 17 00:00:00 2001 From: Gabriel Corona Date: Wed, 9 Dec 2015 13:25:12 +0100 Subject: [PATCH] Remove 'using namespace foo;' in headers --- src/surf/host_clm03.cpp | 6 +++++- src/surf/host_ptask_L07.cpp | 7 ++++++- src/surf/host_ptask_L07.hpp | 6 +++++- src/surf/network_cm02.cpp | 8 +++++--- src/surf/network_ib.cpp | 9 ++++++--- src/surf/network_interface.cpp | 4 +++- src/surf/network_smpi.cpp | 8 +++++++- src/surf/ns3/ns3_simulator.h | 21 ++++++++++----------- src/surf/surf_interface.hpp | 2 -- src/surf/surf_routing_cluster_fat_tree.cpp | 18 +++++++++++++----- src/surf/surf_routing_cluster_fat_tree.hpp | 6 +++++- src/surf/surf_routing_generic.cpp | 13 +++++++++++-- src/surf/vm_hl13.cpp | 4 +++- 13 files changed, 79 insertions(+), 33 deletions(-) diff --git a/src/surf/host_clm03.cpp b/src/surf/host_clm03.cpp index 5a48110bc3..e7151dbfcc 100644 --- a/src/surf/host_clm03.cpp +++ b/src/surf/host_clm03.cpp @@ -4,6 +4,10 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ +#include + +#include + #include "host_clm03.hpp" #include "cpu_cas01.hpp" @@ -62,7 +66,7 @@ double HostCLM03Model::shareResources(double now){ typeid(surf_network_model).name(), min_by_net, typeid(surf_storage_model).name(), min_by_sto); - double res = max(max(min_by_cpu, min_by_net), min_by_sto); + double res = std::max(std::max(min_by_cpu, min_by_net), min_by_sto); if (min_by_cpu >= 0.0 && min_by_cpu < res) res = min_by_cpu; if (min_by_net >= 0.0 && min_by_net < res) diff --git a/src/surf/host_ptask_L07.cpp b/src/surf/host_ptask_L07.cpp index ff196aa18d..57367bb78f 100644 --- a/src/surf/host_ptask_L07.cpp +++ b/src/surf/host_ptask_L07.cpp @@ -4,6 +4,10 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ +#include + +#include + #include "host_ptask_L07.hpp" #include "cpu_interface.hpp" @@ -596,7 +600,8 @@ void L07Action::updateBound() if (m_rate < 0) lmm_update_variable_bound(ptask_maxmin_system, getVariable(), lat_bound); else - lmm_update_variable_bound(ptask_maxmin_system, getVariable(), min(m_rate, lat_bound)); + lmm_update_variable_bound(ptask_maxmin_system, getVariable(), + std::min(m_rate, lat_bound)); } } diff --git a/src/surf/host_ptask_L07.hpp b/src/surf/host_ptask_L07.hpp index 40d0fa591c..60454c9f74 100644 --- a/src/surf/host_ptask_L07.hpp +++ b/src/surf/host_ptask_L07.hpp @@ -4,6 +4,10 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ +#include + +#include + #include #include "host_interface.hpp" @@ -170,7 +174,7 @@ public: void setPriority(double priority); double getRemains(); - vector * p_edgeList = new vector(); + std::vector * p_edgeList = new std::vector(); double *p_computationAmount; double *p_communicationAmount; double m_latency; diff --git a/src/surf/network_cm02.cpp b/src/surf/network_cm02.cpp index ff820b286c..50fb7bee7c 100644 --- a/src/surf/network_cm02.cpp +++ b/src/surf/network_cm02.cpp @@ -4,6 +4,8 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ +#include + #include "network_cm02.hpp" #include "maxmin_private.hpp" #include "simgrid/sg_config.h" @@ -406,7 +408,7 @@ Action *NetworkCm02Model::communicate(RoutingEdge *src, RoutingEdge *dst, link = static_cast(_link); double bb = bandwidthFactor(size) * link->getBandwidth(); bandwidth_bound = - (bandwidth_bound < 0.0) ? bb : min(bandwidth_bound, bb); + (bandwidth_bound < 0.0) ? bb : std::min(bandwidth_bound, bb); } action->m_latCurrent = action->m_latency; @@ -442,7 +444,7 @@ Action *NetworkCm02Model::communicate(RoutingEdge *src, RoutingEdge *dst, if (action->m_rate < 0) { lmm_update_variable_bound(p_maxminSystem, action->getVariable(), (action->m_latCurrent > 0) ? sg_tcp_gamma / (2.0 * action->m_latCurrent) : -1.0); } else { - lmm_update_variable_bound(p_maxminSystem, action->getVariable(), (action->m_latCurrent > 0) ? min(action->m_rate, sg_tcp_gamma / (2.0 * action->m_latCurrent)) : action->m_rate); + lmm_update_variable_bound(p_maxminSystem, action->getVariable(), (action->m_latCurrent > 0) ? std::min(action->m_rate, sg_tcp_gamma / (2.0 * action->m_latCurrent)) : action->m_rate); } xbt_dynar_foreach(route, i, _link) { @@ -640,7 +642,7 @@ void NetworkCm02Link::updateLatency(double value, double date){ lmm_update_variable_bound(getModel()->getMaxminSystem(), action->getVariable(), sg_tcp_gamma / (2.0 * action->m_latCurrent)); else { lmm_update_variable_bound(getModel()->getMaxminSystem(), action->getVariable(), - min(action->m_rate, sg_tcp_gamma / (2.0 * action->m_latCurrent))); + std::min(action->m_rate, sg_tcp_gamma / (2.0 * action->m_latCurrent))); if (action->m_rate < sg_tcp_gamma / (2.0 * action->m_latCurrent)) { XBT_INFO("Flow is limited BYBANDWIDTH"); diff --git a/src/surf/network_ib.cpp b/src/surf/network_ib.cpp index 98ee6c599a..4e51c2b2df 100644 --- a/src/surf/network_ib.cpp +++ b/src/surf/network_ib.cpp @@ -4,6 +4,9 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ +#include +#include + #include "network_ib.hpp" #include "simgrid/sg_config.h" #include "maxmin_private.hpp" @@ -53,7 +56,7 @@ static void IB_action_init_callback(NetworkAction *action,RoutingEdge *src, Rout xbt_die("could not find dst node active comms !"); // act_dst->rate=rate; - ((NetworkIBModel*)surf_network_model)->active_comms[action]=make_pair(act_src, act_dst); + ((NetworkIBModel*)surf_network_model)->active_comms[action]=std::make_pair(act_src, act_dst); //post the action in the second dist, to retrieve in the other callback XBT_DEBUG("IB callback - action %p init", action); @@ -136,7 +139,7 @@ void NetworkIBModel::computeIBfactors(IBNode *root) { my_penalty_out = num_comm_out * Bs; } - max_penalty_out = max(max_penalty_out,my_penalty_out); + max_penalty_out = std::max(max_penalty_out,my_penalty_out); } for (std::vector::iterator it= root->ActiveCommsUp.begin(); it != root->ActiveCommsUp.end(); ++it) { @@ -149,7 +152,7 @@ void NetworkIBModel::computeIBfactors(IBNode *root) { * Be * (*it)->destination->ActiveCommsDown.size();//number of different nodes sending to dest - double penalty=max(my_penalty_in,max_penalty_out); + double penalty = std::max(my_penalty_in,max_penalty_out); double rate_before_update = (*it)->action->getBound(); //save initial rate of the action diff --git a/src/surf/network_interface.cpp b/src/surf/network_interface.cpp index 15df730be1..b64761a91c 100644 --- a/src/surf/network_interface.cpp +++ b/src/surf/network_interface.cpp @@ -4,6 +4,8 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ +#include + #include "network_interface.hpp" #include "simgrid/sg_config.h" @@ -164,7 +166,7 @@ double NetworkModel::shareResourcesFull(double now) } #endif if (action->m_latency > 0) { - minRes = (minRes < 0) ? action->m_latency : min(minRes, action->m_latency); + minRes = (minRes < 0) ? action->m_latency : std::min(minRes, action->m_latency); } } diff --git a/src/surf/network_smpi.cpp b/src/surf/network_smpi.cpp index 045ccc5c96..c30c13fd2c 100644 --- a/src/surf/network_smpi.cpp +++ b/src/surf/network_smpi.cpp @@ -4,6 +4,12 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ +#include + +#include + +#include + #include "network_smpi.hpp" #include "simgrid/sg_config.h" @@ -208,7 +214,7 @@ double NetworkSmpiModel::latencyFactor(double size) double NetworkSmpiModel::bandwidthConstraint(double rate, double bound, double size) { - return rate < 0 ? bound : min(bound, rate * bandwidthFactor(size)); + return rate < 0 ? bound : std::min(bound, rate * bandwidthFactor(size)); } /************ diff --git a/src/surf/ns3/ns3_simulator.h b/src/surf/ns3/ns3_simulator.h index 04f324a27d..740c7e1e7e 100644 --- a/src/surf/ns3/ns3_simulator.h +++ b/src/surf/ns3/ns3_simulator.h @@ -9,6 +9,8 @@ #ifdef __cplusplus +#include + #include "ns3/core-module.h" #include "my-point-to-point-helper.h" @@ -22,14 +24,11 @@ #include "ns3/inet-socket-address.h" #include "ns3/tcp-socket-factory.h" -using namespace ns3; -using namespace std; - struct MySocket{ - uint32_t bufferedBytes; - uint32_t sentBytes; - uint32_t remaining; - uint32_t totalBytes; + std::uint32_t bufferedBytes; + std::uint32_t sentBytes; + std::uint32_t remaining; + std::uint32_t totalBytes; char finished; void* action; }; @@ -42,12 +41,12 @@ private: public: NS3Sim(); ~NS3Sim(); - void create_flow_NS3(Ptr src, - Ptr dst, - uint16_t port_number, + void create_flow_NS3(ns3::Ptr src, + ns3::Ptr dst, + std::uint16_t port_number, double start, const char *addr, - uint32_t TotalBytes, + std::uint32_t TotalBytes, void * action); void simulator_start(double min); void* get_action_from_socket(void *socket); diff --git a/src/surf/surf_interface.hpp b/src/surf/surf_interface.hpp index 1d5611f615..213e6d42fb 100644 --- a/src/surf/surf_interface.hpp +++ b/src/surf/surf_interface.hpp @@ -75,8 +75,6 @@ namespace surf { extern XBT_PRIVATE tmgr_history_t history; #define NO_MAX_DURATION -1.0 -using namespace std; - /********* * Utils * *********/ diff --git a/src/surf/surf_routing_cluster_fat_tree.cpp b/src/surf/surf_routing_cluster_fat_tree.cpp index 6527e15755..e7f1c66777 100644 --- a/src/surf/surf_routing_cluster_fat_tree.cpp +++ b/src/surf/surf_routing_cluster_fat_tree.cpp @@ -1,3 +1,11 @@ +#include + +#include +#include +#include +#include +#include + #include "surf_routing_cluster_fat_tree.hpp" #include "xbt/lib.h" @@ -407,8 +415,8 @@ void AsClusterFatTree::addLink(FatTreeNode *parent, unsigned int parentPort, void AsClusterFatTree::parse_specific_arguments(sg_platf_cluster_cbarg_t cluster) { - std::vector parameters; - std::vector tmp; + std::vector parameters; + std::vector tmp; boost::split(parameters, cluster->topo_parameters, boost::is_any_of(";")); @@ -455,12 +463,12 @@ void AsClusterFatTree::parse_specific_arguments(sg_platf_cluster_cbarg_t } -void AsClusterFatTree::generateDotFile(const string& filename) const { - ofstream file; +void AsClusterFatTree::generateDotFile(const std::string& filename) const { + std::ofstream file; /* Maybe should we get directly a char*, as open takes strings only beginning * with C++11... */ - file.open(filename.c_str(), ios::out | ios::trunc); + file.open(filename.c_str(), std::ios::out | std::ios::trunc); if(file.is_open()) { file << "graph AsClusterFatTree {\n"; diff --git a/src/surf/surf_routing_cluster_fat_tree.hpp b/src/surf/surf_routing_cluster_fat_tree.hpp index 91a2c46c1e..78cbfae03b 100644 --- a/src/surf/surf_routing_cluster_fat_tree.hpp +++ b/src/surf/surf_routing_cluster_fat_tree.hpp @@ -7,6 +7,10 @@ #ifndef SURF_ROUTING_CLUSTER_FAT_TREE_HPP_ #define SURF_ROUTING_CLUSTER_FAT_TREE_HPP_ +#include +#include +#include + #include #include "surf_routing_cluster.hpp" @@ -132,7 +136,7 @@ public: /** \brief Add a processing node. */ void addProcessingNode(int id); - void generateDotFile(const string& filename = "fatTree.dot") const; + void generateDotFile(const std::string& filename = "fatTree.dot") const; private: diff --git a/src/surf/surf_routing_generic.cpp b/src/surf/surf_routing_generic.cpp index febb60a519..fc14c8f323 100644 --- a/src/surf/surf_routing_generic.cpp +++ b/src/surf/surf_routing_generic.cpp @@ -4,11 +4,20 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ +#include + +#include + +#include +#include +#include +#include +#include + #include "simgrid/platf_interface.h" // platform creation API internal interface #include "surf_routing_generic.hpp" #include "network_interface.hpp" -#include "xbt/graph.h" XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_routing_generic, surf_route, "Generic implementation of the surf routing"); @@ -271,7 +280,7 @@ sg_platf_route_cbarg_t AsGeneric::getBypassRoute(RoutingEdge *src, int max_index_src = path_src->used - 1; int max_index_dst = path_dst->used - 1; - int max_index = max(max_index_src, max_index_dst); + int max_index = std::max(max_index_src, max_index_dst); int i, max; for (max = 0; max <= max_index; max++) { diff --git a/src/surf/vm_hl13.cpp b/src/surf/vm_hl13.cpp index 7d7373ea16..09eefddd1d 100644 --- a/src/surf/vm_hl13.cpp +++ b/src/surf/vm_hl13.cpp @@ -4,6 +4,8 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ +#include + #include "cpu_cas01.hpp" #include "vm_hl13.hpp" @@ -110,7 +112,7 @@ double VMHL13Model::shareResources(double now) typeid(surf_network_model).name(), min_by_net, typeid(surf_storage_model).name(), min_by_sto); - double ret = max(max(min_by_cpu, min_by_net), min_by_sto); + double ret = std::max(std::max(min_by_cpu, min_by_net), min_by_sto); if (min_by_cpu >= 0.0 && min_by_cpu < ret) ret = min_by_cpu; if (min_by_net >= 0.0 && min_by_net < ret) -- 2.20.1