[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); |
---|
[2274] | 23 | static void clearCurrentContextId(void) {CurrContext.clear(); CurrContext.shrink_to_fit(); } |
---|
[219] | 24 | |
---|
| 25 | template <typename U> |
---|
[1542] | 26 | static std::shared_ptr<U> GetObject(const StdString & id); |
---|
[219] | 27 | |
---|
| 28 | template <typename U> |
---|
[1542] | 29 | static std::shared_ptr<U> GetObject(const StdString& context,const StdString & id); |
---|
[286] | 30 | |
---|
| 31 | template <typename U> |
---|
[1542] | 32 | static std::shared_ptr<U> GetObject(const U * const object); |
---|
[219] | 33 | |
---|
| 34 | template <typename U> |
---|
[352] | 35 | static int GetObjectNum(void); |
---|
[219] | 36 | template <typename U> |
---|
[352] | 37 | static int GetObjectIdNum(void); |
---|
[219] | 38 | |
---|
| 39 | template <typename U> |
---|
[1542] | 40 | static const std::vector<std::shared_ptr<U> > & |
---|
[219] | 41 | GetObjectVector(const StdString & context = CObjectFactory::GetCurrentContextId()); |
---|
| 42 | |
---|
| 43 | /// Tests /// |
---|
| 44 | template <typename U> |
---|
[352] | 45 | static bool HasObject(const StdString & id); |
---|
[219] | 46 | |
---|
[286] | 47 | template <typename U> |
---|
[352] | 48 | static bool HasObject(const StdString& context,const StdString & id); |
---|
[286] | 49 | |
---|
[219] | 50 | /// Instanciateur /// |
---|
| 51 | template <typename U> |
---|
[1542] | 52 | static std::shared_ptr<U> CreateObject(const StdString & id = StdString("")); |
---|
[1869] | 53 | |
---|
| 54 | template <typename U> |
---|
| 55 | static std::shared_ptr<U> CreateAlias(const StdString& id, const StdString& alias) ; |
---|
| 56 | |
---|
[2265] | 57 | template <typename U> static const StdString GetUIdBase(void); |
---|
[769] | 58 | template <typename U> static StdString GenUId(void); |
---|
| 59 | template <typename U> static bool IsGenUId(const StdString& id); |
---|
[2265] | 60 | template <typename U> static void deleteContext(const StdString & context) ; |
---|
| 61 | template <typename U> static void deleteAllContexts(void) ; |
---|
| 62 | template <typename U> static void dumpObjects(void) ; |
---|
[219] | 63 | private : |
---|
| 64 | |
---|
| 65 | /// Propriétés statiques /// |
---|
| 66 | static StdString CurrContext; |
---|
| 67 | |
---|
| 68 | }; // class CObjectFactory |
---|
[335] | 69 | } // namespace xios |
---|
[219] | 70 | |
---|
[352] | 71 | //#include "object_factory_impl.hpp" |
---|
[219] | 72 | |
---|
[591] | 73 | #endif // __XIOS_CObjectFactory__ |
---|