C++ Device API Reference Manual
Reference documentation for the Simics C++ Device API.
 
Loading...
Searching...
No Matches
expression_vector.h
Go to the documentation of this file.
1/*
2 © 2023 Intel Corporation
3
4 This software and the related documents are Intel copyrighted materials, and
5 your use of them is governed by the express license under which they were
6 provided to you ("License"). Unless the License provides otherwise, you may
7 not use, modify, copy, publish, distribute, disclose or transmit this software
8 or the related documents without Intel's prior written permission.
9
10 This software and the related documents are provided as is, with no express or
11 implied warranties, other than those that are expressly stated in the License.
12*/
13
14//-*- C++ -*-
15
16#ifndef CPP_API_EXTENSIONS_SRC_SME_EXPRESSIONS_EXPRESSION_VECTOR_H
17#define CPP_API_EXTENSIONS_SRC_SME_EXPRESSIONS_EXPRESSION_VECTOR_H
18
19#include <functional>
20#include <map>
21#include <string>
22
24
25namespace sme {
26
27class expression;
28
37public:
38
43 std::map< std::string, std::function<void()> > m_actions;
44
49 std::function<void()> m_lambda;
50
57 _always_inline bool has_targets() { return( m_actions.size() > 0); }
58
65 _always_inline bool is_bound() { return( m_lambda != nullptr); }
66
72 _always_inline void execute( std::function< void()> _func) { m_lambda = _func; }
73
79 if( is_bound()) m_lambda();
80 if( has_targets()) {
81 std::map< std::string, std::function<void()> >::iterator mit;
82 for( mit = m_actions.begin(); mit != m_actions.end(); mit++) {
83 mit->second();
84 }
85 }
86 }
87
88protected:
89 friend class sme::expression;
90
91};
92
93} // namespace sme
94
95#endif
#define _keep_hot
Definition: _inline.h:32
#define _always_inline
Definition: _inline.h:30
vector of execution resulting from expression evaluation.
Definition: expression_vector.h:36
_always_inline bool is_bound()
is the lambda defined/bound
Definition: expression_vector.h:65
friend class sme::expression
Definition: expression_vector.h:89
_keep_hot void process()
processes (executes) sensitivities
Definition: expression_vector.h:78
_always_inline void execute(std::function< void()> _func)
define/bind the lambda (this will be executed)
Definition: expression_vector.h:72
std::map< std::string, std::function< void()> > m_actions
holds sensitivity to other expressions
Definition: expression_vector.h:43
std::function< void()> m_lambda
placeholder for lambda
Definition: expression_vector.h:49
_always_inline bool has_targets()
has sensitivity targets (depends on size of map)
Definition: expression_vector.h:57
Definition: expression_vector.h:25