Karl Zhang | 3de5ab1 | 2021-05-31 11:45:48 +0800 | [diff] [blame] | 1 | /* |
Nik Dewally | 841612a | 2024-07-22 15:27:43 +0100 | [diff] [blame^] | 2 | * Copyright (c) 2019-2024, Arm Limited. All rights reserved. |
Karl Zhang | 3de5ab1 | 2021-05-31 11:45:48 +0800 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | * |
| 6 | */ |
| 7 | |
| 8 | #ifndef PSA_ASSET_HPP |
| 9 | #define PSA_ASSET_HPP |
| 10 | |
Nik Dewally | 841612a | 2024-07-22 15:27:43 +0100 | [diff] [blame^] | 11 | #include "class_forwards.hpp" |
Karl Zhang | 3de5ab1 | 2021-05-31 11:45:48 +0800 | [diff] [blame] | 12 | #include <string> |
| 13 | #include <vector> |
| 14 | #include <cstdint> |
| 15 | |
| 16 | /* This project's header files #including other project headers quickly becomes |
| 17 | unrealistically complicated. The only solution is for each .cpp to include |
| 18 | the headers it needs. */ |
| 19 | |
| 20 | using namespace std; |
| 21 | |
| 22 | class psa_asset |
| 23 | { |
| 24 | public: |
| 25 | /* Data members -- not all PSA assets have all of these, but they need to be |
| 26 | accessible polymorphically via a psa_asset iterator: */ |
| 27 | set_data_info set_data; |
| 28 | /* For a PSA-asset tracker, this is really more about an asset's |
| 29 | on-going, real-time asset data value than about *setting* its data |
| 30 | value. On a template_line or a psa_call, it's about setting its |
| 31 | value at one particular time. */ |
| 32 | expect_info exp_data; |
| 33 | /* For now at least, this is here only for its n_exp_vars member, to |
| 34 | keep track of how many expected-data variables in the test. */ |
| 35 | asset_name_id_info asset_info; // everything about the asset(s) for this line |
| 36 | key_policy_info policy; // (specific to crypto, but have to put this here) |
| 37 | vector<int> template_ref; |
| 38 | // list of template line #s that reference this asset |
| 39 | vector<psa_call> call_ref; // list of PSA calls that reference this asset |
| 40 | string handle_str; // the text name of the key's "handle" |
| 41 | bool asset_name_specified; |
| 42 | /* true if the template specified the asset_name, as opposed to us |
| 43 | having inferred it. */ |
| 44 | // Methods: |
| 45 | void set_name (string set_val); |
| 46 | string get_name (void); |
| 47 | virtual bool simulate (void); |
| 48 | /* simulate() tells this asset to react to its current state information. |
| 49 | Initially, this won't really do much, but will allow assets to react |
| 50 | to each other, if that is relevant. It returns true if anything |
| 51 | in the state of the asset changed, in which case all assets' simulate() |
| 52 | methods will be invoked again to react again. That will repeat until |
| 53 | all assets read a quiescent state. */ |
| 54 | psa_asset(); // (constructor) |
| 55 | ~psa_asset(); |
| 56 | |
| 57 | protected: |
| 58 | // Data members: |
| 59 | // These are initially copied over from the call (or possibly template line): |
| 60 | string data; // String describing current data value. |
| 61 | string asset_name; // human-meaningful name |
| 62 | static long unique_id_counter; // counts off unique IDs for assets |
| 63 | // Methods: |
| 64 | |
| 65 | private: |
| 66 | // Data members: |
| 67 | // Methods: |
| 68 | }; |
| 69 | |
| 70 | #endif // PSA_ASSET_HPP |