Skip to content

Commit

Permalink
resource: [cleanup] avoid 'using namespace boost'
Browse files Browse the repository at this point in the history
Problem: with g++ 5.4.0, the integer types in stdint.h
(or cstdint) have the same names as types defined within
boost, resulting in "ambiguous type" errors.

Avoid 'using namespace boost' in Flux code.  Instead,
prefix all boost symbols with boost::
  • Loading branch information
garlick committed Mar 30, 2018
1 parent 889c569 commit 05a2802
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 78 deletions.
6 changes: 2 additions & 4 deletions resource/dfu_match_id_based.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ class greater_interval_first_t : public dfu_match_cb_t
const std::vector<Flux::Jobspec::Resource> &resources,
const f_resource_graph_t &g, scoring_api_t &dfu)
{
using namespace boost;
using namespace boost::icl;
int score = MATCH_MET;
fold::interval_greater comp;
Expand All @@ -230,7 +229,7 @@ class greater_interval_first_t : public dfu_match_cb_t
break;
}
dfu.transform (subsystem, type,
icl::inserter (comp.ivset, comp.ivset.end ()),
boost::icl::inserter (comp.ivset, comp.ivset.end ()),
fold::to_interval);
dfu.choose_accum_best_k (subsystem, type, count, comp);
}
Expand All @@ -242,7 +241,6 @@ class greater_interval_first_t : public dfu_match_cb_t
const std::vector<Flux::Jobspec::Resource> &resources,
const f_resource_graph_t &g, scoring_api_t &dfu)
{
using namespace boost;
using namespace boost::icl;
int score = MATCH_MET;
int64_t overall;
Expand All @@ -261,7 +259,7 @@ class greater_interval_first_t : public dfu_match_cb_t
break;
}
dfu.transform (subsystem, c_type,
icl::inserter (comp.ivset, comp.ivset.end ()),
boost::icl::inserter (comp.ivset, comp.ivset.end ()),
fold::to_interval);
dfu.choose_accum_best_k (subsystem, c_type, count, comp);
}
Expand Down
11 changes: 5 additions & 6 deletions resource/resource_gen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,13 @@ extern "C" {
}

using namespace std;
using namespace boost;
using namespace Flux::resource_model;

