rewritten: plugin 'menu'
now we have a cache for the plugin (this limits the number of database requests) added: to plugin 'menu' menu_dir_tab can have a 'current' parameter (first argument) (it uses the last path from the previous menu_dir_tab) changed: updated to the new EZC api added: new message to plugins: WINIX_DIR_ADDED git-svn-id: svn://ttmath.org/publicrep/winix/trunk@808 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
75
plugins/menu/cache.h
Executable file
75
plugins/menu/cache.h
Executable file
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2012, 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;
|
||||
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
|
Reference in New Issue
Block a user