1 // This file is part of a terminal todo application.
3 // Copyright (C) 2006 by Mike Sharov <msharov@users.sourceforge.net>
4 // This file is free software, distributed under the MIT License.
9 #ifndef TDDOC_H_31474BC008E2711A4DD60C960CFF3439
10 #define TDDOC_H_31474BC008E2711A4DD60C960CFF3439
14 /// \class CTodoDocument tddoc.h tddoc.h
16 /// Contains the list of todo entries and the table of dependencies between
17 /// them. Provides accessors for modification of the list and the table.
19 class CTodoDocument
: public CDocument
{
21 typedef set
<CTodoItem
> todoset_t
;
22 typedef const CTodoItem
& rcitem_t
;
23 typedef todoset_t::iterator iitem_t
;
24 typedef todoset_t::const_iterator icitem_t
;
25 typedef tddepmap_t::iterator idep_t
;
26 typedef tddepmap_t::const_iterator icdep_t
;
27 typedef CTodoItem::id_t itemid_t
;
28 typedef const string
& rcfname_t
;
31 virtual void read (istream
& is
);
32 virtual void write (ostream
& os
) const;
33 virtual size_t stream_size (void) const;
34 virtual void Open (rcfname_t filename
);
35 virtual void Save (void);
36 icitem_t
FindItem (itemid_t id
) const;
37 inline iitem_t
FindItem (itemid_t id
) { return (const_cast<iitem_t
>(const_cast<const CTodoDocument
*>(this)->FindItem(id
))); }
38 void ItemDeps (itemid_t id
, tddepmap_t
& m
) const;
39 itemid_t
CreateItem (void);
40 void LinkItem (itemid_t id
, itemid_t parent
);
41 void UpdateItem (rcitem_t v
);
42 void UnlinkItem (icdep_t id
);
44 inline itemid_t
GetNextItemId (void) const;
45 void VerifyData (void);
46 bool VisibleOrderLess (const CTodoDep
& d1
, const CTodoDep
& d2
) const;
47 void ResortItemDeps (idep_t first
, idep_t last
) const;
48 void UpdateItemProgress (idep_t first
, idep_t last
);
49 void UpdateCompleteStatus (itemid_t dep
);
51 todoset_t m_Todos
; ///< List of all entries.
52 tddepmap_t m_Deps
; ///< List of dependencies between todos.