[591] | 1 | #ifndef __XIOS_CObjectFactory__ |
---|
| 2 | #define __XIOS_CObjectFactory__ |
---|
[219] | 3 | |
---|
[1542] | 4 | #include <memory> |
---|
[219] | 5 | |
---|
[591] | 6 | /// XIOS headers /// |
---|
| 7 | #include "xios_spl.hpp" |
---|
[219] | 8 | #include "exception.hpp" |
---|
| 9 | #include "object_template.hpp" |
---|
| 10 | |
---|
[335] | 11 | namespace xios |
---|
[219] | 12 | { |
---|
| 13 | /// ////////////////////// Déclarations ////////////////////// /// |
---|
| 14 | class CObjectFactory |
---|
| 15 | { |
---|
| 16 | public : |
---|
| 17 | |
---|
| 18 | /// Mutateurs /// |
---|
| 19 | static void SetCurrentContextId(const StdString & context); |
---|
| 20 | |
---|
| 21 | /// Accesseurs /// |
---|
| 22 | static StdString & GetCurrentContextId(void); |
---|
| 23 | |
---|
| 24 | template <typename U> |
---|
[1542] | 25 | static std::shared_ptr<U> GetObject(const StdString & id); |
---|
[219] | 26 | |
---|
| 27 | template <typename U> |
---|
[1542] | 28 | static std::shared_ptr<U> GetObject(const StdString& context,const StdString & id); |
---|
[286] | 29 | |
---|
| 30 | template <typename U> |
---|
[1542] | 31 | static std::shared_ptr<U> GetObject(const U * const object); |
---|
[219] | 32 | |
---|
| 33 | template <typename U> |
---|
[352] | 34 | static int GetObjectNum(void); |
---|
[219] | 35 | template <typename U> |
---|
[352] | 36 | static int GetObjectIdNum(void); |
---|
[219] | 37 | |
---|
| 38 | template <typename U> |
---|
[1628] | 39 | static int CheckObjectVector(); |
---|
| 40 | |
---|
| 41 | template <typename U> |
---|
[1542] | 42 | static const std::vector<std::shared_ptr<U> > & |
---|
[219] | 43 | GetObjectVector(const StdString & context = CObjectFactory::GetCurrentContextId()); |
---|
| 44 | |
---|
| 45 | /// Tests /// |
---|
| 46 | template <typename U> |
---|
[352] | 47 | static bool HasObject(const StdString & id); |
---|
[219] | 48 | |
---|
[286] | 49 | template <typename U> |
---|
[352] | 50 | static bool HasObject(const StdString& context,const StdString & id); |
---|
[286] | 51 | |
---|
[219] | 52 | /// Instanciateur /// |
---|
| 53 | template <typename U> |
---|
[1542] | 54 | static std::shared_ptr<U> CreateObject(const StdString & id = StdString("")); |
---|
[219] | 55 | |
---|
[769] | 56 | template <typename U> static const StdString& GetUIdBase(void); |
---|
| 57 | template <typename U> static StdString GenUId(void); |
---|
| 58 | template <typename U> static bool IsGenUId(const StdString& id); |
---|
[219] | 59 | |
---|
| 60 | private : |
---|
| 61 | |
---|
| 62 | /// Propriétés statiques /// |
---|
[1601] | 63 | static StdString *CurrContext_ptr; |
---|
| 64 | #pragma omp threadprivate(CurrContext_ptr) |
---|
[219] | 65 | |
---|
| 66 | }; // class CObjectFactory |
---|
[335] | 67 | } // namespace xios |
---|
[219] | 68 | |
---|
[352] | 69 | //#include "object_factory_impl.hpp" |
---|
[219] | 70 | |
---|
[591] | 71 | #endif // __XIOS_CObjectFactory__ |
---|