+2012-06-02 Keith Marshall <keithmarshall@users.sourceforge.net>
+
+ Refactor API to facilitate implementation of GUI ListView hooks.
+
+ * src/pkgkeys.h (title_key, description_key): Declare them.
+ * src/pkgkeys.c (title_key, description_key): Define them; relocate...
+ * src/pkgshow.cpp (pkgDirectoryViewer::EmitDescription): ...from here.
+ (pkgXmlDocument::CalalogueAllPackages): New public method; factor...
+ (pkgXmlDocument::DisplayPackageInfo): ...from here, whence use it.
+ (pkgDirectoryViewerEngine::EnumerateComponents): New private method;
+ implement as a concrete method of this abstract base class; factor...
+ (pkgDirectoryViewer::Dispatch): ...from original inline implementation
+ within this method of the concrete derived class, whence use it.
+ (pkgDirectoryViewerEngine, pkgDirectory): Factor class declarations...
+ * src/pkglist.h: ...into this new header file; include it.
+
+ * src/pkgbase.h (pkgDirectory): Add forward class declaration.
+ (pkgXmlDocument::CatalogueAllPackages): Declare it.
+
2012-05-02 Keith Marshall <keithmarshall@users.sourceforge.net>
Update help text to document package version selection capability.
/* Begin class declarations.
*/
class pkgSpecs;
+class pkgDirectory;
class pkgXmlNode : public TiXmlElement
{
*/
pkgXmlNode* FindPackageByName( const char*, const char* = NULL );
- /* Method to display information about packages.
+ /* Methods to retrieve and display information about packages.
*/
+ pkgDirectory *CatalogueAllPackages();
void DisplayPackageInfo( int, char** );
/* Method to resolve the dependencies of a specified package,
const char *class_key = "class";
const char *component_key = "component";
const char *defaults_key = "defaults";
+const char *description_key = "description";
const char *dirname_key = "dir";
const char *download_key = "download";
const char *download_host_key = "download-host";
const char *sysmap_key = "system-map";
const char *sysroot_key = "sysroot";
const char *tarname_key = "tarname";
+const char *title_key = "title";
const char *uri_key = "uri";
/* Some standard values, which may be associated with certain
* $Id$
*
* Written by Keith Marshall <keithmarshall@users.sourceforge.net>
- * Copyright (C) 2010, MinGW Project
+ * Copyright (C) 2010, 2012, MinGW Project
*
*
* Public declarations of the global definitions for the string
EXTERN_C_DECL const char *class_key;
EXTERN_C_DECL const char *component_key;
EXTERN_C_DECL const char *defaults_key;
+EXTERN_C_DECL const char *description_key;
EXTERN_C_DECL const char *dirname_key;
EXTERN_C_DECL const char *download_key;
EXTERN_C_DECL const char *download_host_key;
EXTERN_C_DECL const char *sysmap_key;
EXTERN_C_DECL const char *sysroot_key;
EXTERN_C_DECL const char *tarname_key;
+EXTERN_C_DECL const char *title_key;
EXTERN_C_DECL const char *uri_key;
/* Some standard values, which may be associated with certain
--- /dev/null
+#ifndef PKGLIST_H
+/*
+ * pkglist.h
+ *
+ * $Id$
+ *
+ * Written by Keith Marshall <keithmarshall@users.sourceforge.net>
+ * Copyright (C) 2010, 2012, MinGW Project
+ *
+ *
+ * Declarations of the classes used to implement the package list
+ * viewers, for both CLI and GUI clients.
+ *
+ *
+ * This is free software. Permission is granted to copy, modify and
+ * redistribute this software, under the provisions of the GNU General
+ * Public License, Version 3, (or, at your option, any later version),
+ * as published by the Free Software Foundation; see the file COPYING
+ * for licensing details.
+ *
+ * Note, in particular, that this software is provided "as is", in the
+ * hope that it may prove useful, but WITHOUT WARRANTY OF ANY KIND; not
+ * even an implied WARRANTY OF MERCHANTABILITY, nor of FITNESS FOR ANY
+ * PARTICULAR PURPOSE. Under no circumstances will the author, or the
+ * MinGW Project, accept liability for any damages, however caused,
+ * arising from the use of this software.
+ *
+ */
+#define PKGLIST_H 1
+
+class pkgDirectory;
+
+class pkgDirectoryViewerEngine
+{
+ /* A minimal abstract base class, through which directory
+ * traversal methods of the following "pkgDirectory" class
+ * gain access to an appropriate handler in a specialised
+ * directory viewer class, (or any other class which may
+ * provide directory traversal hooks). All such helper
+ * classes should derive from this base class, providing
+ * a "Dispatch" method as the directory traversal hook.
+ */
+ public:
+ virtual void Dispatch( pkgXmlNode * ) = 0;
+
+ pkgDirectory *EnumerateComponents( pkgXmlNode * );
+};
+
+class pkgDirectory
+{
+ /* A locally defined class, used to manage a list of package
+ * or component package references in the form of an unbalanced
+ * binary tree, such that an in-order traversal will produce
+ * an alpha-numerically sorted package list.
+ */
+ public:
+ pkgDirectory( pkgXmlNode * );
+ pkgDirectory *Insert( const char *, pkgDirectory * );
+ void InOrder( pkgDirectoryViewerEngine * );
+ ~pkgDirectory();
+
+ protected:
+ pkgXmlNode *entry;
+ pkgDirectory *prev;
+ pkgDirectory *next;
+};
+
+#endif /* PKGLIST_H: $RCSfile$: end of file */
* $Id$
*
* Written by Keith Marshall <keithmarshall@users.sourceforge.net>
- * Copyright (C) 2009, 2010, MinGW Project
+ * Copyright (C) 2009, 2010, 2012, MinGW Project
*
*
* Implementation of the classes and methods required to support the
#include "pkgbase.h"
#include "pkgkeys.h"
+#include "pkglist.h"
#include "dmh.h"
return curr;
}
-class pkgDirectoryViewerEngine
-{
- /* A minimal abstract base class, through which directory
- * traversal methods of the following "pkgDirectory" class
- * gain access to an appropriate handler in a specialised
- * directory viewer class, (or any other class which may
- * provide directory traversal hooks). All such helper
- * classes should derive from this base class, providing
- * a "Dispatch" method as the directory traversal hook.
- */
- public:
- virtual void Dispatch( pkgXmlNode* ) = 0;
-#if 0
- pkgDirectoryViewerEngine()
- {
- for( int i = 1; i < 9; i++ ) printf( "%10d", i ); putchar( '\n' );
- for( int i = 1; i < 9; i++ ) printf( "1234567890" ); putchar( '\n' );
- }
-#endif
-};
-
-class pkgDirectory
-{
- /* A locally defined class, used to manage a list of package
- * or component package references in the form of an unbalanced
- * binary tree, such that an in-order traversal will produce
- * an alpha-numerically sorted package list.
- */
- public:
- pkgDirectory( pkgXmlNode* );
- pkgDirectory *Insert( const char*, pkgDirectory* );
- void InOrder( pkgDirectoryViewerEngine* );
- ~pkgDirectory();
-
- protected:
- pkgXmlNode *entry;
- pkgDirectory *prev;
- pkgDirectory *next;
-};
-
/* Constructor...
*/
pkgDirectory::pkgDirectory( pkgXmlNode *item ):
*/
int offset = 0;
- /* These XML element and attribute identification keys should
+ /* This XML element and attribute identification key should
* perhaps be defined in the pkgkeys.h header; once more, for
- * the time being we simply define them locally.
+ * the time being we simply define it locally.
*/
- const char *title_key = "title";
- const char *description_key = "description";
const char *paragraph_key = "paragraph";
/* The procedure is recursive, selecting description elements
/* The selected entity is a full package;
* create an auxiliary directory...
*/
- pkgDirectory *dir = NULL;
- pkgXmlNode *cpt = entry->FindFirstAssociate( component_key );
- while( cpt != NULL )
- {
- /* ...in which we enumerate its components.
- */
- dir = dir->Insert( class_key, new pkgDirectory( cpt ) );
- cpt = cpt->FindNextAssociate( component_key );
- }
+ pkgDirectory *dir = EnumerateComponents( entry );
/* Signalling that a component list is to be included...
*/
}
else
- {
/* No arguments were specified; interpret this as a request
* to display information pertaining to all known packages in
* the current mingw-get repository's universe, thus...
*/
- pkgXmlNode *grp = GetRoot()->FindFirstAssociate( package_collection_key );
- while( grp != NULL )
- {
- /* ...for each known package collection...
- */
- pkgXmlNode *pkg = grp->FindFirstAssociate( package_key );
- while( pkg != NULL )
- {
- /* ...add an entry for each included package
- * into the print-out directory...
- */
- dir = dir->Insert( name_key, new pkgDirectory( pkg ) );
- /*
- * ...enumerating each and every package...
- */
- pkg = pkg->FindNextAssociate( package_key );
- }
- /* ...then repeat for the next package collection,
- * if any.
- */
- grp = grp->FindNextAssociate( package_collection_key );
- }
- }
+ dir = CatalogueAllPackages();
/* Regardless of how the print-out directory was compiled,
* we hand it off to the common viewer, for output.
delete dir;
}
+pkgDirectory *pkgXmlDocument::CatalogueAllPackages()
+{
+ /* A helper method for compiling a catalogue of all available packages,
+ * into a linked list of collated pkgDirectory class instances.
+ *
+ * FIXME: This will eventually need to support filtering of the result,
+ * based on a package group category specification.
+ */
+ pkgDirectory *dir = NULL;
+ pkgXmlNode *grp = GetRoot()->FindFirstAssociate( package_collection_key );
+ while( grp != NULL )
+ {
+ /* ...for each known package collection...
+ */
+ pkgXmlNode *pkg = grp->FindFirstAssociate( package_key );
+ while( pkg != NULL )
+ {
+ /* ...add an entry for each included package
+ * into the print-out directory...
+ */
+ dir = dir->Insert( name_key, new pkgDirectory( pkg ) );
+ /*
+ * ...enumerating each and every package...
+ */
+ pkg = pkg->FindNextAssociate( package_key );
+ }
+ /* ...then repeat for the next package collection,
+ * if any.
+ */
+ grp = grp->FindNextAssociate( package_collection_key );
+ }
+ return dir;
+}
+
+pkgDirectory *pkgDirectoryViewerEngine::EnumerateComponents( pkgXmlNode *pkg )
+{
+ /* A convenience method for enumerating the component packages of
+ * a specified package set, returning the enumerated collection as
+ * a collated list, in a chain of pkgDirectory structures.
+ */
+ pkgDirectory *dir = NULL;
+ pkg = pkg->FindFirstAssociate( component_key );
+ while( pkg != NULL )
+ {
+ /* ...in which we enumerate its components.
+ */
+ dir = dir->Insert( class_key, new pkgDirectory( pkg ) );
+ pkg = pkg->FindNextAssociate( component_key );
+ }
+ return dir;
+}
+
/* $RCSfile$: end of file */