1
0
mirror of https://github.com/ohwgiles/laminar.git synced 2024-10-27 20:34:20 +00:00

boost compatibility

This commit is contained in:
Oliver Giles 2015-11-19 21:43:08 +01:00
parent 56a8301e85
commit d44d5ba0e6
3 changed files with 22 additions and 22 deletions

View File

@ -104,15 +104,14 @@ bool Laminar::setParam(std::string job, int buildNum, std::string param, std::st
void Laminar::populateArtifacts(Json &j, std::string job, int num) const { void Laminar::populateArtifacts(Json &j, std::string job, int num) const {
fs::path dir(fs::path(homeDir)/"archive"/job/std::to_string(num)); fs::path dir(fs::path(homeDir)/"archive"/job/std::to_string(num));
if(fs::is_directory(dir)) { if(fs::is_directory(dir)) {
fs::recursive_directory_iterator rdt(dir);
int prefixLen = (fs::path(homeDir)/"archive").string().length(); int prefixLen = (fs::path(homeDir)/"archive").string().length();
int scopeLen = dir.string().length(); int scopeLen = dir.string().length();
for(fs::directory_entry e : rdt) { for(fs::recursive_directory_iterator it(dir); it != fs::recursive_directory_iterator(); ++it) {
if(!fs::is_regular_file(e)) if(!fs::is_regular_file(*it))
continue; continue;
j.StartObject(); j.StartObject();
j.set("url", archiveUrl + e.path().string().substr(prefixLen)); j.set("url", archiveUrl + it->path().string().substr(prefixLen));
j.set("filename", e.path().string().substr(scopeLen+1)); j.set("filename", it->path().string().substr(scopeLen+1));
j.EndObject(); j.EndObject();
} }
} }
@ -330,19 +329,18 @@ bool Laminar::loadConfiguration() {
fs::path nodeCfg = fs::path(homeDir)/"cfg"/"nodes"; fs::path nodeCfg = fs::path(homeDir)/"cfg"/"nodes";
if(fs::is_directory(nodeCfg)) { if(fs::is_directory(nodeCfg)) {
fs::directory_iterator dit(nodeCfg); for(fs::directory_iterator it(nodeCfg); it != fs::directory_iterator(); ++it) {
for(fs::directory_entry& it : dit) { if(!fs::is_directory(it->status()))
if(!fs::is_directory(it.status()))
continue; continue;
fs::directory_entry config(it.path()/"config"); fs::directory_entry config(it->path()/"config");
if(!fs::is_regular_file(config.status())) if(!fs::is_regular_file(config.status()))
continue; continue;
StringMap conf = parseConfFile(config.path().string().c_str()); StringMap conf = parseConfFile(config.path().string().c_str());
Node node; Node node;
node.name = it.path().filename().string(); node.name = it->path().filename().string();
node.numExecutors = conf.get<int>("EXECUTORS", 6); node.numExecutors = conf.get<int>("EXECUTORS", 6);
std::string tags = conf.get<std::string>("TAGS"); std::string tags = conf.get<std::string>("TAGS");
@ -371,12 +369,11 @@ bool Laminar::loadConfiguration() {
fs::path jobsDir = fs::path(homeDir)/"cfg"/"jobs"; fs::path jobsDir = fs::path(homeDir)/"cfg"/"jobs";
if(fs::is_directory(jobsDir)) { if(fs::is_directory(jobsDir)) {
fs::directory_iterator dit(jobsDir); for(fs::directory_iterator it(jobsDir); it != fs::directory_iterator(); ++it) {
for(fs::directory_entry& it : dit) { if(!fs::is_directory(it->status()))
if(!fs::is_directory(it.status()))
continue; continue;
fs::directory_entry config(it.path()/"config"); fs::directory_entry config(it->path()/"config");
if(!fs::is_regular_file(config.status())) if(!fs::is_regular_file(config.status()))
continue; continue;
@ -389,7 +386,7 @@ bool Laminar::loadConfiguration() {
std::copy(std::istream_iterator<std::string>(iss), std::copy(std::istream_iterator<std::string>(iss),
std::istream_iterator<std::string>(), std::istream_iterator<std::string>(),
std::inserter(tagList, tagList.begin())); std::inserter(tagList, tagList.begin()));
jobTags[it.path().filename().string()] = tagList; jobTags[it->path().filename().string()] = tagList;
} }
} }

View File

@ -67,7 +67,7 @@ private:
void populateArtifacts(Json& out, std::string job, int num) const; void populateArtifacts(Json& out, std::string job, int num) const;
Run* activeRun(std::string name, int num) { Run* activeRun(std::string name, int num) {
auto it = activeJobs.get<1>().find(std::make_tuple(name, num)); auto it = activeJobs.get<1>().find(boost::make_tuple(name, num));
return it == activeJobs.get<1>().end() ? nullptr : it->get(); return it == activeJobs.get<1>().end() ? nullptr : it->get();
} }

View File

@ -107,17 +107,15 @@ private:
namespace bmi = boost::multi_index; namespace bmi = boost::multi_index;
struct _same { struct _run_same {
typedef const Run* result_type; typedef const Run* result_type;
const Run* operator()(const std::shared_ptr<Run>& run) const { const Run* operator()(const std::shared_ptr<Run>& run) const {
return run.get(); return run.get();
} }
}; };
struct RunSet: public boost::multi_index_container< // A single Run can be fetched by...
std::shared_ptr<Run>, struct _run_index : bmi::indexed_by<
// A single Run can be fetched by...
bmi::indexed_by<
// their current running pid // their current running pid
bmi::hashed_unique<bmi::member<Run, pid_t, &Run::pid>>, bmi::hashed_unique<bmi::member<Run, pid_t, &Run::pid>>,
bmi::hashed_unique<bmi::composite_key< bmi::hashed_unique<bmi::composite_key<
@ -127,12 +125,17 @@ struct RunSet: public boost::multi_index_container<
bmi::member<Run, int, &Run::build> bmi::member<Run, int, &Run::build>
>>, >>,
// or a pointer to a Run object. // or a pointer to a Run object.
bmi::hashed_unique<_same>, bmi::hashed_unique<_run_same>,
// A group of Runs can be fetched by the time they started // A group of Runs can be fetched by the time they started
bmi::ordered_non_unique<bmi::member<Run, time_t, &Run::startedAt>>, bmi::ordered_non_unique<bmi::member<Run, time_t, &Run::startedAt>>,
// or by their job name // or by their job name
bmi::ordered_non_unique<bmi::member<Run, std::string, &Run::name>> bmi::ordered_non_unique<bmi::member<Run, std::string, &Run::name>>
> >
{};
struct RunSet: public boost::multi_index_container<
std::shared_ptr<Run>,
_run_index
> { > {
// TODO: getters for each index // TODO: getters for each index
}; };