2008-12-10 05:42:49 +01:00
|
|
|
/*
|
|
|
|
* This file is a part of CMSLU -- Content Management System like Unix
|
|
|
|
* and is not publicly distributed
|
|
|
|
*
|
|
|
|
* Copyright (c) 2008, Tomasz Sowa
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef headerfiledircontainer
|
|
|
|
#define headerfiledircontainer
|
|
|
|
|
2009-02-06 14:12:03 +01:00
|
|
|
#include <list>
|
2008-12-10 05:42:49 +01:00
|
|
|
#include <map>
|
|
|
|
#include "item.h"
|
|
|
|
#include "log.h"
|
|
|
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
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);
|
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);
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
// 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
|
|
|
|
2008-12-10 05:42:49 +01:00
|
|
|
// indexes
|
|
|
|
TableId table_id;
|
|
|
|
TableParent table_parent;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|