Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <hei_includes.hpp> |
| 4 | #include <hei_isolation_data.hpp> |
Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 5 | |
| 6 | namespace libhei |
| 7 | { |
| 8 | |
| 9 | /** |
| 10 | * @brief This class is a complement to the main APIs. Its purpose is to store |
| 11 | * and maintain all of the objects necessary for isolation. |
| 12 | * |
| 13 | * The intended flow is to: |
| 14 | * - Create a singleton instance of an Isolator object via getSingleton(). |
| 15 | * - Use initialize() to input each necessary Chip Data File provided by the |
| 16 | * user application. |
Zane Shelley | b406de4 | 2019-09-09 16:10:38 -0500 | [diff] [blame] | 17 | * - Call isolate() to find all active errors being reported by the given list |
| 18 | * of chips. |
Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 19 | * - Once isolation is no longer needed, use uninitialize() to free up |
| 20 | * internal resources. |
| 21 | * |
| 22 | * The purpose of the singleton instance is to avoid initializing the object |
| 23 | * each time isolation is required. The data provided by the Chip Data Files is |
| 24 | * static. So reinitializing would be a waste of time, unless for some reason |
| 25 | * the Chip Data Files themselves are updated, which would require |
| 26 | * reinitialization anyway. Of course, leaving the object in memory chews up |
| 27 | * resources. So, some users may need to weigh performance vs. memory usage. |
| 28 | */ |
| 29 | class Isolator |
| 30 | { |
| 31 | private: // This class cannot be instantiated. Use getSingleton() instead. |
Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 32 | /** @brief Default constructor. */ |
| 33 | Isolator() = default; |
| 34 | |
| 35 | /** @brief Destructor. */ |
| 36 | ~Isolator() |
| 37 | { |
| 38 | // Clear out all of the internal isolation objects. |
| 39 | uninitialize(); |
| 40 | } |
| 41 | |
| 42 | /** @brief Copy constructor. */ |
Zane Shelley | fe27b65 | 2019-10-28 11:33:07 -0500 | [diff] [blame] | 43 | Isolator(const Isolator&) = delete; |
Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 44 | |
| 45 | /** @brief Assignment operator. */ |
Zane Shelley | fe27b65 | 2019-10-28 11:33:07 -0500 | [diff] [blame] | 46 | Isolator& operator=(const Isolator&) = delete; |
Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 47 | |
| 48 | public: |
Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 49 | /** @brief Provides access to a singleton instance of this object. */ |
Zane Shelley | fe27b65 | 2019-10-28 11:33:07 -0500 | [diff] [blame] | 50 | static Isolator& getSingleton() |
Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 51 | { |
| 52 | static Isolator theIsolator; |
| 53 | return theIsolator; |
| 54 | } |
| 55 | |
| 56 | /** @brief See API wrapper description in hei_main.hpp. */ |
Zane Shelley | fe27b65 | 2019-10-28 11:33:07 -0500 | [diff] [blame] | 57 | ReturnCode initialize(void* i_buffer, size_t i_bufferSize, |
Zane Shelley | 83da245 | 2019-10-25 15:45:34 -0500 | [diff] [blame] | 58 | bool i_forceInit = false); |
Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 59 | |
| 60 | /** |
| 61 | * @brief See API wrapper description in hei_main.hpp. |
| 62 | * |
| 63 | * This function is called in the destructor. Therefore, it should never |
| 64 | * throw an exception. |
| 65 | */ |
| 66 | void uninitialize(); |
| 67 | |
| 68 | /** @brief See API wrapper description in hei_main.hpp. */ |
Zane Shelley | fe27b65 | 2019-10-28 11:33:07 -0500 | [diff] [blame] | 69 | ReturnCode isolate(const std::vector<Chip>& i_chipList, |
| 70 | IsolationData& o_isoData) const; |
Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 71 | }; // end class Isolator |
| 72 | |
| 73 | } // end namespace libhei |