winix/plugins/menu/cache.h

77 lines
1007 B
C++
Executable File

/*
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2012-2013, Tomasz Sowa
* All rights reserved.
*
*/
#ifndef headerfile_winix_plugins_menu_cache
#define headerfile_winix_plugins_menu_cache
#include <string>
#include <vector>
#include <list>
#include "core/item.h"
#include "core/dirs.h"
namespace Menu
{
struct MenuItem
{
long id; // item id
std::wstring url;
std::wstring subject;
PT::Space meta;
Item::Type type;
int file_type;
};
struct CacheItem
{
long dir_id;
int param;
std::vector<MenuItem> menu_items;
std::wstring dir; // without the last slash
CacheItem()
{
dir_id = -1;
param = -1;
}
};
class Cache
{
public:
void SetDirs(Dirs * pdirs);
CacheItem * Get(long dir_id, int param);
CacheItem * Insert(long dir_id, int param);
void Remove(long dir_id);
void Clear();
private:
Dirs * dirs;
typedef std::list<CacheItem> Tab;
Tab tab;
CacheItem empty_cache_item;
};
} // namespace
#endif