scc  2022.4.0
SystemC components library
cci_broker.h
1 /*******************************************************************************
2  * Copyright 2022 MINRES Technologies GmbH
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *******************************************************************************/
16 
17 #ifndef _SYSC_SCC_CCI_BROKER_H_
18 #define _SYSC_SCC_CCI_BROKER_H_
19 
20 #include <cci_utils/broker.h>
21 #include <regex>
22 #include <string>
23 #include <unordered_map>
24 #include <unordered_set>
25 #include <vector>
26 
27 namespace scc {
28 class cci_broker : public cci_utils::consuming_broker {
29  std::unordered_set<std::string> expose;
30 
31  bool has_parent;
32  cci::cci_broker_if& m_parent;
33 
34  cci::cci_broker_if& get_parent_broker() {
35  if(sc_core::sc_get_current_object()) {
36  has_parent = true;
37  return unwrap_broker(cci::cci_get_broker());
38  } else {
39  // We ARE the global broker
40  has_parent = false;
41  return *this;
42  }
43  }
44 
45  bool sendToParent(const std::string& parname) const;
46 
47  void insert_matching_preset_value(const std::string& parname);
48 
49  struct wildcard_entry {
50  std::regex rr;
51  cci::cci_value value;
52  cci::cci_originator originator;
53  };
54  std::unordered_map<std::string, wildcard_entry> wildcard_presets;
55  std::unordered_map<std::string, std::regex> wildcard_locks;
56 
57 public:
58  cci::cci_originator get_value_origin(const std::string& parname) const override;
59 
60  cci_broker(const std::string& name);
61 
62  ~cci_broker();
63 
64  bool has_preset_value(const std::string& parname) const override;
65 
66  cci::cci_originator get_preset_value_origin(const std::string& parname) const override;
67 
68  cci::cci_value get_preset_cci_value(const std::string& parname) const override;
88  void set_preset_cci_value(const std::string& parname, const cci::cci_value& cci_value, const cci::cci_originator& originator) override;
89 
110  void lock_preset_value(const std::string& parname) override;
111 
112  cci::cci_value get_cci_value(const std::string& parname, const cci::cci_originator& originator = cci::cci_originator()) const override;
113 
114  cci::cci_param_untyped_handle get_param_handle(const std::string& parname, const cci::cci_originator& originator) const override;
115 
116  std::vector<cci::cci_param_untyped_handle> get_param_handles(const cci::cci_originator& originator) const override;
117 
118  void add_param(cci::cci_param_if* par) override;
119 
120  void remove_param(cci::cci_param_if* par) override;
121 
122  bool is_global_broker() const override;
123 };
124 
125 } // namespace scc
126 #endif // _SYSC_SCC_CCI_BROKER_H_
void lock_preset_value(const std::string &parname) override
Lock a parameter's preset value.
Definition: cci_broker.cpp:167
void set_preset_cci_value(const std::string &parname, const cci::cci_value &cci_value, const cci::cci_originator &originator) override
Set a parameter's preset value.
Definition: cci_broker.cpp:148
SCC SystemC utilities.