Skip to content

Commit

Permalink
- last compiling
Browse files Browse the repository at this point in the history
  • Loading branch information
neel committed Oct 13, 2020
1 parent b919adc commit 8c97f87
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ cmake-build-*
docs.sphinx/bin
docs.sphinx/lib
docs.sphinx/pyvenv.cfg
docs/_build
34 changes: 17 additions & 17 deletions includes/udho/cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -292,10 +292,10 @@ struct engine: StorageT{
}
};

template <typename KeyT, template<typename, typename> class StorageT = storage::memory>
struct master: public engine<StorageT<KeyT, void>>{
template <typename KeyT>
struct master: public engine<storage::memory<KeyT>>{
typedef KeyT key_type;
typedef engine<StorageT<KeyT, void>> storage_type;
typedef engine<storage::memory<KeyT>> storage_type;

bool issued(const key_type& key) const{
return storage_type::exists(key);
Expand All @@ -305,8 +305,8 @@ struct master: public engine<StorageT<KeyT, void>>{
}
};

template <typename KeyT, typename T, template<typename, typename> class StorageT = storage::memory>
struct registry: public engine<StorageT<KeyT, T>>{
template <typename KeyT, typename T>
struct registry: public engine<storage::memory<KeyT, T>>{
typedef registry<KeyT, T> self_type;

registry() = default;
Expand All @@ -318,7 +318,7 @@ struct registry: public engine<StorageT<KeyT, T>>{

};

template <typename KeyT, template<typename, typename> class StorageT = storage::memory, typename... T>
template <typename KeyT, typename... T>
struct shadow;

/**
Expand All @@ -332,36 +332,36 @@ struct shadow;
* store.exists<user>();
* \endcode
*/
template <typename KeyT, template<typename, typename> class StorageT = storage::memory, typename... T>
struct store: master<KeyT, StorageT>, registry<KeyT, T, StorageT>...{
template <typename KeyT, typename... T>
struct store: master<KeyT>, registry<KeyT, T>...{
typedef KeyT key_type;
typedef master<KeyT, StorageT> master_type;
typedef store<KeyT, StorageT, T...> self_type;
typedef shadow<KeyT, StorageT, T...> shadow_type;
typedef master<KeyT> master_type;
typedef store<KeyT, T...> self_type;
typedef shadow<KeyT, T...> shadow_type;

store() = default;
store(const self_type&) = delete;
store(self_type&&) = default;

template <typename V>
bool exists(const key_type& key) const{
return master_type::issued(key) && registry<KeyT, V, StorageT>::exists(key);
return master_type::issued(key) && registry<KeyT, V>::exists(key);
}
template <typename V>
const V& get(const key_type& key, const V& def=V()) const{
if(master_type::issued(key)){
return registry<KeyT, V, StorageT>::at(key);
return registry<KeyT, V>::at(key);
}else{
return def;
}
}
template <typename V>
V& at(const key_type& key){
return registry<KeyT, V, StorageT>::at(key);
return registry<KeyT, V>::at(key);
}
template <typename V>
void insert(const key_type& key, const V& value){
registry<KeyT, V, StorageT>::insert(key, value);
registry<KeyT, V>::insert(key, value);
if(!master_type::issued(key)){
master_type::issue(key);
}
Expand All @@ -372,14 +372,14 @@ struct store: master<KeyT, StorageT>, registry<KeyT, T, StorageT>...{
}
template <typename V>
std::size_t size(const key_type& key) const{
return registry<KeyT, V, StorageT>::size(key);
return registry<KeyT, V>::size(key);
}
bool remove(){
return master_type::remove();
}
template <typename V>
bool remove(const key_type& key){
if(registry<KeyT, V, StorageT>::remove(key)){
if(registry<KeyT, V>::remove(key)){
master_type::update();
return true;
}
Expand Down

0 comments on commit 8c97f87

Please sign in to comment.