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. |
| 32 | |
| 33 | /** @brief Default constructor. */ |
| 34 | Isolator() = default; |
| 35 | |
| 36 | /** @brief Destructor. */ |
| 37 | ~Isolator() |
| 38 | { |
| 39 | // Clear out all of the internal isolation objects. |
| 40 | uninitialize(); |
| 41 | } |
| 42 | |
| 43 | /** @brief Copy constructor. */ |
| 44 | Isolator( const Isolator & ) = delete; |
| 45 | |
| 46 | /** @brief Assignment operator. */ |
| 47 | Isolator & operator=( const Isolator & ) = delete; |
| 48 | |
| 49 | public: |
| 50 | |
| 51 | /** @brief Provides access to a singleton instance of this object. */ |
| 52 | static Isolator & getSingleton() |
| 53 | { |
| 54 | static Isolator theIsolator; |
| 55 | return theIsolator; |
| 56 | } |
| 57 | |
| 58 | /** @brief See API wrapper description in hei_main.hpp. */ |
| 59 | ReturnCode initialize( void * i_buffer, size_t i_bufferSize, |
| 60 | bool i_forceInit = false ); |
| 61 | |
| 62 | /** |
| 63 | * @brief See API wrapper description in hei_main.hpp. |
| 64 | * |
| 65 | * This function is called in the destructor. Therefore, it should never |
| 66 | * throw an exception. |
| 67 | */ |
| 68 | void uninitialize(); |
| 69 | |
| 70 | /** @brief See API wrapper description in hei_main.hpp. */ |
Zane Shelley | b406de4 | 2019-09-09 16:10:38 -0500 | [diff] [blame] | 71 | ReturnCode isolate( const std::vector<Chip> & i_chipList, |
| 72 | IsolationData & o_isoData ) const; |
Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 73 | |
| 74 | private: |
| 75 | |
| 76 | }; // end class Isolator |
| 77 | |
| 78 | } // end namespace libhei |