/usr/include/xbt/signal.hpp is in libsimgrid-dev 3.18+dfsg-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | /* Copyright (c) 2014-2017. The SimGrid Team. All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
#ifndef SIMGRID_XBT_SIGNAL_HPP
#define SIMGRID_XBT_SIGNAL_HPP
#include <functional>
#include <utility>
#include <vector>
namespace simgrid {
namespace xbt {
template<class S> class signal;
/** A signal/slot mechanism
*
* S is expected to be the function signature of the signal.
* I'm not sure we need a return value (it is currently ignored).
* If we don't we might use `signal<P1, P2, ...>` instead.
*/
template<class R, class... P>
class signal<R(P...)> {
private:
typedef std::function<R(P...)> callback_type;
std::vector<callback_type> handlers_;
public:
template<class U>
void connect(U slot)
{
handlers_.push_back(std::move(slot));
}
R operator()(P... args) const
{
for (auto const& handler : handlers_)
handler(args...);
}
void disconnect_all_slots()
{
handlers_.clear();
}
};
}
}
#endif
|