blob: e832514f299a4a20e15d05b98e80372cf5bf2a63 [file] [log] [blame]
Zane Shelley5a266612019-08-15 16:23:53 -05001#pragma once
2
3#include <hei_includes.hpp>
4#include <hei_isolation_data.hpp>
Zane Shelley5a266612019-08-15 16:23:53 -05005
6namespace 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 Shelleyb406de42019-09-09 16:10:38 -050017 * - Call isolate() to find all active errors being reported by the given list
18 * of chips.
Zane Shelley5a266612019-08-15 16:23:53 -050019 * - 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 */
29class 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. */
Zane Shelleyfe27b652019-10-28 11:33:07 -050044 Isolator(const Isolator&) = delete;
Zane Shelley5a266612019-08-15 16:23:53 -050045
46 /** @brief Assignment operator. */
Zane Shelleyfe27b652019-10-28 11:33:07 -050047 Isolator& operator=(const Isolator&) = delete;
Zane Shelley5a266612019-08-15 16:23:53 -050048
49 public:
50
51 /** @brief Provides access to a singleton instance of this object. */
Zane Shelleyfe27b652019-10-28 11:33:07 -050052 static Isolator& getSingleton()
Zane Shelley5a266612019-08-15 16:23:53 -050053 {
54 static Isolator theIsolator;
55 return theIsolator;
56 }
57
58 /** @brief See API wrapper description in hei_main.hpp. */
Zane Shelleyfe27b652019-10-28 11:33:07 -050059 ReturnCode initialize(void* i_buffer, size_t i_bufferSize,
Zane Shelley83da2452019-10-25 15:45:34 -050060 bool i_forceInit = false);
Zane Shelley5a266612019-08-15 16:23:53 -050061
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 Shelleyfe27b652019-10-28 11:33:07 -050071 ReturnCode isolate(const std::vector<Chip>& i_chipList,
72 IsolationData& o_isoData) const;
Zane Shelley5a266612019-08-15 16:23:53 -050073
74 private:
75
76}; // end class Isolator
77
78} // end namespace libhei