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