[Debtags-commits] [svn] r889 - in libdebtags1/trunk: debtags tests

Enrico Zini debtags-commits@lists.alioth.debian.org
Fri, 17 Jun 2005 18:43:52 +0000


Author: enrico
Date: Fri Jun 17 18:43:51 2005
New Revision: 889

Added:
   libdebtags1/trunk/tests/test-dbcat1.cc
      - copied, changed from r881, libdebtags1/trunk/tests/test-dbcat.cc
Modified:
   libdebtags1/trunk/debtags/DebtagsFilters.cc
   libdebtags1/trunk/debtags/DebtagsSerializer.h
   libdebtags1/trunk/debtags/DebtagsSimple.cc
   libdebtags1/trunk/debtags/DebtagsSimple.h
   libdebtags1/trunk/debtags/Environment.cc
   libdebtags1/trunk/debtags/instantiations.cc
   libdebtags1/trunk/tests/Makefile.am
Log:
Added some Package-related features on DebtagsSimple<Package>, on the way to removing Environment.  In particular, now a PackageDB is instantiated by the Serializer<Package, Tag>, and it could conflict with the one in Environment

Modified: libdebtags1/trunk/debtags/DebtagsFilters.cc
==============================================================================
--- libdebtags1/trunk/debtags/DebtagsFilters.cc	(original)
+++ libdebtags1/trunk/debtags/DebtagsFilters.cc	Fri Jun 17 18:43:51 2005
@@ -13,8 +13,7 @@
 using namespace Debtags;
 
 ExpressionFilter::ExpressionFilter(const std::string& expression) throw (ConsistencyCheckException)
