2008-12-10 05:42:49 +01:00
|
|
|
/*
|
2010-02-28 01:08:10 +01:00
|
|
|
* This file is a part of Winix
|
2008-12-10 05:42:49 +01:00
|
|
|
* and is not publicly distributed
|
|
|
|
*
|
2010-02-28 22:33:06 +01:00
|
|
|
* Copyright (c) 2008-2010, Tomasz Sowa
|
2008-12-10 05:42:49 +01:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2009-04-21 22:50:55 +02:00
|
|
|
#ifndef headerfilecmslucoredircontainer
|
|
|
|
#define headerfilecmslucoredircontainer
|
2008-12-10 05:42:49 +01:00
|
|
|
|
2009-02-06 14:12:03 +01:00
|
|
|
#include <list>
|
2008-12-10 05:42:49 +01:00
|
|
|
#include <map>
|
|
|
|
#include "item.h"
|
2009-04-21 22:50:55 +02:00
|
|
|
|
2008-12-10 05:42:49 +01:00
|
|
|
|
|
|
|
|
|
|
|
class DirContainer
|
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
2009-02-06 14:12:03 +01:00
|
|
|
typedef std::list<Item> Table;
|
|
|
|
typedef Table::iterator Iterator;
|
|
|
|
typedef Table::size_type SizeType;
|
2008-12-10 05:42:49 +01:00
|
|
|
|
|
|
|
typedef std::map<long, Iterator> TableId;
|
|
|
|
typedef std::multimap<long, Iterator> TableParent;
|
|
|
|
typedef TableParent::iterator ParentIterator;
|
|
|
|
typedef TableParent::size_type ParentSizeType;
|
|
|
|
|
|
|
|
|
|
|
|
DirContainer();
|
|
|
|
|
2008-12-22 17:03:03 +01:00
|
|
|
Iterator GetRoot();
|
2009-11-16 00:55:11 +01:00
|
|
|
Iterator GetEtc();
|
2008-12-22 17:03:03 +01:00
|
|
|
|
2008-12-10 05:42:49 +01:00
|
|
|
Iterator Begin();
|
|
|
|
Iterator End();
|
|
|
|
SizeType Size();
|
|
|
|
bool Empty();
|
2009-04-20 00:13:21 +02:00
|
|
|
Iterator PushBack(const Item & item);
|
2010-03-15 02:47:26 +01:00
|
|
|
bool ChangeParent(long dir_id, long new_parent_id);
|
2008-12-10 05:42:49 +01:00
|
|
|
void Clear();
|
|
|
|
|
|
|
|
Iterator FindId(long id);
|
|
|
|
|
2009-02-06 14:12:03 +01:00
|
|
|
bool DelById(long id);
|
|
|
|
|
2008-12-10 05:42:49 +01:00
|
|
|
ParentIterator ParentBegin();
|
|
|
|
ParentIterator ParentEnd();
|
|
|
|
ParentSizeType ParentSize();
|
|
|
|
bool ParentEmpty();
|
|
|
|
ParentIterator FindFirstParent(long parent);
|
|
|
|
ParentIterator NextParent(ParentIterator pi);
|
|
|
|
|
2009-11-16 00:55:11 +01:00
|
|
|
void FindSpecialFolders();
|
2008-12-10 05:42:49 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
2009-11-16 18:43:23 +01:00
|
|
|
void CheckSpecialFolder(const Item & item, Iterator iter);
|
|
|
|
|
2008-12-10 05:42:49 +01:00
|
|
|
// main table with dirs
|
|
|
|
Table table;
|
|
|
|
|
2008-12-22 17:03:03 +01:00
|
|
|
// true if there is a root dir in the table
|
|
|
|
bool is_root;
|
|
|
|
|
2009-02-06 14:12:03 +01:00
|
|
|
// root
|
|
|
|
Iterator root_iter;
|
2008-12-22 17:03:03 +01:00
|
|
|
|
2009-11-16 00:55:11 +01:00
|
|
|
// true if there is a etc dir in the table
|
|
|
|
bool is_etc;
|
|
|
|
|
|
|
|
// etc
|
|
|
|
Iterator etc_iter;
|
|
|
|
|
2008-12-10 05:42:49 +01:00
|
|
|
// indexes
|
|
|
|
TableId table_id;
|
|
|
|
TableParent table_parent;
|
2009-11-16 18:43:23 +01:00
|
|
|
|
|
|
|
// names of folders
|
|
|
|
static std::string dir_etc;
|
2008-12-10 05:42:49 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|