17 #ifndef COM_BORA_SOFTWARE__BALAU_APPLICATION__APPLICATION_CONFIGURATION 18 #define COM_BORA_SOFTWARE__BALAU_APPLICATION__APPLICATION_CONFIGURATION 40 protected:
template <
typename BaseT,
typename DeleterT = std::default_delete<BaseT>>
42 return Bind<BaseT, DeleterT>(*this).bind(name);
46 extraConfiguration.push_back(&conf);
58 postConstructionCalls.push_back(call);
75 preDestructionCalls.push_back(call);
92 protected:
template <
typename T>
void registerStaticSingleton(std::shared_ptr<T> * ptrPtr, std::string_view name = std::string_view())
const {
93 staticSingletonPostConstructionCalls.emplace_back(
new StaticSingletonRegistration(ptrPtr, name));
94 preDestructionCalls.push_back([ptrPtr] () { ptrPtr->reset(); });
99 private: std::vector<std::shared_ptr<Impl::BindingBuilderBase>> build()
const override {
101 return std::move(builders);
104 public: std::vector<const InjectorConfiguration *> getExtraConfiguration()
const override {
105 return extraConfiguration;
108 public: std::list<std::function<void (const Injector& )>> getPostConstructionCalls()
const override {
109 return postConstructionCalls;
112 public: std::list<std::function<void ()>> getPreDestructionCalls()
const override {
113 return preDestructionCalls;
116 public: std::list<std::unique_ptr<StaticSingletonRegistrationBase>> getStaticSingletonPostConstructionCalls()
const override {
117 return std::move(staticSingletonPostConstructionCalls);
120 private:
template <
typename T,
typename DeleterT>
struct Bind {
122 std::negation<
typename std::is_pointer<T>::type>::value
123 ,
"Raw pointers are not permitted in bindings. Use Unique or Shared bindings instead." 131 parent.builders.emplace_back(
139 private:
template <
typename T,
typename DeleterT>
struct Bind<const T, DeleterT> {
141 std::negation<
typename std::is_pointer<T>::type>::value
142 ,
"Raw pointers are not permitted in bindings. Use Unique or Shared bindings instead." 150 parent.builders.emplace_back(
158 private:
mutable std::vector<std::shared_ptr<Impl::BindingBuilderBase>> builders;
159 private:
mutable std::vector<const InjectorConfiguration *> extraConfiguration;
160 private:
mutable std::list<std::function<void (const Injector& )>> postConstructionCalls;
161 private:
mutable std::list<std::function<void ()>> preDestructionCalls;
162 private:
mutable std::list<std::unique_ptr<StaticSingletonRegistrationBase>> staticSingletonPostConstructionCalls;
167 #endif // COM_BORA_SOFTWARE__BALAU_APPLICATION__APPLICATION_CONFIGURATION void registerPreDestructionCall(const std::function< void()> &call) const
Register with the injector a callback that will be called in the injector's destructor, before the bindings are deleted.
Definition: ApplicationConfiguration.hpp:74
The abstract base class for all Injector configuration classes.
void registerStaticSingleton(std::shared_ptr< T > *ptrPtr, std::string_view name=std::string_view()) const
Register a static singleton pointer that the injector will set up post-construction and invalidate pr...
Definition: ApplicationConfiguration.hpp:92
Application configurations specify application injector bindings.
Definition: ApplicationConfiguration.hpp:34
An injector binding candidate created via the injector configuration.
Definition: BindingBuilder.hpp:44
The root Balau namespace.
Definition: ApplicationConfiguration.hpp:23
BindingBuilder< BaseT, DeleterT > & bind(std::string_view name=std::string_view()) const
Create a binding specification for the specified named or unnamed interface.
Definition: ApplicationConfiguration.hpp:41
The main dependency injector class.
Definition: Injector.hpp:41
Injector configurations specify injector bindings.
Definition: InjectorConfiguration.hpp:32
An injector binding candidate created via the injector configuration.
void registerPostConstructionCall(const std::function< void(const Injector &)> &call) const
Register with the injector a callback that will be called by the injector at the end of construction...
Definition: ApplicationConfiguration.hpp:57