winix/core/dircontainer.h

104 lines
1.9 KiB
C++
Executable File

/*
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2014, Tomasz Sowa
* All rights reserved.
*
*/
#ifndef headerfile_winix_core_dircontainer
#define headerfile_winix_core_dircontainer
#include <list>
#include <map>
#include "item.h"
namespace Winix
{
class DirContainer
{
public:
typedef std::list<Item> Table;
typedef Table::iterator Iterator;
typedef Table::size_type SizeType;
typedef std::map<long, Iterator> TableId;
typedef std::multimap<long, Iterator> TableParent;
typedef TableParent::iterator ParentIterator;
typedef TableParent::size_type ParentSizeType;
DirContainer();
Iterator GetRoot();
Iterator GetEtc();
Iterator GetVar();
Iterator Begin();
Iterator End();
SizeType Size();
bool Empty();
Iterator PushBack(const Item & item);
bool ChangeParent(long dir_id, long new_parent_id);
void Clear();
Iterator FindId(long id);
bool DelById(long id);
ParentIterator ParentBegin(); // IMPROVE ME: may it should be renamed to ChildBegin() similarly as FindFirstChild() ?
ParentIterator ParentEnd();
ParentSizeType ParentSize();
bool ParentEmpty();
ParentIterator FindFirstChild(long parent);
ParentIterator NextChild(ParentIterator pi);
bool IsNameOfSpecialFolder(const std::wstring & name);
void FindSpecialFolders();
private:
void CheckSpecialFolder(const Item & item, Iterator iter);
// main table with dirs
Table table;
// true if there is a root dir in the table
bool is_root;
// root
Iterator root_iter;
// true if there is a etc dir in the table
bool is_etc;
// etc
Iterator etc_iter;
// true if there is a var dir in the table
bool is_var;
// var
Iterator var_iter;
// indexes
TableId table_id;
TableParent table_parent;
// names of folders
static std::wstring dir_etc, dir_var;
};
} // namespace Winix
#endif