4 #include "include/types.h"
5 #include "include/paxos_protocol.h"
6 #include "include/rpc/marshall.h"
11 std::map<string, std::function<void(unmarshall &)>> handlers;
19 struct label : public string { label(const char * s) : string(s) {} };
20 #define LABEL(_x_) inline operator log::label () const { return _x_; }
22 // XXX should be an atomic operation
24 void append(const T & t) {
25 std::ofstream(name, std::ios::app) << marshall{label(t), t};
29 void handler(std::function<void(T)> h) {
30 handlers[label(T())] = [h, this] (unmarshall & from) {
31 auto entry = from.get<T>();