Arcane  v3.15.0.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
DependencyInjection.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2025 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* DependencyInjection.h (C) 2000-2025 */
9/* */
10/* Types et fonctions pour gérer le pattern 'DependencyInjection'. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_UTILS_INTERNAL_DEPENDENCYINJECTION_H
13#define ARCANE_UTILS_INTERNAL_DEPENDENCYINJECTION_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17/*
18 * NOTE: API en cours de définition. Ne pas utiliser.
19 */
20
21#include "arcane/utils/Ref.h"
22#include "arcane/utils/ExternalRef.h"
23#include "arcane/utils/GenericRegisterer.h"
24
26
27//TODO Mettre le lancement des exceptions dans le '.cc'
28#include "arcane/utils/NotImplementedException.h"
29
30#include <tuple>
31#include <typeinfo>
32
33// TODO: Améliorer les messages d'erreurs en cas d'échec de l'injection
34// TODO: Ajouter méthodes pour afficher le type en cas d'erreur (utiliser A_FUNC_INFO)
35// TODO: Ajouter mode verbose
36// TODO: Supporter plusieurs constructeurs et ne pas échouer si le premier
37// ne fonctionne pas
38// TODO: Supporter des instances externes (comme par exemple celles créées en C#).
39
40/*---------------------------------------------------------------------------*/
41/*---------------------------------------------------------------------------*/
42
43namespace Arcane::DependencyInjection
44{
45class Injector;
46}
47
48namespace Arcane::DependencyInjection::impl
49{
50class FactoryInfo;
51class IInstanceFactory;
52template <typename InterfaceType>
53class IConcreteFactory;
54class ConcreteFactoryTypeInfo;
55} // namespace Arcane::DependencyInjection::impl
56
58
59/*---------------------------------------------------------------------------*/
60/*---------------------------------------------------------------------------*/
61
62namespace Arcane::DependencyInjection
63{
64
65/*---------------------------------------------------------------------------*/
66/*---------------------------------------------------------------------------*/
67
68class ARCANE_UTILS_EXPORT IInjectedInstance
69{
70 public:
71 virtual ~IInjectedInstance() = default;
72 virtual bool hasName(const String& str) const = 0;
73 virtual bool hasTypeInfo(const std::type_info& tinfo) const = 0;
74};
75
76/*---------------------------------------------------------------------------*/
77/*---------------------------------------------------------------------------*/
84class ARCANE_UTILS_EXPORT ProviderProperty
85{
86 public:
87
88 ProviderProperty(const char* name)
89 : m_name(name)
90 {}
91
92 public:
93
94 const char* name() const { return m_name; }
95
96 private:
97
98 const char* m_name;
99};
100
101/*---------------------------------------------------------------------------*/
102/*---------------------------------------------------------------------------*/
103
104} // namespace Arcane::DependencyInjection
105
106/*---------------------------------------------------------------------------*/
107/*---------------------------------------------------------------------------*/
108
109namespace Arcane::DependencyInjection::impl
110{
111
112/*---------------------------------------------------------------------------*/
113/*---------------------------------------------------------------------------*/
114
116{
117 private:
118
119 TypeInfo(const TraceInfo& trace_info, const std::type_info& type_info)
120 : m_trace_info(trace_info)
121 , m_type_info(type_info)
122 {}
123
124 public:
125
126 template <typename Type> static TypeInfo create()
127 {
128 return TypeInfo(A_FUNCINFO, typeid(Type));
129 }
130 const TraceInfo& traceInfo() const { return m_trace_info; }
131 const std::type_info& stdTypeInfo() const { return m_type_info; }
132
133 private:
134
135 TraceInfo m_trace_info;
136 const std::type_info& m_type_info;
137};
138
139/*---------------------------------------------------------------------------*/
140/*---------------------------------------------------------------------------*/
148class ARCANE_UTILS_EXPORT ConcreteFactoryTypeInfo
149{
150 private:
151
153 : m_interface_info(a)
154 , m_concrete_info(b)
155 , m_constructor_info(c)
156 {}
157
158 public:
159
160 template <typename InterfaceType, typename ConcreteType, typename ConstructorType>
161 static ConcreteFactoryTypeInfo create()
162 {
163 return ConcreteFactoryTypeInfo(TypeInfo::create<InterfaceType>(),
164 TypeInfo::create<ConcreteType>(),
165 TypeInfo::create<ConstructorType>());
166 }
167 const TypeInfo& interfaceTypeInfo() const { return m_interface_info; }
168 const TypeInfo& concreteTypeInfo() const { return m_concrete_info; }
169 const TypeInfo& constructorTypeInfo() const { return m_constructor_info; }
170
171 private:
172
173 TypeInfo m_interface_info;
174 TypeInfo m_concrete_info;
175 TypeInfo m_constructor_info;
176};
177
178/*---------------------------------------------------------------------------*/
179/*---------------------------------------------------------------------------*/
184template <typename InterfaceType>
186: public IInjectedInstance
187{
188 public:
189
190 virtual Ref<InterfaceType> instance() = 0;
191
192 private:
193};
194
195/*---------------------------------------------------------------------------*/
196/*---------------------------------------------------------------------------*/
201template <typename InterfaceType>
203: public IInjectedRefInstanceT<InterfaceType>
204{
205 public:
206
208
209 public:
210
212 : m_instance(t_instance)
213 , m_name(t_name)
214 {}
215
216 public:
217
218 Ref<InterfaceType> instance() override { return m_instance; }
219 bool hasName(const String& str) const override { return m_name == str; }
220 bool hasTypeInfo(const std::type_info& tinfo) const override { return typeid(InstanceType) == tinfo; }
221
222 private:
223
224 InstanceType m_instance;
225 String m_name;
226};
227
228/*---------------------------------------------------------------------------*/
229/*---------------------------------------------------------------------------*/
234template <typename Type>
236: public IInjectedInstance
237{
238 public:
239
240 virtual Type instance() const = 0;
241};
242
243/*---------------------------------------------------------------------------*/
244/*---------------------------------------------------------------------------*/
249template <typename Type>
251: public IInjectedValueInstance<Type>
252{
253 public:
254
255 using InstanceType = Type;
256
257 public:
258
260 : m_instance(t_instance)
261 , m_name(t_name)
262 {}
263
264 public:
265
266 Type instance() const override { return m_instance; }
267 bool hasName(const String& str) const override { return m_name == str; }
268 bool hasTypeInfo(const std::type_info& tinfo) const override { return typeid(InstanceType) == tinfo; }
269
270 private:
271
272 Type m_instance;
273 String m_name;
274};
275
276/*---------------------------------------------------------------------------*/
277/*---------------------------------------------------------------------------*/
284class ARCANE_UTILS_EXPORT InjectedInstanceRef
285{
287
288 private:
289
290 explicit InjectedInstanceRef(const RefType& r)
291 : m_instance(r)
292 {}
293
294 public:
295
296 InjectedInstanceRef() = default;
297
298 public:
299
300 static InjectedInstanceRef createRef(IInjectedInstance* p)
301 {
302 return InjectedInstanceRef(RefType::create(p));
303 }
304 static InjectedInstanceRef createRefNoDestroy(IInjectedInstance* p)
305 {
306 return InjectedInstanceRef(RefType::_createNoDestroy(p));
307 }
308 static InjectedInstanceRef createWithHandle(IInjectedInstance* p, Internal::ExternalRef handle)
309 {
310 return InjectedInstanceRef(RefType::createWithHandle(p, handle));
311 }
312
313 public:
314
315 IInjectedInstance* get() const { return m_instance.get(); }
316 void reset() { m_instance.reset(); }
317
318 private:
319
320 RefType m_instance;
321};
322
323/*---------------------------------------------------------------------------*/
324/*---------------------------------------------------------------------------*/
329class ARCANE_UTILS_EXPORT IInstanceFactory
330{
332
333 protected:
334
335 virtual ~IInstanceFactory() = default;
336
337 public:
338
339 virtual InjectedInstanceRef createGenericReference(Injector& injector, const String& name) = 0;
340
341 virtual const FactoryInfo* factoryInfo() const = 0;
342
343 virtual ConcreteFactoryTypeInfo concreteFactoryInfo() const = 0;
344
345 virtual Int32 nbConstructorArg() const = 0;
346};
347
348/*---------------------------------------------------------------------------*/
349/*---------------------------------------------------------------------------*/
362
363/*---------------------------------------------------------------------------*/
364/*---------------------------------------------------------------------------*/
365
366template <typename InterfaceType>
369{
370 public:
371
373 : m_factory_info(si)
374 , m_sub_factory(sub_factory)
375 {
376 }
377
378 ~InstanceFactory() override
379 {
380 delete m_sub_factory;
381 }
382
383 InjectedInstanceRef createGenericReference(Injector& injector, const String& name) override
384 {
385 return _create(_createReference(injector), name);
386 }
387
388 Ref<InterfaceType> createReference(Injector& injector)
389 {
390 return _createReference(injector);
391 }
392
393 const FactoryInfo* factoryInfo() const override
394 {
395 return m_factory_info;
396 }
397
398 ConcreteFactoryTypeInfo concreteFactoryInfo() const override
399 {
400 return m_sub_factory->concreteFactoryInfo();
401 }
402
403 Int32 nbConstructorArg() const override
404 {
405 return m_sub_factory->nbConstructorArg();
406 }
407
408 protected:
409
410 FactoryInfo* m_factory_info;
411 IConcreteFactory<InterfaceType>* m_sub_factory;
412
413 private:
414
415 Ref<InterfaceType> _createReference(Injector& injector)
416 {
417 return m_sub_factory->createReference(injector);
418 }
419
420 InjectedInstanceRef _create(Ref<InterfaceType> it, const String& name)
421 {
422 IInjectedInstance* x = (!it) ? nullptr : new InjectedRefInstance<InterfaceType>(it, name);
423 return InjectedInstanceRef::createRef(x);
424 }
425};
426
427/*---------------------------------------------------------------------------*/
428/*---------------------------------------------------------------------------*/
429
430class ARCANE_UTILS_EXPORT IConcreteFactoryBase
431{
432 public:
433
434 virtual ~IConcreteFactoryBase() = default;
435
436 public:
437
438 virtual ConcreteFactoryTypeInfo concreteFactoryInfo() const = 0;
439 virtual Int32 nbConstructorArg() const = 0;
440};
441
442/*---------------------------------------------------------------------------*/
443/*---------------------------------------------------------------------------*/
449template <typename InterfaceType>
452{
453 public:
454
455 virtual ~IConcreteFactory() = default;
456
457 public:
458
461};
462
463/*---------------------------------------------------------------------------*/
464/*---------------------------------------------------------------------------*/
469class ARCANE_UTILS_EXPORT FactoryInfo
470{
472 class Impl;
473
474 public:
475
476 FactoryInfo(const FactoryInfo&) = delete;
477 FactoryInfo& operator=(const FactoryInfo&) = delete;
478 ~FactoryInfo();
479
480 private:
481
482 explicit FactoryInfo(const ProviderProperty& property);
483
484 public:
485
486 static FactoryInfo* create(const ProviderProperty& property, const char* file_name, int line_number)
487 {
488 ARCANE_UNUSED(file_name);
489 ARCANE_UNUSED(line_number);
490 return new FactoryInfo(property);
491 }
492 void addFactory(Ref<IInstanceFactory> f);
493 bool hasName(const String& str) const;
494 void fillWithImplementationNames(Array<String>& names) const;
495
496 private:
497
498 Impl* m_p = nullptr;
499};
500
501/*---------------------------------------------------------------------------*/
502/*---------------------------------------------------------------------------*/
503
504class ARCANE_UTILS_EXPORT GlobalRegisterer
505: public GenericRegisterer<GlobalRegisterer>
506{
508 static BaseClass::Info m_global_registerer_info;
509
510 public:
511
512 static GenericRegisterer<GlobalRegisterer>::Info& registererInfo()
513 {
514 return m_global_registerer_info;
515 }
516
517 public:
518
519 typedef FactoryInfo* (*FactoryCreateFunc)(const ProviderProperty& property);
520
521 public:
522
528 GlobalRegisterer(FactoryCreateFunc func, const ProviderProperty& property) noexcept;
529
530 public:
531
532 FactoryCreateFunc infoCreatorWithPropertyFunction() { return m_factory_create_func; }
533
535 const char* name() { return m_name; }
536
537 const ProviderProperty& property() const { return m_factory_property; }
538
539 private:
540
541 FactoryCreateFunc m_factory_create_func = nullptr;
542 const char* m_name = nullptr;
543 ProviderProperty m_factory_property;
544
545 private:
546};
547
548/*---------------------------------------------------------------------------*/
549/*---------------------------------------------------------------------------*/
550
551} // namespace Arcane::DependencyInjection::impl
552
553namespace Arcane::DependencyInjection
554{
555
556/*---------------------------------------------------------------------------*/
557/*---------------------------------------------------------------------------*/
561class ARCANE_UTILS_EXPORT Injector
562{
563 class Impl;
564 using FactoryFilterFunc = bool (*)(impl::IInstanceFactory*);
565
566 template <class Type>
568 {
569 public:
570
571 static IInjectedInstance* bind(const Type& t, const String& name)
572 {
573 return new impl::InjectedValueInstance<Type>(t, name);
574 }
575 static Type get(Injector& i, const String& name)
576 {
577 return i._getValue<Type>(name);
578 }
579 };
580
582 template <class PointerType>
583 class InjectorHelper<Ref<PointerType>>
584 {
585 public:
586
588
589 public:
590
591 static IInjectedInstance* bind(const ThatType& t, const String& name)
592 {
594 }
595 static ThatType get(Injector& i, const String& name)
596 {
597 return i._getRef<PointerType>(name);
598 }
599 };
604 {
605 public:
606
607 virtual ~IFactoryVisitorFunctor() = default;
608 virtual bool execute(impl::IInstanceFactory* f) = 0;
609 };
610
611 template <typename Lambda> class FactoryVisitorFunctor
613 {
614 public:
615
617 : m_lambda(lambda)
618 {}
619
620 public:
621
622 virtual bool execute(impl::IInstanceFactory* f) { return m_lambda(f); }
623
624 private:
625
626 Lambda& m_lambda;
627 };
628
633 {
634 public:
635
636 virtual ~IInstanceVisitorFunctor() = default;
637 virtual bool execute(IInjectedInstance* v) = 0;
638 };
639
640 template <typename Lambda> class InstanceVisitorFunctor
642 {
643 public:
644
646 : m_lambda(lambda)
647 {}
648
649 public:
650
651 virtual bool execute(IInjectedInstance* v) { return m_lambda(v); }
652
653 private:
654
655 Lambda& m_lambda;
656 };
657
658 public:
659
660 Injector();
661 Injector(const Injector&) = delete;
662 Injector& operator=(const Injector&) = delete;
663 ~Injector();
664
665 public:
666
667 template <typename Type> void
668 bind(Type iref, const String& name = String())
669 {
670 _add(InjectorHelper<Type>::bind(iref, name));
671 }
672
673 template <typename Type> Type
674 get(const String& name = String())
675 {
676 return InjectorHelper<Type>::get(*this, name);
677 }
678
692 template <typename InterfaceType> Ref<InterfaceType>
694 {
695 using FactoryType = impl::InstanceFactory<InterfaceType>;
696 Ref<InterfaceType> instance;
697 auto f = [&](impl::IInstanceFactory* v) -> bool {
698 auto* t = dynamic_cast<FactoryType*>(v);
699 //std::cout << "TRY DYNAMIC_CAST FACTORY v=" << v << " t=" << t << "\n";
700 if (t) {
701 Ref<InterfaceType> x = t->createReference(*this);
702 if (x.get()) {
703 instance = x;
704 return true;
705 }
706 }
707 return false;
708 };
710 _iterateFactories(implementation_name, &ff);
711 if (instance.get() || allow_null)
712 return instance;
713
714 // Pas d'implémentation correspondante trouvée.
715 // Dans ce cas on récupère la liste des implémentations valides et on les affiche dans
716 // le message d'erreur.
717 auto filter_func = [](impl::IInstanceFactory* v) -> bool {
718 return dynamic_cast<FactoryType*>(v) != nullptr;
719 };
720 _printValidImplementationAndThrow(A_FUNCINFO, implementation_name, filter_func);
721 }
722
723 String printFactories() const;
724
725 void fillWithGlobalFactories();
726
727 private:
728
729 Impl* m_p = nullptr;
730
731 private:
732
733 void _add(IInjectedInstance* instance);
734
735 // Itère sur la lambda et s'arrête dès que cette dernière retourne \a true
736 void _iterateInstances(const std::type_info& t_info, const String& instance_name,
737 IInstanceVisitorFunctor* lambda);
738 Integer _nbValue() const;
739 IInjectedInstance* _value(Integer i) const;
740
749 void _iterateFactories(const String& factory_name, IFactoryVisitorFunctor* functor) const;
750 Integer _nbFactory() const;
751 impl::IInstanceFactory* _factory(Integer i) const;
752
753 // Spécialisation pour les références
754 template <typename InterfaceType> Ref<InterfaceType>
755 _getRef(const String& instance_name)
756 {
758 InjectedType* t = nullptr;
759 auto f = [&](IInjectedInstance* v) -> bool {
760 t = dynamic_cast<InjectedType*>(v);
761 return t;
762 };
763 InstanceVisitorFunctor ff(f);
764 _iterateInstances(typeid(Ref<InterfaceType>), instance_name, &ff);
765 if (t)
766 return t->instance();
767 // TODO: faire un fatal ou créer l'instance
768 ARCANE_THROW(NotImplementedException, "Create Ref<InterfaceType> from factory");
769 }
770
771 template <typename Type> Type
772 _getValue(const String& instance_name)
773 {
774 using InjectedType = impl::IInjectedValueInstance<Type>;
775 InjectedType* t = nullptr;
776 auto f = [&](IInjectedInstance* v) -> bool {
777 t = dynamic_cast<InjectedType*>(v);
778 return t;
779 };
780 InstanceVisitorFunctor ff(f);
781 _iterateInstances(typeid(Type), instance_name, &ff);
782 if (t)
783 return t->instance();
784 _doError(A_FUNCINFO, "Can not find value for type");
785 }
786 [[noreturn]] void _printValidImplementationAndThrow(const TraceInfo& ti,
787 const String& implementation_name,
788 FactoryFilterFunc filter_func);
789 [[noreturn]] void _doError(const TraceInfo& ti, const String& message);
790};
791
792/*---------------------------------------------------------------------------*/
793/*---------------------------------------------------------------------------*/
794
795} // namespace Arcane::DependencyInjection
796
797namespace Arcane::DependencyInjection::impl
798{
799
800/*---------------------------------------------------------------------------*/
801/*---------------------------------------------------------------------------*/
802
803class ARCANE_UTILS_EXPORT ConstructorRegistererBase
804{
805 protected:
806
807 [[noreturn]] void _doError1(const String& message, int nb_value);
808};
809
816template <typename... Args>
819{
820 public:
821
822 using ArgsType = std::tuple<Args...>;
823
825
826 // Permet de récupérer via l'injecteur \a i le I-ème argument du tuple.
827 template <std::size_t I>
828 static auto _get(Injector& i) -> std::tuple_element_t<I, ArgsType>
829 {
830 using SelectedType = std::tuple_element_t<I, ArgsType>;
831 //std::cout << "RETURN _GET(I=" << I << ")\n";
832 return i.get<SelectedType>();
833 }
834
835 ArgsType createTuple(Injector& i)
836 {
837 // TODO: supporter plus d'arguments ou passer à des 'variadic templates'
838 constexpr int tuple_size = std::tuple_size<ArgsType>();
839 static_assert(tuple_size < 3, "Too many arguments for createTuple (max=2)");
840 if constexpr (tuple_size == 0) {
841 return ArgsType();
842 }
843 else if constexpr (tuple_size == 1) {
844 return ArgsType(_get<0>(i));
845 }
846 else if constexpr (tuple_size == 2) {
847 return ArgsType(_get<0>(i), _get<1>(i));
848 }
849 // Ne devrait pas arriver mais on ne sais jamais.
850 _doError1("Too many arguments for createTuple n={0} max=2", tuple_size);
851 }
852};
853
854/*---------------------------------------------------------------------------*/
855/*---------------------------------------------------------------------------*/
861template <typename InterfaceType, typename ConcreteType, typename ConstructorType>
863: public IConcreteFactory<InterfaceType>
864{
865 using Args = typename ConstructorType::ArgsType;
866
867 public:
868
870 {
872 ConcreteType* st = _create(ct.createTuple(injector));
873 return makeRef<InterfaceType>(st);
874 }
875 ConcreteFactoryTypeInfo concreteFactoryInfo() const override
876 {
877 return ConcreteFactoryTypeInfo::create<InterfaceType, ConcreteType, ConstructorType>();
878 }
879 Int32 nbConstructorArg() const override
880 {
881 return std::tuple_size<Args>();
882 }
883
884 private:
885
892 {
893 ConcreteType* st = std::apply([](auto&&... args) -> ConcreteType* { return new ConcreteType(args...); }, tuple_args);
894 return st;
895 }
896};
897
898/*---------------------------------------------------------------------------*/
899/*---------------------------------------------------------------------------*/
905template <typename... Interfaces>
907{
908 public:
909
916 template <typename ConcreteType, typename ConstructorType> void
918 {
919 _registerFactory<ConcreteType, ConstructorType, Interfaces...>(si);
920 }
921
922 private:
923
924 template <typename ConcreteType, typename ConstructorType,
925 typename InterfaceType, typename... OtherInterfaces>
926 void
927 _registerFactory(FactoryInfo* fi)
928 {
930 fi->addFactory(createRef<InstanceFactory<InterfaceType>>(fi, factory));
931 // Applique récursivement pour les autres interfaces si nécessaire
932 if constexpr (sizeof...(OtherInterfaces) > 0)
933 _registerFactory<ConcreteType, ConstructorType, OtherInterfaces...>(fi);
934 }
935};
936
937/*---------------------------------------------------------------------------*/
938/*---------------------------------------------------------------------------*/
945template <typename ConcreteType, typename InterfaceList>
947{
948 public:
949
951 template <typename... Constructors> void
953 {
954 _create(si, args...);
955 }
956
957 private:
958
959 // TODO: Créér l'instance de 'FactoryInfo' dans le constructeur
960 InterfaceList m_interface_list;
961
962 private:
963
965 template <typename ConstructorType> void
967 {
968 m_interface_list.template registerFactory<ConcreteType, ConstructorType>(si);
969 }
970
972 template <typename C1, typename C2, typename... OtherConstructors>
973 void _create(FactoryInfo* si, const C1& c1, const C2& c2, const OtherConstructors&... args)
974 {
975 _create<C1>(si, c1);
976 // Applique la récursivité sur les types restants
977 _create<C2, OtherConstructors...>(si, c2, args...);
978 }
979};
980
981/*---------------------------------------------------------------------------*/
982/*---------------------------------------------------------------------------*/
983
984} // namespace Arcane::DependencyInjection::impl
985
986/*---------------------------------------------------------------------------*/
987/*---------------------------------------------------------------------------*/
988
989#define ARCANE_DI_CONSTRUCTOR(...) \
990 ::Arcane::DependencyInjection::impl::ConstructorRegisterer<__VA_ARGS__>()
991
992#define ARCANE_DI_EMPTY_CONSTRUCTOR(...) \
993 ::Arcane::DependencyInjection::impl::ConstructorRegisterer<>()
994
995// TODO: garantir au moins une interface
996
997#define ARCANE_DI_INTERFACES(...) \
998 ::Arcane::DependencyInjection::impl::InterfaceListRegisterer<__VA_ARGS__>
999
1000#define ARCANE_DI_REGISTER_PROVIDER(t_class, t_provider_property, t_interfaces, ...) \
1001 namespace \
1002 { \
1003 Arcane::DependencyInjection::impl::FactoryInfo* \
1004 ARCANE_JOIN_WITH_LINE(arcaneCreateDependencyInjectionProviderInfo##t_class)(const Arcane::DependencyInjection::ProviderProperty& property) \
1005 { \
1006 auto* si = Arcane::DependencyInjection::impl::FactoryInfo::create(property, __FILE__, __LINE__); \
1007 Arcane::DependencyInjection::impl::InjectionRegisterer<t_class, t_interfaces> injection_registerer; \
1008 injection_registerer.registerProviderInfo(si, __VA_ARGS__); \
1009 return si; \
1010 } \
1011 } \
1012 Arcane::DependencyInjection::impl::GlobalRegisterer ARCANE_EXPORT ARCANE_JOIN_WITH_LINE(globalServiceRegisterer##aclass)(&ARCANE_JOIN_WITH_LINE(arcaneCreateDependencyInjectionProviderInfo##t_class), t_provider_property)
1013
1014/*---------------------------------------------------------------------------*/
1015/*---------------------------------------------------------------------------*/
1016
1017#endif
#define ARCANE_THROW(exception_class,...)
Macro pour envoyer une exception avec formattage.
#define ARCCORE_DECLARE_REFERENCE_COUNTED_INCLASS_METHODS()
Macro pour déclarer les méthodes virtuelles gérant les compteurs de référence.
#define ARCCORE_DECLARE_REFERENCE_COUNTED_CLASS(class_name)
Macro pour déclarer qu'une classe utilise un compteur de référence.
#define ARCCORE_DEFINE_REFERENCE_COUNTED_INCLASS_METHODS()
Macro pour définir les méthodes gérant les compteurs de référence.
Interface d'un fonctor pour appliqué à chaque fabrique.
Interface d'un fonctor pour appliqué à chaque fabrique.
Ref< InterfaceType > createInstance(const String &implementation_name, bool allow_null=false)
Créé une instance implémentant une interface.
Fabrique pour le type ConcreteType pour l'interface InterfaceType via le constructeur ConstructorType...
ConcreteType * _create(const Args &&tuple_args)
Ref< InterfaceType > createReference(Injector &injector) override
Créé une instance du service .
Classe permettant d'enregistrer un constructeur pour créer un objet via un Injector....
Interface d'un fonctor de création d'une instance de service correspondant à l'interface InterfaceTyp...
virtual Ref< InterfaceType > createReference(Injector &)=0
Créé une instance du service .
Interface typée gérant l'instance d'un service.
Fabrique pour une instance encapsulée par une référence (i.e Ref<T>).
Interface typée gérant l'instance d'un service.
Interface typée gérant l'instance d'un service.
Classe permettant d'enregistrer des constructeurs pour créer un type ConcreteType implémentant les in...
void _create(FactoryInfo *si, const C1 &c1, const C2 &c2, const OtherConstructors &... args)
Surcharge pour 2 constructeurs ou plus.
void registerProviderInfo(FactoryInfo *si, const Constructors &... args)
Enregistre dans si les fabriques correspondentes aux constructeurs Constructors.
void _create(FactoryInfo *si, const ConstructorType &)
Surcharge pour 1 constructeur.
Classe permettant d'enregistrer la liste des interfaces d'un service. Interfaces contient la liste de...
void registerFactory(FactoryInfo *si)
Enregistre une fabrique.
Classe template pour gérer une liste globale permettant d'enregistrer des fabriques.
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Definition Lima.cc:149
Gestion des références sur un objet externe.
Exception lorsqu'une fonction n'est pas implémentée.
Référence à une instance.
Implémentation thread-safe d'un compteur de référence.
Chaîne de caractères unicode.
Type
Type of JSON value.
Definition rapidjson.h:665