26#ifndef MYSQL_HARNESS_DIMANAGER_INCLUDED
27#define MYSQL_HARNESS_DIMANAGER_INCLUDED
29#include "harness_export.h"
362class RandomGeneratorInterface;
388 static DIM &instance();
404 factory_LoggingRegistry_ = factory;
405 deleter_LoggingRegistry_ = deleter;
414 factory_RandomGenerator_ = factory;
415 deleter_RandomGenerator_ = deleter;
423 factory_Config_ = factory;
424 deleter_Config_ = deleter;
432 factory_DynamicState_ = factory;
433 deleter_DynamicState_ = deleter;
442 return get_external_generic(instance_LoggingRegistry_,
443 factory_LoggingRegistry_,
444 deleter_LoggingRegistry_);
449 return get_generic(factory_RandomGenerator_, deleter_RandomGenerator_);
454 return get_external_generic(instance_Config_, factory_Config_,
461 return get_external_generic(instance_DynamicState_, factory_DynamicState_,
462 deleter_DynamicState_);
472 factory_LoggingRegistry_;
479 factory_RandomGenerator_;
498 template <
typename T>
500 const std::function<
void(T *)> &deleter) {
501 static UniquePtr<T> obj = new_generic(factory, deleter);
507 template <
typename T>
509 const std::function<
void(T *)> &deleter) {
517 template <
typename T,
typename A1>
519 const std::function<
void(T *)> &deleter,
528 template <
typename T,
typename A1,
typename A2>
530 const std::function<
void(T *)> &deleter,
531 const A1 &a1,
const A2 &a2) {
540 template <
typename T>
542 const std::function<T *()> &factory,
543 const std::function<
void(T *)> &deleter) {
545 std::shared_ptr<void> exit_trigger(
nullptr, [&](
void *) { mtx_.unlock(); });
547 if (!
object)
object = new_generic(factory, deleter);
552 template <
typename T>
555 std::shared_ptr<void> exit_trigger(
nullptr, [&](
void *) { mtx_.unlock(); });
560 mutable std::recursive_mutex
mtx_;
mysql_harness::RandomGeneratorInterface & get_RandomGenerator() const
Definition: dim.h:448
T & get_external_generic(UniquePtr< T > &object, const std::function< T *()> &factory, const std::function< void(T *)> &deleter)
Definition: dim.h:541
static T & get_generic(const std::function< T *(void)> &factory, const std::function< void(T *)> &deleter)
Definition: dim.h:499
void set_Config(const std::function< mysql_harness::LoaderConfig *(void)> &factory, const std::function< void(mysql_harness::LoaderConfig *)> &deleter)
Definition: dim.h:420
void set_LoggingRegistry(const std::function< mysql_harness::logging::Registry *(void)> &factory, const std::function< void(mysql_harness::logging::Registry *)> &deleter)
Definition: dim.h:401
std::function< void(mysql_harness::DynamicState *)> deleter_DynamicState_
Definition: dim.h:490
std::function< void(mysql_harness::RandomGeneratorInterface *)> deleter_RandomGenerator_
Definition: dim.h:481
static UniquePtr< T > new_generic(const std::function< T *(void)> &factory, const std::function< void(T *)> &deleter)
Definition: dim.h:508
UniquePtr< mysql_harness::logging::Registry > instance_LoggingRegistry_
Definition: dim.h:475
mysql_harness::DynamicState & get_DynamicState()
Definition: dim.h:460
void set_RandomGenerator(const std::function< mysql_harness::RandomGeneratorInterface *(void)> &factory, const std::function< void(mysql_harness::RandomGeneratorInterface *)> &deleter)
Definition: dim.h:409
std::function< void(mysql_harness::logging::Registry *)> deleter_LoggingRegistry_
Definition: dim.h:474
mysql_harness::LoaderConfig & get_Config()
Definition: dim.h:453
std::recursive_mutex mtx_
Definition: dim.h:560
void set_DynamicState(const std::function< mysql_harness::DynamicState *(void)> &factory, const std::function< void(mysql_harness::DynamicState *)> &deleter)
Definition: dim.h:429
static UniquePtr< T > new_generic1(const std::function< T *(A1)> &factory, const std::function< void(T *)> &deleter, const A1 &a1)
Definition: dim.h:518
static UniquePtr< T > new_generic2(const std::function< T *(A1, A2)> &factory, const std::function< void(T *)> &deleter, const A1 &a1, const A2 &a2)
Definition: dim.h:529
mysql_harness::logging::Registry & get_LoggingRegistry()
Definition: dim.h:441
std::function< void(mysql_harness::LoaderConfig *)> deleter_Config_
Definition: dim.h:485
void reset_generic(UniquePtr< T > &object)
Definition: dim.h:553
DIM & operator=(const DIM &)=delete
bool is_DynamicState()
Definition: dim.h:459
void reset_Config()
Definition: dim.h:419
UniquePtr< mysql_harness::DynamicState > instance_DynamicState_
Definition: dim.h:491
UniquePtr< mysql_harness::LoaderConfig > instance_Config_
Definition: dim.h:486
void reset_LoggingRegistry()
Definition: dim.h:400
void reset_DynamicState()
Definition: dim.h:428
DynamicState represents a MySQLRouter dynamic state object.
Definition: dynamic_state.h:64
Configuration file handler for the loader.
Definition: loader_config.h:46
Definition: random_generator.h:36
Definition: unique_ptr.h:75
Definition: registry.h:47
const char * p
Definition: ctype-mb.cc:1237