Go to the documentation of this file.
3 #include <boost/preprocessor/seq/for_each.hpp>
8 struct db_accessor_factory;
13 #define DECLARE_SERVICE_FUNCT_NAME(service) BOOST_PP_CAT(service, _service)
15 #define DECLARE_SERVICE_INTERFACE_NAME(service) BOOST_PP_CAT(DECLARE_SERVICE_FUNCT_NAME(service), _i)
17 #define DECLARE_DBS_IMPL_NAME(service) BOOST_PP_CAT(dbs_, service)
19 #define DECLARE_SERVICE_INTERFACE(_1, _2, service) \
20 struct DECLARE_SERVICE_INTERFACE_NAME(service); \
21 struct account_service_i; \
22 struct witness_service_i;
24 #define DECLARE_FACTORY_INTERFACE_METHOD(_1, _2, service) \
25 virtual DECLARE_SERVICE_INTERFACE_NAME(service) \
26 & BOOST_PP_CAT(DECLARE_SERVICE_FUNCT_NAME(service), BOOST_PP_EMPTY())() const \
29 #define DECLARE_FACTORY_METHOD(_1, _2, service) \
30 virtual DECLARE_SERVICE_INTERFACE_NAME(service) \
31 & BOOST_PP_CAT(DECLARE_SERVICE_FUNCT_NAME(service), BOOST_PP_EMPTY())() const;
33 #define DATA_SERVICE_FACTORY_DECLARE(SERVICES) \
38 class dbservice_dbs_factory; \
40 BOOST_PP_SEQ_FOR_EACH(DECLARE_SERVICE_INTERFACE, _, SERVICES) \
42 struct data_service_factory_i \
44 BOOST_PP_SEQ_FOR_EACH(DECLARE_FACTORY_INTERFACE_METHOD, _, SERVICES) \
45 virtual account_service_i& account_service() const = 0; \
46 virtual witness_service_i& witness_service() const = 0; \
48 class data_service_factory : public data_service_factory_i \
51 explicit data_service_factory(scorum::chain::database& db); \
53 virtual ~data_service_factory(); \
55 BOOST_PP_SEQ_FOR_EACH(DECLARE_FACTORY_METHOD, _, SERVICES) \
56 virtual account_service_i& account_service() const override; \
57 virtual witness_service_i& witness_service() const override; \
60 scorum::chain::dbservice_dbs_factory& factory; \
61 scorum::chain::dba::db_accessor_factory& dba_factory; \
66 #define DECLARE_FACTORY_METHOD_IMPL(_1, _2, service) \
67 DECLARE_SERVICE_INTERFACE_NAME(service) \
68 &data_service_factory::BOOST_PP_CAT(DECLARE_SERVICE_FUNCT_NAME(service), BOOST_PP_EMPTY())() const \
70 return factory.obtain_service<DECLARE_DBS_IMPL_NAME(service)>(); \
73 #define DATA_SERVICE_FACTORY_IMPL(SERVICES) \
76 data_service_factory::data_service_factory(scorum::chain::database& db) \
82 data_service_factory::~data_service_factory() \
85 BOOST_PP_SEQ_FOR_EACH(DECLARE_FACTORY_METHOD_IMPL, _, SERVICES) \
86 account_service_i& data_service_factory::account_service() const \
88 return factory.obtain_service_explicit<dbs_account>(dynamic_global_property_service(), witness_service()); \
90 witness_service_i& data_service_factory::witness_service() const \
92 return factory.obtain_service_explicit<dbs_witness>(witness_schedule_service(), \
93 dynamic_global_property_service(), \
94 dba_factory.get_dba<chain_property_object>()); \