Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-06-02 08:51:49

0001 #ifndef RESOURCE_MANAGER_H
0002 #define RESOURCE_MANAGER_H
0003 
0004 /**
0005  * @file ResourceManager.h
0006  * @author Bryan BERTHOU (SPhN / CEA Saclay)
0007  * @date April 22, 2016
0008  * @version 1.0
0009  */
0010 
0011 #include <ctime>
0012 #include <map>
0013 #include <memory>
0014 #include <string>
0015 #include <utility>
0016 
0017 #include "beans/automation/Scenario.h"
0018 #include "beans/Computation.h"
0019 
0020 namespace PARTONS {
0021 
0022 /**
0023  * @class ResourceManager
0024  *
0025  * @brief
0026  */
0027 class ResourceManager: public BaseObject {
0028 public:
0029     /**
0030      * Static function to be able to retrieve a unique instance pointer of this class anywhere in the code.
0031      *
0032      * @return a unique instance of this class
0033      */
0034     static ResourceManager* getInstance();
0035 
0036     /**
0037      * Default destructor
0038      */
0039     virtual ~ResourceManager();
0040 
0041     Scenario* getScenarioByHashSum(const std::string &hashSum) const;
0042 
0043     Scenario* registerScenario(Scenario* pScenario);
0044     Scenario* registerScenario(
0045             const std::string &description,
0046             const std::string &filePath, const std::string &hashSum,
0047             const std::string &file);
0048 
0049     Computation* getComputationPointer(const time_t &datetime);
0050     Computation* newComputationObject();
0051 
0052 private:
0053     /**
0054      * Private pointer of this class for a unique instance
0055      */
0056     static ResourceManager* m_pInstance;
0057 
0058     /**
0059      * Private default constructor for a unique instance
0060      */
0061     ResourceManager();
0062 
0063     // key = hashSum of the XML file
0064     // 1st value = scenario instantiated object
0065     // 2nd value = counter for know how many system objects refer to it. When counter == 0 mean that Scenario object must be free.
0066     std::map<std::string, std::pair<Scenario*, unsigned int> > m_scenarioResourceList;
0067 
0068     // key = computation datetime
0069     // 1st value = computation instantiated object
0070     // 2nd value = counter for know how many system objects refer to it. When counter == 0 mean that Computation object must be free.
0071     std::map<time_t, std::pair<std::unique_ptr<Computation>, unsigned int> > computationList;
0072 };
0073 
0074 } /* namespace PARTONS */
0075 
0076 #endif /* RESOURCE_MANAGER_H */