Loading...
Searching...
No Matches
icache.h
Go to the documentation of this file.
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
http://www.etlcpp.com
Copyright(c) 2017 jwellbelove, rlindeman
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
//*****************************************************************************
#error This header is in development. Do not use.
//*****************************************************************************
#ifndef __ETL_ICACHE__
#define __ETL_ICACHE__
#include "platform.h"
#include "delegate.h"
#include <utility>
namespace etl
{
template <typename TKey, typename TValue>
class icache
{
public:
icache()
: write_through(true)
, read_store(nullptr)
, write_store(nullptr)
{
}
virtual ~icache()
{
if (!write_through)
{
flush();
}
}
void set_read_function(etl::delegate<key_value_t&(void)> reader_)
{
read_store = reader;
}
void set_write_function(etl::delegate<void(const key_value_t&)> writer_)
{
write_store = writer;
}
void set_write_through(bool write_through_)
{
write_through = write_through_;
}
virtual const T& read(const TKey& key) const = 0;
virtual void write(const TKey& key,
const TValue& value) = 0;
virtual void flush() = 0;
protected:
typedef ETL_OR_STD::pair<TKey, TValue> key_value_t;
bool write_through;
etl::delegate<key_value_t&(void)>* read_store;
etl::delegate<void(const key_value_t&)>* write_store;
}
} // namespace etl
#endif
etl::delegate
Declaration.
Definition delegate_cpp03.h:191
etl::icache::write_through
bool write_through
Definition icache.h:112
etl::icache::read_store
etl::delegate< key_value_t &(void)> * read_store
Definition icache.h:116
etl::icache::flush
virtual void flush()=0
etl::icache::read
virtual const T & read(const TKey &key) const =0
etl::icache::write_store
etl::delegate< void(const key_value_t &)> * write_store
Definition icache.h:118
etl::icache::write
virtual void write(const TKey &key, const TValue &value)=0
delegate.h
etl
Definition absolute.h:40
platform.h