Files
spark/src/lib/quickbus/core/Quickbus.h
T

66 lines
1.6 KiB
C++

#pragma once
#include <memory>
#include "lib/quickbus/pubsub/TableFilter.h"
#include "lib/quickbus/core/Topic.h"
#include "lib/quickbus/pubsub/TableEvent.h"
#include "lib/quickbus/message_model/Update.h"
#include "lib/utils/bts_export.h"
// fwds
namespace bts {
namespace config {class QuickbusNodeCfg;}
namespace qbus {class TablePublisher; class PublisherImp;}
namespace qbus {class TableSubscriber; class SubscriberImp;}
namespace qbus {class Change;}
namespace qbus {class LocalNode;}
namespace qbus {class Router;}
}
// end fwds
namespace bts {
namespace qbus {
// This class is not intended for direct use, use Subscriber,
// Publisher, RPCClient and RPCServer instead.
// The point of this class is to provide a facade for the core
// components of the Quickbus system.
class BTS_EXPORT Quickbus
{
public:
enum class ThreadOptions {
own_thread,
outside_thread,
deferred_start
};
Quickbus(ThreadOptions options = ThreadOptions::own_thread);
Quickbus(config::QuickbusNodeCfg const&cfg, ThreadOptions = ThreadOptions::own_thread);
~Quickbus();
// call this only if ThreadOptions == external_thread and you would
// like to manually control message dispatch. Returns wheter any
// work was done
bool do_work();
// call this at most once and only if ThreadOptions ==
// deferred_start. This method will not return.
void run();
bool on_qb_thread() const;
void post (std::function<void()> const &, uint32_t delay_ms=0);
protected:
friend class LocalNode;
Router& router() const;
private:
struct PImpl;
std::unique_ptr<PImpl> me;
void init();
};
}}