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
|
|
|
|
*
|
2012-01-25 00:03:36 +01:00
|
|
|
* Copyright (c) 2008-2012, Tomasz Sowa
|
2008-12-10 05:42:49 +01:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2011-01-23 15:15:30 +01:00
|
|
|
#ifndef headerfile_winix_core_dircontainer
|
|
|
|
#define headerfile_winix_core_dircontainer
|
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();
|
2010-11-04 17:46:19 +01:00
|
|
|
Iterator GetVar();
|
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);
|
|
|
|
|
2012-01-25 00:03:36 +01:00
|
|
|
ParentIterator ParentBegin(); // IMPROVE ME: may it should be renamed to ChildBegin() similarly as FindFirstChild() ?
|
2008-12-10 05:42:49 +01:00
|
|
|
ParentIterator ParentEnd();
|
|
|
|
ParentSizeType ParentSize();
|
|
|
|
bool ParentEmpty();
|
2011-01-05 22:24:11 +01:00
|
|
|
ParentIterator FindFirstChild(long parent);
|
|
|
|
ParentIterator NextChild(ParentIterator pi);
|
2008-12-10 05:42:49 +01:00
|
|
|
|
2010-11-21 01:19:17 +01:00
|
|
|
bool IsNameOfSpecialFolder(const std::wstring & name);
|
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;
|
|
|
|
|
2010-11-04 17:46:19 +01:00
|
|
|
// true if there is a var dir in the table
|
|
|
|
bool is_var;
|
|
|
|
|
|
|
|
// var
|
|
|
|
Iterator var_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
|
2010-11-21 01:19:17 +01:00
|
|
|
static std::wstring dir_etc, dir_var;
|
2008-12-10 05:42:49 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|