Embedded Template Library 1.0
Loading...
Searching...
No Matches
icache.h
Go to the documentation of this file.
1
2
3/******************************************************************************
4The MIT License(MIT)
5
6Embedded Template Library.
7https://github.com/ETLCPP/etl
8http://www.etlcpp.com
9
10Copyright(c) 2017 jwellbelove, rlindeman
11
12Permission is hereby granted, free of charge, to any person obtaining a copy
13of this software and associated documentation files(the "Software"), to deal
14in the Software without restriction, including without limitation the rights
15to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
16copies of the Software, and to permit persons to whom the Software is
17furnished to do so, subject to the following conditions :
18
19The above copyright notice and this permission notice shall be included in all
20copies or substantial portions of the Software.
21
22THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
25AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28SOFTWARE.
29******************************************************************************/
30
31//*****************************************************************************
32#error This header is in development. Do not use.
33//*****************************************************************************
34
35#ifndef __ETL_ICACHE__
36 #define __ETL_ICACHE__
37
38 #include "platform.h"
39 #include "delegate.h"
40
41 #include <utility>
42
43namespace etl
44{
48 template <typename TKey, typename TValue>
49 class icache
50 {
51 public:
52
57 icache()
58 : write_through(true)
59 , read_store(nullptr)
60 , write_store(nullptr)
61 {
62 }
63
68 virtual ~icache()
69 {
70 if (!write_through)
71 {
72 flush();
73 }
74 }
75
79 void set_read_function(etl::delegate<key_value_t&(void)> reader_)
80 {
81 read_store = reader;
82 }
83
87 void set_write_function(etl::delegate<void(const key_value_t&)> writer_)
88 {
89 write_store = writer;
90 }
91
95 void set_write_through(bool write_through_)
96 {
97 write_through = write_through_;
98 }
99
100 virtual const T& read(const TKey& key) const = 0;
102 virtual void write(const TKey& key,
103 const TValue& value) = 0;
105 virtual void flush() = 0;
107
108 protected:
109
110 typedef ETL_OR_STD::pair<TKey, TValue> key_value_t;
111
115
116 etl::delegate<key_value_t&(void)>* read_store;
118 etl::delegate<void(const key_value_t&)>* write_store;
120 }
121} // namespace etl
122
123#endif
Declaration.
Definition delegate_cpp03.h:191
bool write_through
Definition icache.h:112
etl::delegate< key_value_t &(void)> * read_store
Definition icache.h:116
virtual void flush()=0
virtual const T & read(const TKey &key) const =0
etl::delegate< void(const key_value_t &)> * write_store
Definition icache.h:118
virtual void write(const TKey &key, const TValue &value)=0
bitset_ext
Definition absolute.h:40