ui: Compile boost:signals2 only once

This commit is contained in:
MarcoFalke
2018-07-11 08:00:15 -04:00
parent fad42e8c4a
commit fa5ce27385
5 changed files with 95 additions and 34 deletions

View File

@@ -6,15 +6,18 @@
#ifndef BITCOIN_UI_INTERFACE_H
#define BITCOIN_UI_INTERFACE_H
#include <functional>
#include <memory>
#include <stdint.h>
#include <string>
#include <boost/signals2/last_value.hpp>
#include <boost/signals2/signal.hpp>
class CWallet;
class CBlockIndex;
namespace boost {
namespace signals2 {
class connection;
}
} // namespace boost
/** General change type (added, updated, removed). */
enum ChangeType
@@ -72,43 +75,49 @@ public:
MSG_ERROR = (ICON_ERROR | BTN_OK | MODAL)
};
#define ADD_SIGNALS_DECL_WRAPPER(signal_name, rtype, args...) \
rtype signal_name(args); \
using signal_name##Sig = rtype(args); \
boost::signals2::connection signal_name##_connect(std::function<signal_name##Sig> fn); \
void signal_name##_disconnect(std::function<signal_name##Sig> fn);
/** Show message box. */
boost::signals2::signal<bool (const std::string& message, const std::string& caption, unsigned int style), boost::signals2::last_value<bool> > ThreadSafeMessageBox;
ADD_SIGNALS_DECL_WRAPPER(ThreadSafeMessageBox, bool, const std::string& message, const std::string& caption, unsigned int style);
/** If possible, ask the user a question. If not, falls back to ThreadSafeMessageBox(noninteractive_message, caption, style) and returns false. */
boost::signals2::signal<bool (const std::string& message, const std::string& noninteractive_message, const std::string& caption, unsigned int style), boost::signals2::last_value<bool> > ThreadSafeQuestion;
ADD_SIGNALS_DECL_WRAPPER(ThreadSafeQuestion, bool, const std::string& message, const std::string& noninteractive_message, const std::string& caption, unsigned int style);
/** Progress message during initialization. */
boost::signals2::signal<void (const std::string &message)> InitMessage;
ADD_SIGNALS_DECL_WRAPPER(InitMessage, void, const std::string& message);
/** Number of network connections changed. */
boost::signals2::signal<void (int newNumConnections)> NotifyNumConnectionsChanged;
ADD_SIGNALS_DECL_WRAPPER(NotifyNumConnectionsChanged, void, int newNumConnections);
/** Network activity state changed. */
boost::signals2::signal<void (bool networkActive)> NotifyNetworkActiveChanged;
ADD_SIGNALS_DECL_WRAPPER(NotifyNetworkActiveChanged, void, bool networkActive);
/**
* Status bar alerts changed.
*/
boost::signals2::signal<void ()> NotifyAlertChanged;
ADD_SIGNALS_DECL_WRAPPER(NotifyAlertChanged, void, );
/** A wallet has been loaded. */
boost::signals2::signal<void (std::shared_ptr<CWallet> wallet)> LoadWallet;
ADD_SIGNALS_DECL_WRAPPER(LoadWallet, void, std::shared_ptr<CWallet> wallet);
/**
* Show progress e.g. for verifychain.
* resume_possible indicates shutting down now will result in the current progress action resuming upon restart.
*/
boost::signals2::signal<void (const std::string &title, int nProgress, bool resume_possible)> ShowProgress;
ADD_SIGNALS_DECL_WRAPPER(ShowProgress, void, const std::string& title, int nProgress, bool resume_possible);
/** New block has been accepted */
boost::signals2::signal<void (bool, const CBlockIndex *)> NotifyBlockTip;
ADD_SIGNALS_DECL_WRAPPER(NotifyBlockTip, void, bool, const CBlockIndex*);
/** Best header has changed */
boost::signals2::signal<void (bool, const CBlockIndex *)> NotifyHeaderTip;
ADD_SIGNALS_DECL_WRAPPER(NotifyHeaderTip, void, bool, const CBlockIndex*);
/** Banlist did change. */
boost::signals2::signal<void (void)> BannedListChanged;
ADD_SIGNALS_DECL_WRAPPER(BannedListChanged, void, void);
};
/** Show warning message **/