X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;ds=sidebyside;f=test%2Flib%2FServer.hpp;h=26acdc4468b2f89ff0b4524e28ea3251a273a923;hb=refs%2Fpull%2F101%2Fhead;hp=bfbab812259a44ec14118fa221d577009368874f;hpb=77fcb72bd529695c88e931403dac25c130190d0c;p=awesomized%2Flibmemcached diff --git a/test/lib/Server.hpp b/test/lib/Server.hpp index bfbab812..26acdc44 100644 --- a/test/lib/Server.hpp +++ b/test/lib/Server.hpp @@ -1,3 +1,18 @@ +/* + +--------------------------------------------------------------------+ + | libmemcached - C/C++ Client Library for memcached | + +--------------------------------------------------------------------+ + | Redistribution and use in source and binary forms, with or without | + | modification, are permitted under the terms of the BSD license. | + | You should have received a copy of the license in a bundled file | + | named LICENSE; in case you did not receive a copy you can review | + | the terms online at: https://opensource.org/licenses/BSD-3-Clause | + +--------------------------------------------------------------------+ + | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ | + | Copyright (c) 2020 Michael Wallner | + +--------------------------------------------------------------------+ +*/ + #pragma once #include "common.hpp" @@ -7,7 +22,6 @@ class Server { public: - friend class Cluster; using arg_func_t = function; @@ -15,30 +29,24 @@ public: using arg_pair_t = pair; using argv_t = vector>; - explicit - Server(string binary_ = "false", argv_t args_ = {}); + explicit Server(string binary_ = "false", argv_t args_ = {}); ~Server(); Server(const Server &s); - Server &operator = (const Server &s); + Server &operator=(const Server &s); - Server(Server &&s) { + Server(Server &&s) noexcept { *this = move(s); }; - Server &operator = (Server &&s) { + Server &operator=(Server &&s) noexcept { binary = exchange(s.binary, "false"); args = exchange(s.args, {}); pid = exchange(s.pid, 0); pipe = exchange(s.pipe, -1); status = exchange(s.status, 0); signalled = exchange(s.signalled, {}); -#if __clang__ && __clang_major__ <= 7 - socket_or_port = s.socket_or_port; - s.socket_or_port = 11211; -#else - socket_or_port = exchange(s.socket_or_port, 11211); -#endif + socket_or_port = exchange(s.socket_or_port, {}); output = exchange(s.output, {}); return *this; }; @@ -54,23 +62,20 @@ public: int pipe; ChildProc(pid_t pid_, int pipe_) : pid{pid_} - , pipe{pipe_} - { - } + , pipe{pipe_} {} }; optional start(); bool stop(); bool signal(int signo = SIGTERM); bool check(); - bool isListening(); + bool isListening() const; bool ensureListening(); bool wait(int flags = 0); bool tryWait(); string &drain(); - private: string binary; argv_t args; @@ -82,12 +87,11 @@ private: socket_or_port_t socket_or_port = 11211; string output; - [[nodiscard]] - vector createArgv(); + [[nodiscard]] vector createArgv(); optional handleArg(vector &arr, const string &arg, const arg_func_t &next_arg); }; -inline ostream &operator << (ostream &out, const socket_or_port_t sop) { +inline ostream &operator<<(ostream &out, const socket_or_port_t &sop) { if (holds_alternative(sop)) { out << get(sop); } else { @@ -96,7 +100,8 @@ inline ostream &operator << (ostream &out, const socket_or_port_t sop) { return out; } -inline ostream &operator << (ostream &out, const Server &server) { - out << "Server{binary=" << server.getBinary() << ",pid=" << server.getPid() << ",conn=" << server.getSocketOrPort() << "}"; +inline ostream &operator<<(ostream &out, const Server &server) { + out << "Server{binary=" << server.getBinary() << ",pid=" << server.getPid() + << ",conn=" << server.getSocketOrPort() << "}"; return out; }