OSDN Git Service

64c845c9f3e3257449149307360fdcab57de674d
[mingw/mingw-get.git] / src / pkglist.h
1 #ifndef PKGLIST_H
2 /*
3  * pkglist.h
4  *
5  * $Id$
6  *
7  * Written by Keith Marshall <keithmarshall@users.sourceforge.net>
8  * Copyright (C) 2010, 2012, MinGW Project
9  *
10  *
11  * Declarations of the classes used to implement the package list
12  * viewers, for both CLI and GUI clients.
13  *
14  *
15  * This is free software.  Permission is granted to copy, modify and
16  * redistribute this software, under the provisions of the GNU General
17  * Public License, Version 3, (or, at your option, any later version),
18  * as published by the Free Software Foundation; see the file COPYING
19  * for licensing details.
20  *
21  * Note, in particular, that this software is provided "as is", in the
22  * hope that it may prove useful, but WITHOUT WARRANTY OF ANY KIND; not
23  * even an implied WARRANTY OF MERCHANTABILITY, nor of FITNESS FOR ANY
24  * PARTICULAR PURPOSE.  Under no circumstances will the author, or the
25  * MinGW Project, accept liability for any damages, however caused,
26  * arising from the use of this software.
27  *
28  */
29 #define PKGLIST_H  1
30
31 class pkgDirectory;
32
33 class pkgDirectoryViewerEngine
34 {
35   /* A minimal abstract base class, through which directory
36    * traversal methods of the following "pkgDirectory" class
37    * gain access to an appropriate handler in a specialised
38    * directory viewer class, (or any other class which may
39    * provide directory traversal hooks).  All such helper
40    * classes should derive from this base class, providing
41    * a "Dispatch" method as the directory traversal hook.
42    */
43   public:
44     virtual void Dispatch( pkgXmlNode * ) = 0;
45
46     pkgDirectory *EnumerateComponents( pkgXmlNode * );
47 };
48
49 #ifdef GUIMAIN_H
50 /*
51  * The following class is required only when implementing the
52  * graphical user interface; it is heavily dependent on graphical
53  * elements of the MS-Windows API.  Thus, we expose its declaration
54  * only when the including module expresses an intent to deploy
55  * such graphical elements, (as implied by prior inclusion of
56  * the guimain.h header, which this augments).
57  *
58  */
59 class pkgListViewMaker: public pkgDirectoryViewerEngine
60 {
61   /* A concrete specialization of the pkgDirectoryViewerEngine
62    * class, used to assemble the content of the records displayed
63    * in the list view pane of the graphical user interface.
64    */
65   public:
66     pkgListViewMaker( HWND );
67     virtual void Dispatch( pkgXmlNode * );
68     virtual void MarkScheduledActions( pkgActionItem * );
69     virtual void UpdateListView( void );
70
71   private:
72     HWND ListView;
73     LVITEM content;
74     inline bool GetItem( void );
75     void InsertItem( pkgXmlNode *, char * );
76     void UpdateItem( char *, bool = false );
77     char *package_name;
78 };
79
80 #endif /* GUIMAIN_H */
81
82 class pkgDirectory
83 {
84   /* A locally defined class, used to manage a list of package
85    * or component package references in the form of an unbalanced
86    * binary tree, such that an in-order traversal will produce
87    * an alpha-numerically sorted package list.
88    */
89   public:
90     pkgDirectory( pkgXmlNode * );
91     pkgDirectory *Insert( const char *, pkgDirectory * );
92     void InOrder( pkgDirectoryViewerEngine * );
93     ~pkgDirectory();
94
95   protected:
96     pkgXmlNode *entry;
97     pkgDirectory *prev;
98     pkgDirectory *next;
99 };
100
101 /* The following helper function is used to retrieve release availability
102  * and installation status attributes for any specified package, from the
103  * XML database, returning specifications for the latest available release
104  * and the installed release, if any, in the to_install and the to_remove
105  * selection fields of the passed pkgActionItem structure respectively.
106  */
107 EXTERN_C pkgXmlNode *pkgGetStatus( pkgXmlNode *, pkgActionItem * );
108
109 #endif /* PKGLIST_H: $RCSfile$: end of file */