|
|
|||
File indexing completed on 2026-06-02 08:48:23
0001 #ifndef INTEGRATOR_REGISTRY_H 0002 #define INTEGRATOR_REGISTRY_H 0003 0004 /** 0005 * @file IntegratorRegistry.h 0006 * @author Bryan BERTHOU (SPhN / CEA Saclay) 0007 * @date June 29, 2016 0008 * @version 1.0 0009 */ 0010 0011 #include <SFML/System/Mutex.hpp> 0012 #include <map> 0013 #include <string> 0014 0015 #include "Integrator.h" 0016 0017 namespace NumA { 0018 0019 /** 0020 * @class IntegratorRegistry 0021 * 0022 * @brief 0023 */ 0024 class IntegratorRegistry { 0025 public: 0026 /** 0027 * Static function to be able to retrieve a unique instance pointer of this class anywhere in the code. 0028 * 0029 * @return a unique instance of this class 0030 */ 0031 static IntegratorRegistry* getInstance(); 0032 0033 /** 0034 * Default destructor 0035 */ 0036 virtual ~IntegratorRegistry(); 0037 0038 unsigned int registerIntegrator(Integrator * pIntegrator); 0039 0040 /** 0041 * Try to find stored object identified by its unique class identifier. 0042 * 0043 * @param classId 0044 * @return reference to object in memory or throw an exception 0045 */ 0046 Integrator* get(unsigned int classId) const; 0047 0048 /** 0049 * Try to find stored object identified by its class name. 0050 * 0051 * @param className 0052 * @return reference to object in memory or throw an exception 0053 */ 0054 Integrator* get(const std::string &className) const; 0055 0056 private: 0057 0058 /** 0059 * Because NumA++ can be use in a multi-threading program we must ensure that only one object manipulates the registry at the same time to avoid memory access violation. 0060 * It's performed by a mechanism called mutex or semaphore. 0061 */ 0062 mutable sf::Mutex m_mutex; 0063 0064 /** 0065 * Private pointer of this class for a unique instance 0066 */ 0067 static IntegratorRegistry* m_pInstance; 0068 0069 /** 0070 * Private default constructor for a unique instance 0071 */ 0072 IntegratorRegistry(); 0073 0074 std::map<unsigned int, Integrator*> m_baseObjectList; ///< list of registered objects identified by their unique integer identifier 0075 std::map<std::string, Integrator*> m_translateList; ///< list of registered objects identified by their class name. 0076 }; 0077 0078 } // namespace NumA 0079 0080 #endif /* INTEGRATOR_REGISTRY_H */
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|