/// /// Copyright 2015-2019 Oliver Giles /// /// This file is part of Laminar /// /// Laminar is free software: you can redistribute it and/or modify /// it under the terms of the GNU General Public License as published by /// the Free Software Foundation, either version 3 of the License, or /// (at your option) any later version. /// /// Laminar is distributed in the hope that it will be useful, /// but WITHOUT ANY WARRANTY; without even the implied warranty of /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /// GNU General Public License for more details. /// /// You should have received a copy of the GNU General Public License /// along with Laminar. If not, see /// #ifndef LAMINAR_MONITORSCOPE_H_ #define LAMINAR_MONITORSCOPE_H_ #include // Simple struct to define which information a frontend client is interested // in, both in initial request phase and real-time updates. It corresponds // loosely to frontend URLs struct MonitorScope { enum Type { HOME, // home page: recent builds and statistics ALL, // browse jobs JOB, // a specific job page RUN, // a specific run page }; MonitorScope(Type type = HOME, std::string job = std::string(), uint num = 0) : type(type), job(job), num(num), page(0), field("number"), order_desc(true) {} // whether this scope wants status information about the given job or run bool wantsStatus(std::string ajob, uint anum = 0) const { if(type == HOME || type == ALL) return true; if(type == JOB) return ajob == job; if(type == RUN) return ajob == job && anum == num; return false; } Type type; std::string job; uint num = 0; // sorting uint page = 0; std::string field; bool order_desc; }; #endif // LAMINAR_MONITORSCOPE_H_