/*! Note that this class must be copy-constructible
* required by the concept of the depth first search
* visitor. It must be lightweight.
*/
class dfs_emitter_t : public default_dfs_visitor {
class dfs_emitter_t : public boost::default_dfs_visitor {
public:
dfs_emitter_t ();
dfs_emitter_t (resource_graph_db_t *db_p, resource_gen_spec_t *g);
Expand Down Expand Up @@ -184,7 +183,7 @@ vtx_t dfs_emitter_t::emit_vertex (ggv_t u, gge_t e, const gg_t &recipe,
vtx_t src_v, int i, int sz, int j)
{
resource_graph_db_t &db = *m_db_p;
if (src_v == graph_traits<resource_graph_t>::null_vertex())
if (src_v == boost::graph_traits<resource_graph_t>::null_vertex())
if (db.roots.find (recipe[u].subsystem) != db.roots.end ())
return db.roots[recipe[u].subsystem];

Expand All @@ -193,7 +192,7 @@ vtx_t dfs_emitter_t::emit_vertex (ggv_t u, gge_t e, const gg_t &recipe,
string ssys = recipe[u].subsystem;
int id = 0;

if (src_v == graph_traits<resource_graph_t>::null_vertex()) {
if (src_v == boost::graph_traits<resource_graph_t>::null_vertex()) {
// ROOT!!
db.roots[recipe[u].subsystem] = v;
id = 0;
Expand Down Expand Up @@ -290,7 +289,7 @@ void dfs_emitter_t::tree_edge (gge_t e, const gg_t &recipe)
if (recipe[src_ggv].root) {
//! ROOT
if (m_gen_src_vtx[src_ggv].empty ()) {
vtx_t null_v = graph_traits<resource_graph_t>::null_vertex();
vtx_t null_v = boost::graph_traits<resource_graph_t>::null_vertex();
m_gen_src_vtx[src_ggv].push_back (emit_vertex (src_ggv, e, recipe,
null_v, 0, 1, 0));
}
Expand Down Expand Up @@ -453,7 +452,7 @@ int resource_generator_t::read_graphml (const string &fn, resource_graph_db_t &d
// with emitter visitor.
//
dfs_emitter_t emitter (&db, &m_gspec);
depth_first_search (m_gspec.gen_graph (), visitor (emitter));
depth_first_search (m_gspec.gen_graph (), boost::visitor (emitter));
m_err_msg += emitter.err_message ();

return (m_err_msg == "")? rc : -1;
Expand Down
7 changes: 3 additions & 4 deletions resource/resource_gen_spec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ extern "C" {
}

using namespace std;
using namespace boost;
using namespace Flux::resource_model;

struct str2enum_t
Expand Down Expand Up @@ -87,7 +86,7 @@ class gg_label_writer_sim_t {
* *
********************************************************************************/

void resource_gen_spec_t::setup_dynamic_property (dynamic_properties &dp, gg_t &g)
void resource_gen_spec_t::setup_dynamic_property (boost::dynamic_properties &dp, gg_t &g)
{
dp.property("root", get(&resource_pool_gen_t::root, g));
dp.property("type", get(&resource_pool_gen_t::type, g));
Expand Down Expand Up @@ -159,7 +158,7 @@ int resource_gen_spec_t::read_graphml (const string &ifn)

try {
boost::read_graphml (in_file, g, dp);
} catch (graph_exception &e) {
} catch (boost::graph_exception &e) {
cerr << e.what () << endl;
rc = -1;
}
Expand Down Expand Up @@ -199,7 +198,7 @@ int resource_gen_spec_t::write_graphviz (const string &ofn, bool simple)
gg_label_writer_sim_t<edg_relation_map_t> ewr (e_rel_map);
boost::write_graphviz (out_file, g, vwr, ewr);
}
} catch (graph_exception &e) {
} catch (boost::graph_exception &e) {
cerr << e.what () << endl;
rc = -1;
}
Expand Down
40 changes: 19 additions & 21 deletions resource/resource_gen_spec.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@
namespace Flux {
namespace resource_model {

using namespace boost;

enum gen_meth_t {
MULTIPLY,
ASSOCIATE_IN,
Expand Down Expand Up @@ -66,30 +64,30 @@ struct relation_gen_t {
int as_src_uplvl;
};

typedef adjacency_list<
vecS,
vecS,
directedS,
typedef boost::adjacency_list<
boost::vecS,
boost::vecS,
boost::directedS,
resource_pool_gen_t,
relation_gen_t
> gg_t;

typedef std::string resource_pool_gen_t::* pgen_t;
typedef std::string relation_gen_t::* rgen_t;
typedef graph_traits<gg_t>::vertex_descriptor ggv_t;
typedef graph_traits<gg_t>::edge_descriptor gge_t;
typedef boost::graph_traits<gg_t>::vertex_descriptor ggv_t;
typedef boost::graph_traits<gg_t>::edge_descriptor gge_t;

typedef property_map<gg_t, pgen_t>::type vtx_type_map_t;
typedef property_map<gg_t, pgen_t>::type vtx_basename_map_t;
typedef property_map<gg_t, long resource_pool_gen_t::* >::type vtx_size_map_t;
typedef property_map<gg_t, pgen_t>::type vtx_unit_map_t;
typedef property_map<gg_t, pgen_t>::type vtx_subsystem_map_t;
typedef property_map<gg_t, rgen_t>::type edg_e_subsystem_map_t;
typedef property_map<gg_t, rgen_t>::type edg_relation_map_t;
typedef property_map<gg_t, rgen_t>::type edg_rrelation_map_t;
typedef property_map<gg_t, rgen_t>::type edg_gen_method_map_t;
typedef property_map<gg_t, rgen_t>::type edg_id_method_map_t;
typedef property_map<gg_t, int relation_gen_t::* >::type edg_multi_scale_map_t;
typedef boost::property_map<gg_t, pgen_t>::type vtx_type_map_t;
typedef boost::property_map<gg_t, pgen_t>::type vtx_basename_map_t;
typedef boost::property_map<gg_t, long resource_pool_gen_t::* >::type vtx_size_map_t;
typedef boost::property_map<gg_t, pgen_t>::type vtx_unit_map_t;
typedef boost::property_map<gg_t, pgen_t>::type vtx_subsystem_map_t;
typedef boost::property_map<gg_t, rgen_t>::type edg_e_subsystem_map_t;
typedef boost::property_map<gg_t, rgen_t>::type edg_relation_map_t;
typedef boost::property_map<gg_t, rgen_t>::type edg_rrelation_map_t;
typedef boost::property_map<gg_t, rgen_t>::type edg_gen_method_map_t;
typedef boost::property_map<gg_t, rgen_t>::type edg_id_method_map_t;
typedef boost::property_map<gg_t, int relation_gen_t::* >::type edg_multi_scale_map_t;

class resource_gen_spec_t {
public:
Expand All @@ -101,9 +99,9 @@ class resource_gen_spec_t {
int write_graphviz (const std::string &ofn, bool simple=false);

private:
void setup_dynamic_property (dynamic_properties &dp, gg_t &g);
void setup_dynamic_property (boost::dynamic_properties &dp, gg_t &g);
gg_t g;
dynamic_properties dp;
boost::dynamic_properties dp;
};

} // namespace resource_model
Expand Down
38 changes: 18 additions & 20 deletions resource/resource_graph.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,14 @@
namespace Flux {
namespace resource_model {

using namespace boost;

enum class emit_format_t { GRAPHVIZ_DOT, GRAPH_ML, };

typedef pool_infra_t resource_pool_t::* pinfra_t;
typedef std::string resource_pool_t::* pname_t;
typedef std::string resource_relation_t::* rname_t;
typedef relation_infra_t resource_relation_t::* rinfra_t;

typedef adjacency_list<vecS, vecS, directedS, resource_pool_t,
typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::directedS, resource_pool_t,
resource_relation_t, std::string> resource_graph_t;

/*! For each chosen subsystem, a selector has std::set<string>.
Expand All @@ -65,7 +63,7 @@ class subsystem_selector_t {
m_selector = sel;
}
bool operator () (const graph_entity &ent) const {
typedef typename property_traits<inframap>::value_type infra_type;
typedef typename boost::property_traits<inframap>::value_type infra_type;
const infra_type &inf = get (m_imap, ent);
const multi_subsystems_t &subsystems = inf.member_of;
for (auto &kv : subsystems) {
Expand All @@ -87,25 +85,25 @@ class subsystem_selector_t {
inframap m_imap;
};

typedef property_map<resource_graph_t, pinfra_t>::type vtx_infra_map_t;
typedef property_map<resource_graph_t, rinfra_t>::type edg_infra_map_t;
typedef graph_traits<resource_graph_t>::vertex_descriptor vtx_t;
typedef graph_traits<resource_graph_t>::edge_descriptor edg_t;
typedef graph_traits<resource_graph_t>::vertex_iterator vtx_iterator_t;
typedef graph_traits<resource_graph_t>::edge_iterator edg_iterator_t;
typedef graph_traits<resource_graph_t>::out_edge_iterator out_edg_iterator_t;
typedef filtered_graph<resource_graph_t,
typedef boost::property_map<resource_graph_t, pinfra_t>::type vtx_infra_map_t;
typedef boost::property_map<resource_graph_t, rinfra_t>::type edg_infra_map_t;
typedef boost::graph_traits<resource_graph_t>::vertex_descriptor vtx_t;
typedef boost::graph_traits<resource_graph_t>::edge_descriptor edg_t;
typedef boost::graph_traits<resource_graph_t>::vertex_iterator vtx_iterator_t;
typedef boost::graph_traits<resource_graph_t>::edge_iterator edg_iterator_t;
typedef boost::graph_traits<resource_graph_t>::out_edge_iterator out_edg_iterator_t;
typedef boost::filtered_graph<resource_graph_t,
subsystem_selector_t<edg_t, edg_infra_map_t>,
subsystem_selector_t<vtx_t, vtx_infra_map_t>>
f_resource_graph_t;
typedef property_map<f_resource_graph_t, rinfra_t>::type f_edg_infra_map_t;
typedef property_map<f_resource_graph_t, pinfra_t>::type f_vtx_infra_map_t;
typedef property_map<f_resource_graph_t, pname_t>::type f_res_name_map_t;
typedef property_map<f_resource_graph_t, rname_t>::type f_rel_name_map_t;
typedef property_map<f_resource_graph_t, pinfra_t>::type f_vtx_infra_map_t;
typedef graph_traits<f_resource_graph_t>::vertex_iterator f_vtx_iterator_t;
typedef graph_traits<f_resource_graph_t>::edge_iterator f_edg_iterator_t;
typedef graph_traits<f_resource_graph_t>::out_edge_iterator f_out_edg_iterator_t;
typedef boost::property_map<f_resource_graph_t, rinfra_t>::type f_edg_infra_map_t;
typedef boost::property_map<f_resource_graph_t, pinfra_t>::type f_vtx_infra_map_t;
typedef boost::property_map<f_resource_graph_t, pname_t>::type f_res_name_map_t;
typedef boost::property_map<f_resource_graph_t, rname_t>::type f_rel_name_map_t;
typedef boost::property_map<f_resource_graph_t, pinfra_t>::type f_vtx_infra_map_t;
typedef boost::graph_traits<f_resource_graph_t>::vertex_iterator f_vtx_iterator_t;
typedef boost::graph_traits<f_resource_graph_t>::edge_iterator f_edg_iterator_t;
typedef boost::graph_traits<f_resource_graph_t>::out_edge_iterator f_out_edg_iterator_t;

/*! Resource graph data store.
* Adjacency_list graph, roots of this graph and various indexing.
Expand Down
3 changes: 1 addition & 2 deletions resource/utilities/grug2dot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ extern "C" {
}

using namespace std;
using namespace boost;
using namespace Flux::resource_model;

#define OPTIONS "hm"
Expand Down Expand Up @@ -85,7 +84,7 @@ int main (int argc, char *argv[])

resource_gen_spec_t gspec;
string fn (argv[optind]);
filesystem::path path = fn;
boost::filesystem::path path = fn;
string base = path.stem ().string ();

if (gspec.read_graphml (fn) != 0) {
Expand Down
41 changes: 20 additions & 21 deletions resource/utilities/resource-query.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ extern "C" {
}

using namespace std;
using namespace boost;
using namespace Flux::resource_model;

#define OPTIONS "G:S:P:g:o:t:e:h"
Expand Down Expand Up @@ -176,9 +175,9 @@ static void set_default_params (resource_context_t *ctx)
static int string_to_graph_format (string st, emit_format_t &format)
{
int rc = 0;
if (iequals (st, string ("dot")))
if (boost::iequals (st, string ("dot")))
format = emit_format_t::GRAPHVIZ_DOT;
else if (iequals (st, string ("graphml")))
else if (boost::iequals (st, string ("graphml")))
format = emit_format_t::GRAPH_ML;
else
rc = -1;
Expand Down Expand Up @@ -216,57 +215,57 @@ static int set_subsystems_use (resource_context_t *ctx, string n)
dfu_match_cb_t &matcher = *(ctx->matcher);
const string &matcher_type = matcher.matcher_name ();

if (iequals (matcher_type, string ("CA"))) {
if (boost::iequals (matcher_type, string ("CA"))) {
if ( (rc = subsystem_exist (ctx, "containment")) == 0)
matcher.add_subsystem ("containment", "*");
} else if (iequals (matcher_type, string ("IBA"))) {
} else if (boost::iequals (matcher_type, string ("IBA"))) {
if ( (rc = subsystem_exist (ctx, "ibnet")) == 0)
matcher.add_subsystem ("ibnet", "*");
} else if (iequals (matcher_type, string ("IBBA"))) {
} else if (boost::iequals (matcher_type, string ("IBBA"))) {
if ( (rc = subsystem_exist (ctx, "ibnetbw")) == 0)
matcher.add_subsystem ("ibnetbw", "*");
} else if (iequals (matcher_type, string ("PFS1BA"))) {
} else if (boost::iequals (matcher_type, string ("PFS1BA"))) {
if ( (rc = subsystem_exist (ctx, "pfs1bw")) == 0)
matcher.add_subsystem ("pfs1bw", "*");
} else if (iequals (matcher_type, string ("PA"))) {
} else if (boost::iequals (matcher_type, string ("PA"))) {
if ( (rc = subsystem_exist (ctx, "power")) == 0)
matcher.add_subsystem ("power", "*");
} else if (iequals (matcher_type, string ("C+PFS1BA"))) {
} else if (boost::iequals (matcher_type, string ("C+PFS1BA"))) {
if ( (rc = subsystem_exist (ctx, "containment")) == 0)
matcher.add_subsystem ("containment", "contains");
if ( !rc && (rc = subsystem_exist (ctx, "pfs1bw")) == 0)
matcher.add_subsystem ("pfs1bw", "*");
} else if (iequals (matcher_type, string ("C+IBA"))) {
} else if (boost::iequals (matcher_type, string ("C+IBA"))) {
if ( (rc = subsystem_exist (ctx, "containment")) == 0)
matcher.add_subsystem ("containment", "contains");
if ( !rc && (rc = subsystem_exist (ctx, "ibnet")) == 0)
matcher.add_subsystem ("ibnet", "connected_up");
} else if (iequals (matcher_type, string ("C+PA"))) {
} else if (boost::iequals (matcher_type, string ("C+PA"))) {
if ( (rc = subsystem_exist (ctx, "containment")) == 0)
matcher.add_subsystem ("containment", "*");
if ( !rc && (rc = subsystem_exist (ctx, "power")) == 0)
matcher.add_subsystem ("power", "draws_from");
} else if (iequals (matcher_type, string ("IB+IBBA"))) {
} else if (boost::iequals (matcher_type, string ("IB+IBBA"))) {
if ( (rc = subsystem_exist (ctx, "ibnet")) == 0)
matcher.add_subsystem ("ibnet", "connected_down");
if ( !rc && (rc = subsystem_exist (ctx, "ibnetbw")) == 0)
matcher.add_subsystem ("ibnetbw", "*");
} else if (iequals (matcher_type, string ("C+P+IBA"))) {
} else if (boost::iequals (matcher_type, string ("C+P+IBA"))) {
if ( (rc = subsystem_exist (ctx, "containment")) == 0)
matcher.add_subsystem ("containment", "contains");
if ( (rc = subsystem_exist (ctx, "power")) == 0)
matcher.add_subsystem ("power", "draws_from");
if ( !rc && (rc = subsystem_exist (ctx, "ibnet")) == 0)
matcher.add_subsystem ("ibnet", "connected_up");
} else if (iequals (matcher_type, string ("V+PFS1BA"))) {
} else if (boost::iequals (matcher_type, string ("V+PFS1BA"))) {
if ( (rc = subsystem_exist (ctx, "virtual1")) == 0)
matcher.add_subsystem ("virtual1", "*");
if ( !rc && (rc = subsystem_exist (ctx, "pfs1bw")) == 0)
matcher.add_subsystem ("pfs1bw", "*");
} else if (iequals (matcher_type, string ("VA"))) {
} else if (boost::iequals (matcher_type, string ("VA"))) {
if ( (rc = subsystem_exist (ctx, "virtual1")) == 0)
matcher.add_subsystem ("virtual1", "*");
} else if (iequals (matcher_type, string ("ALL"))) {
} else if (boost::iequals (matcher_type, string ("ALL"))) {
if ( (rc = subsystem_exist (ctx, "containment")) == 0)
matcher.add_subsystem ("containment", "*");
if ( !rc && (rc = subsystem_exist (ctx, "ibnet")) == 0)
Expand Down Expand Up @@ -323,13 +322,13 @@ static void flatten (f_resource_graph_t &fg, map<vtx_t, string> &paths,

static void write_to_graphml (f_resource_graph_t &fg, fstream &o)
{
dynamic_properties dp;
boost::dynamic_properties dp;
map<edg_t, string> esubsystems;
map<vtx_t, string> subsystems, properties, paths;
associative_property_map<map<vtx_t, string>> subsystems_map (subsystems);
associative_property_map<map<edg_t, string>> esubsystems_map (esubsystems);
associative_property_map<map<vtx_t, string>> props_map (properties);
associative_property_map<map<vtx_t, string>> paths_map (paths);
boost::associative_property_map<map<vtx_t, string>> subsystems_map (subsystems);
boost::associative_property_map<map<edg_t, string>> esubsystems_map (esubsystems);
boost::associative_property_map<map<vtx_t, string>> props_map (properties);
boost::associative_property_map<map<vtx_t, string>> paths_map (paths);

flatten (fg, paths, subsystems, esubsystems);

Expand Down

0 comments on commit 05a2802

Please sign in to comment.