blob: 1cc29b70add457b96255ff04b6018349e1ac70d7 [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. */
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 Shelleyb406de42019-09-09 16:10:38 -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