1 // This file is part of the utui library, a terminal UI framework.
3 // Copyright (C) 2006 by Mike Sharov <msharov@users.sourceforge.net>
4 // This file is free software, distributed under the MIT License.
9 #ifndef DOC_H_7BBE3FAF41D4C26A3BB1D8E8391176E8
10 #define DOC_H_7BBE3FAF41D4C26A3BB1D8E8391176E8
14 /// \class CDocument doc.h doc.h
16 /// Documents are the data storage side of the document-view architecture.
17 /// Any window can serve as a view to display the data it obtains by using
18 /// accessor functions of objects derived from CDocument through the pointer
19 /// sent to it in OnUpdate.
21 class CDocument
: public CDocumentClient
{
23 typedef const string
& rcfname_t
;
24 typedef CDocumentClient
* pview_t
;
27 inline virtual ~CDocument (void) { }
28 void RegisterView (pview_t pView
);
29 void UnregisterView (pview_t pView
);
30 virtual void Open (rcfname_t filename
);
31 virtual void Close (void);
32 inline rcfname_t
Filename (void) const { return (m_Filename
); }
33 inline virtual void read (istream
&) { }
34 inline virtual void write (ostream
&) const { }
35 inline virtual size_t stream_size (void) const { return (0); }
37 void UpdateAllViews (void);
39 typedef vector
<pview_t
> vwvec_t
;
41 vwvec_t m_Views
; ///< Registered views.
42 string m_Filename
; ///< Name of the currently open file.
45 STD_STREAMABLE (CDocument
)