-	: ser(Debtags::Environment::get().vocabulary(),
-			Debtags::Environment::get().packageDB()), expr(0)
+	: ser(Debtags::Environment::get().vocabulary()), expr(0)
 {
 	expr = Tagcoll::TagexprParser::instance()->parse(expression);
 	if (expr == 0)
@@ -24,8 +23,7 @@
 ExpressionFilter::ExpressionFilter(const std::string& expression, Tagcoll::TagcollConsumer<Package, Tag>* cons)
 	throw (ConsistencyCheckException)
 		: Tagcoll::TagcollFilter<Package, Tag>(cons),
-		  ser(Debtags::Environment::get().vocabulary(),
-			  Debtags::Environment::get().packageDB()), expr(0)
+		  ser(Debtags::Environment::get().vocabulary()), expr(0)
 {
 	expr = Tagcoll::TagexprParser::instance()->parse(expression);
 	if (expr == 0)

Modified: libdebtags1/trunk/debtags/DebtagsSerializer.h
==============================================================================
--- libdebtags1/trunk/debtags/DebtagsSerializer.h	(original)
+++ libdebtags1/trunk/debtags/DebtagsSerializer.h	Fri Jun 17 18:43:51 2005
@@ -23,6 +23,8 @@
 
 #pragma interface
 
+#include <debtags/PackageDB.h>
+
 #include <tagcoll/Exception.h>
 #include <tagcoll/Serializer.h>
 
@@ -45,11 +47,16 @@
 {
 protected:
 	const Debtags::Vocabulary& voc;
-	const Debtags::PackageDB& pkg;
+
+	// APT Package database
+	Debtags::PackageDB pkg;
 	
 public:
-	Serializer(const Debtags::Vocabulary& voc, const Debtags::PackageDB& pkg) throw ()
-		: voc(voc), pkg(pkg) {}
+	Serializer(const Debtags::Vocabulary& voc) throw ()
+		: voc(voc) {}
+
+	Debtags::PackageDB& packageDB() throw () { return pkg; }
+	const Debtags::PackageDB& packageDB() const throw () { return pkg; }
 	
 	/**
 	 * Convert a TAG to a string

Modified: libdebtags1/trunk/debtags/DebtagsSimple.cc
==============================================================================
--- libdebtags1/trunk/debtags/DebtagsSimple.cc	(original)
+++ libdebtags1/trunk/debtags/DebtagsSimple.cc	Fri Jun 17 18:43:51 2005
@@ -32,22 +32,12 @@
 
 #ifndef INSTANTIATING_TEMPLATES
 template<>
-DebtagsSimple<Debtags::Package>::DebtagsSimple(bool editable) :
-		_vocab(Paths::path_vocabulary, Paths::path_vocabulary_index),
-		_serializer(_vocab, _packagedb),
-		_tagDB(_vocab, _serializer, editable)
-{
-}
-
-template<>
 TagSet DebtagsSimple<std::string>::getTags(const std::string& package) const
 {
 	return _tagDB.getTags(package);
 }
 #else
 template<>
-DebtagsSimple<Debtags::Package>::DebtagsSimple(bool editable);
-template<>
 TagSet DebtagsSimple<std::string>::getTags(const std::string& package) const;
 #endif
 
@@ -110,6 +100,12 @@
 	return res;
 }
 
+template<class ITEM>
+bool DebtagsSimple<ITEM>::hasTagDatabase() throw ()
+{
+	return _tagDB.hasTagDatabase();
+}
+
 };
 
 #if 0
@@ -274,11 +270,6 @@
 
 
 
-bool StandardEnvironment::hasTagDatabase() throw ()
-{
-	return TagDB::hasTagDatabase();
-}
-
 #if 0
 void StandardEnvironment::updateDebtagsDatabase() throw (Exception)
 {

Modified: libdebtags1/trunk/debtags/DebtagsSimple.h
==============================================================================
--- libdebtags1/trunk/debtags/DebtagsSimple.h	(original)
+++ libdebtags1/trunk/debtags/DebtagsSimple.h	Fri Jun 17 18:43:51 2005
@@ -23,7 +23,6 @@
 
 #pragma interface
 
-#include <debtags/PackageDB.h>
 #include <debtags/Vocabulary.h>
 #include <debtags/TagDB.h>
 #include <tagcoll/Implications.h>
@@ -42,9 +41,6 @@
 	// State directory
 	std::string rcdir;
 
-	// APT Package database
-	PackageDB _packagedb;
-
 	// Debtags vocabulary
 	Vocabulary _vocab;
 
@@ -59,7 +55,7 @@
 	~DebtagsSimple() throw () {}
 	
 	// Check if the tag database has been created (i.e. if debtags update has been run)
-	//bool hasTagDatabase() throw ();
+	bool hasTagDatabase() throw ();
 
 	Vocabulary& vocabulary() throw () { return _vocab; }
 	const Vocabulary& vocabulary() const throw () { return _vocab; }
@@ -67,6 +63,9 @@
 	TagDB<ITEM>& tagDB() throw () { return _tagDB; }
 	const TagDB<ITEM>& tagDB() const throw () { return _tagDB; }
 
+	Tagcoll::Serializer<ITEM, Tag>& serializer() throw () { return _serializer; }
+	const Tagcoll::Serializer<ITEM, Tag>& serializer() const throw () { return _serializer; }
+
 	TagSet getTags(const std::string& package) const;
 	OpSet<ITEM> getPackages(const Tag& tag) const;
 	OpSet<ITEM> getPackages(const TagSet& tags) const;

Modified: libdebtags1/trunk/debtags/Environment.cc
==============================================================================
--- libdebtags1/trunk/debtags/Environment.cc	(original)
+++ libdebtags1/trunk/debtags/Environment.cc	Fri Jun 17 18:43:51 2005
@@ -184,7 +184,7 @@
 StandardEnvironment::StandardEnvironment(bool editable, bool facet_only) throw (ParserException, SystemException, ConsistencyCheckException) :
 		facet_only(facet_only),
 		_vocab(Paths::path_vocabulary, Paths::path_vocabulary_index),
-		_serializer(_vocab, _packagedb),
+		_serializer(_vocab),
 		_tagDB(_vocab, _serializer, editable)//,
 		//availableLoaded(false)
 {

Modified: libdebtags1/trunk/debtags/instantiations.cc
==============================================================================
--- libdebtags1/trunk/debtags/instantiations.cc	(original)
+++ libdebtags1/trunk/debtags/instantiations.cc	Fri Jun 17 18:43:51 2005
@@ -30,6 +30,7 @@
 
 template class FilterChain<Debtags::Package, Debtags::Tag>;
 template class InputMerger<Debtags::Package, Debtags::Tag>;
+template class ItemGrouper<std::string, Debtags::Tag>;
 template class ItemGrouper<Debtags::Package, Debtags::Tag>;
 template class OpSet<Debtags::Package>;
 template class OpSet<Debtags::Maintainer>;

Modified: libdebtags1/trunk/tests/Makefile.am
==============================================================================
--- libdebtags1/trunk/tests/Makefile.am	(original)
+++ libdebtags1/trunk/tests/Makefile.am	Fri Jun 17 18:43:51 2005
@@ -3,7 +3,7 @@
 libdebtags_test_SOURCES = tut-main.cpp test-vocabulary.cc
 libdebtags_test_LDADD = ../debtags/libdebtags1.a @LIBTAGCOLL1_LIBS@ -lapt-pkg 
 
-noinst_PROGRAMS = test-update test-packages test-packagedata test-dbcat ex-showpkg ex-showpkgs
+noinst_PROGRAMS = test-update test-packages test-packagedata test-dbcat test-dbcat1 ex-showpkg ex-showpkgs
 #ex-showfacetimpl
 #test-maintainers 
 
@@ -26,6 +26,9 @@
 test_dbcat_SOURCES = test-dbcat.cc
 test_dbcat_LDADD = ../debtags/libdebtags1.a @LIBTAGCOLL1_LIBS@ -lapt-pkg
 
+test_dbcat1_SOURCES = test-dbcat1.cc
+test_dbcat1_LDADD = ../debtags/libdebtags1.a @LIBTAGCOLL1_LIBS@ -lapt-pkg
+
 ex_showpkg_SOURCES = ex-showpkg.cc
 ex_showpkg_LDADD = ../debtags/libdebtags1.a @LIBTAGCOLL1_LIBS@ -lapt-pkg
 	

Copied: libdebtags1/trunk/tests/test-dbcat1.cc (from r881, libdebtags1/trunk/tests/test-dbcat.cc)
==============================================================================
--- libdebtags1/trunk/tests/test-dbcat.cc	(original)
+++ libdebtags1/trunk/tests/test-dbcat1.cc	Fri Jun 17 18:43:51 2005
@@ -1,4 +1,4 @@
-#include <debtags/Environment.h>
+#include <debtags/DebtagsSimple.h>
 #include <debtags/TagDB.h>
 #include <debtags/DebtagsSerializer.h>
 
@@ -17,19 +17,20 @@
 		// Install the handler for unexpected exceptions
 		InstallUnexpected installUnexpected;
 
-		Debtags::Environment::init(false);
+		DebtagsSimple<string> debtags(false);
+		Tagcoll::Serializer<string, Tag> serializer(debtags.vocabulary());
 
 		int result = 0;
 		
-		TextFormat<Package, Tag> writer(Environment::get().serializer(), stdout);
+		TextFormat<string, Tag> writer(serializer, stdout);
 
 		if (argc == 1)
 		{
-			ItemGrouper<Package, Tag> grouper;
-			Environment::get().tagDB().outputPatched(grouper);
+			ItemGrouper<string, Tag> grouper;
+			debtags.tagDB().outputPatched(grouper);
 			grouper.output(writer);
 		} else
-			Environment::get().tagDB().outputPatched(writer);
+			debtags.tagDB().outputPatched(writer);
 
 		return result;
 	} catch (Exception& e) {