#include "wait_station.hpp" #include #include using namespace waitstation; static void record_fields(const Record &r) { std::cout << ' ' << r.id << ' ' << r.cell << ' ' << r.relation << ' ' << r.target << ' ' << r.domain << ' ' << r.deadline << ' ' << r.phase << ' ' << r.result; } int main() { Station stations[2]; std::string operation; Integer slot = 0; while (std::cin >> operation >> slot) { Station &station = stations[static_cast(slot)]; Integer a = 0, b = 0, c = 0, d = 0, e = 0, f = 0; Code code = OK; if (operation == "N") { std::cin >> a >> b >> c; code = station.reset(a, b, c); } else if (operation == "P") { std::cin >> a >> b; code = station.publish(a, b); } else if (operation == "B") { std::cin >> a; std::vector items; for (Integer i = 0; i < a; ++i) { std::cin >> b >> c; items.push_back({b, c}); } code = station.publish_many(items); } else if (operation == "W") { std::cin >> a >> b >> c >> d >> e >> f; code = station.watch(a, b, c, d, e, f); } else if (operation == "A") { std::cin >> a; code = station.advance(a); } else if (operation == "J") { std::cin >> a; code = station.adjust(a); } else if (operation == "U") { std::cin >> a >> b >> c; code = station.rearm(a, b, c); } else if (operation == "C") { std::cin >> a; code = station.cancel(a); } else if (operation == "E") { std::cin >> a; code = station.erase(a); } else if (operation == "I") { Record record; record.id = record.cell = record.relation = record.target = -777; record.domain = record.deadline = record.phase = record.result = -777; std::cin >> a; code = station.inspect(a, record); std::cout << operation << ' ' << slot << ' ' << code; record_fields(record); std::cout << '\n'; continue; } else if (operation == "R" || operation == "T" || operation == "D") { std::cin >> a; Integer value = -777; if (operation == "R") { code = station.read(a, value); } else if (operation == "T") { code = station.time(a, value); } else { code = station.remaining(a, value); } std::cout << operation << ' ' << slot << ' ' << code; std::cout << ' ' << value; std::cout << '\n'; continue; } else if (operation == "S") { Counters counts = station.counters(); std::cout << operation << ' ' << slot << ' ' << counts.capacity << ' ' << counts.used << ' ' << counts.waiting << ' ' << counts.satisfied << ' ' << counts.expired << ' ' << counts.cancelled << '\n'; continue; } else if (operation == "L" || operation == "G") { std::cin >> a >> b; Listing listing = operation == "L" ? station.list(a, b) : station.drain(a, b); std::cout << operation << ' ' << slot << ' ' << listing.code << ' ' << listing.records.size(); for (const Record &record : listing.records) { record_fields(record); } std::cout << '\n'; continue; } std::cout << operation << ' ' << slot << ' ' << code << '\n'; } return 0; }