blob: d779b7b3ae7fffcfdd1815cf9cd131b8e13e14a6 [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.
Zane Shelley5a266612019-08-15 16:23:53 -050032 /** @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 Shelleyfe27b652019-10-28 11:33:07 -050043 Isolator(const Isolator&) = delete;
Zane Shelley5a266612019-08-15 16:23:53 -050044
45 /** @brief Assignment operator. */
Zane Shelleyfe27b652019-10-28 11:33:07 -050046 Isolator& operator=(const Isolator&) = delete;
Zane Shelley5a266612019-08-15 16:23:53 -050047
48 public:
Zane Shelley5a266612019-08-15 16:23:53 -050049 /** @brief Provides access to a singleton instance of this object. */
Zane Shelleyfe27b652019-10-28 11:33:07 -050050 static Isolator& getSingleton()
Zane Shelley5a266612019-08-15 16:23:53 -050051 {
52 static Isolator theIsolator;
53 return theIsolator;
54 }
55
56 /** @brief See API wrapper description in hei_main.hpp. */
Zane Shelleyfe27b652019-10-28 11:33:07 -050057 ReturnCode initialize(void* i_buffer, size_t i_bufferSize,
Zane Shelley83da2452019-10-25 15:45:34 -050058 bool i_forceInit = false);
Zane Shelley5a266612019-08-15 16:23:53 -050059
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 Shelleyfe27b652019-10-28 11:33:07 -050069 ReturnCode isolate(const std::vector<Chip>& i_chipList,
70 IsolationData& o_isoData) const;
Zane Shelley5a266612019-08-15 16:23:53 -050071}; // end class Isolator
72
73} // end namespace libhei