- this will be the common classes to transport data from parsers to
authorDuncan Mac-Vicar P <dmacvicar@suse.de>
Thu, 29 Jun 2006 13:48:03 +0000 (13:48 +0000)
committerDuncan Mac-Vicar P <dmacvicar@suse.de>
Thu, 29 Jun 2006 13:48:03 +0000 (13:48 +0000)
  cache as we cant expose the sqlite schema to source cachers or then
  we will need to fix it everywhere if the schema changed

  so we will say goodbye to yum data soon.

configure.ac
devel/devel.dmacvicar/testbed.cc
zypp/Makefile.am
zypp/cache/SourceCacher.cpp
zypp/data/Makefile.am [new file with mode: 0644]
zypp/data/ResolvableData.cc [new file with mode: 0644]
zypp/data/ResolvableData.h [new file with mode: 0644]

index 86bbb82..808e27a 100644 (file)
@@ -251,6 +251,7 @@ AC_OUTPUT(   po/Makefile.in\
        zypp/pool/Makefile              \
        zypp/solver/Makefile            \
        zypp/solver/detail/Makefile     \
+  zypp/data/Makefile \
        zypp/cache/Makefile \
   zypp/cache/sqlite3x/Makefile
   zypp/source/Makefile         \
index 4ff4862..bf613a2 100644 (file)
@@ -36,7 +36,13 @@ using namespace zypp;
 
 int main()
 {
-  cache::KnownSourcesCache("/");
+  cache::KnownSourcesCache cache("/");
+  
+  source::SourceInfoList srcs = cache.knownSources();
+  for ( source::SourceInfoList::const_iterator it = srcs.begin(); it != srcs.end(); ++it)
+  {
+    cout << *it << endl;
+  }
 }
 
 
index 22b8950..bf5a4ba 100644 (file)
@@ -2,7 +2,7 @@
 ## ##################################################
 
 SUBDIRS = base thread url media capability detail pool parser \
-       source cache target solver zypp_detail ui
+       data source cache target solver zypp_detail ui
 
 AM_CXXFLAGS = -DZYPP_BASE_LOGGER_LOGGROUP=\"zypp\"
 
@@ -174,6 +174,7 @@ lib@PACKAGE@_la_LIBADD =        thread/lib@PACKAGE@_thread.la               \
                                parser/lib@PACKAGE@_parser.la           \
                                source/lib@PACKAGE@_source.la           \
                                cache/lib@PACKAGE@_cache.la             \
+                               data/lib@PACKAGE@_data.la               \
                                media/lib@PACKAGE@_media.la             \
                                url/lib@PACKAGE@_url.la                 \
                                target/lib@PACKAGE@_target.la           \
index d03c45e..b51f057 100644 (file)
@@ -27,6 +27,10 @@ SourceCacher::~SourceCacher()
 {
 }
 
+std::ostream & SourceCacher::dumpOn( std::ostream & str ) const
+{
+  return str;
+}
 
 }
 }
diff --git a/zypp/data/Makefile.am b/zypp/data/Makefile.am
new file mode 100644 (file)
index 0000000..45a1251
--- /dev/null
@@ -0,0 +1,22 @@
+## Process this file with automake to produce Makefile.in
+## ##################################################
+
+SUBDIRS =
+
+INCLUDES = -I$(oldincludedir)/libxml2  \
+       -DZYPP_BASE_LOGGER_LOGGROUP=\"data\"
+
+## ##################################################
+
+parserincludedir = $(pkgincludedir)/data
+
+parserinclude_HEADERS = \
+       ResolvableData.h
+       
+noinst_LTLIBRARIES =   lib@PACKAGE@_data.la
+
+
+## ##################################################
+
+lib@PACKAGE@_data_la_SOURCES = \
+       ResolvableData.cc
diff --git a/zypp/data/ResolvableData.cc b/zypp/data/ResolvableData.cc
new file mode 100644 (file)
index 0000000..d30572f
--- /dev/null
@@ -0,0 +1,105 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+
+#include "zypp/data/ResolvableData.h"
+
+using namespace std;
+
+namespace zypp
+{
+namespace data
+{
+
+Dependency::Dependency(const std::string& kind, const std::string& encoded)
+                               : kind(kind), encoded(encoded)
+{
+}; 
+  
+IMPL_PTR_TYPE(ResObject);
+IMPL_PTR_TYPE(Script);
+IMPL_PTR_TYPE(Message);
+IMPL_PTR_TYPE(Selection);  
+IMPL_PTR_TYPE(Pattern);
+  
+  
+std::ostream& operator<<(std::ostream& out, const zypp::shared_ptr<AtomBase> data)
+{
+  out << "Atom data" << endl;
+  switch (data->atomType())
+  {
+    case AtomBase::TypePackage:
+      out << "  atom type: " << "package" << endl
+          << *zypp::dynamic_pointer_cast<Patch>(data);
+      break;
+    case AtomBase::TypeMessage:
+      out << "  atom type: " << "message" << endl
+          << *zypp::dynamic_pointer_cast<Message>(data);
+      break;
+    case AtomBase::TypeScript:
+      out << "  atom type: " << "script" << endl
+          << *zypp::dynamic_pointer_cast<Script>(data);
+      break;
+    default:
+      out << "Unknown atom type" << endl;
+  }
+  return out;
+}  
+  
+std::ostream& operator<<(std::ostream& out, const Script& data)
+{
+  out << "Script Data: " << endl
+      << "  name: " << data.name << endl
+      << "  epoch: " << data.epoch << endl
+      << "  version: " << data.ver << endl
+      << "  release: " << data.rel << endl
+      << "  provides: " << data.provides << endl
+      << "  conflicts: " << data.conflicts << endl
+      << "  obsoletes: " << data.obsoletes << endl
+      << "  freshens: " << data.freshens << endl
+      << "  requires: " << data.requires << endl
+      << "  recommends:" << endl << data.recommends << endl
+      << "  suggests:" << endl << data.suggests << endl
+      << "  supplements:" << endl << data.supplements << endl
+      << "  enhances:" << endl << data.enhances << endl
+      << "  do script: " << data.do_script << endl
+      << "  undo script: " << data.undo_script << endl
+      << "  do script location: " << data.do_location << endl
+      << "  undo script location: " << data.undo_location << endl
+      << "  do script media: " << data.do_media << endl
+      << "  undo script media: " << data.undo_media << endl
+      << "  do checksum type: " << data.do_checksum_type << endl
+      << "  do checksum: " << data.do_checksum << endl
+      << "  undo checksum type: " << data.undo_checksum_type << endl
+      << "  undo checksum: " << data.undo_checksum << endl;
+  return out;
+}  
+  
+std::ostream& operator<<(std::ostream& out, const Message& data)
+{
+  out << "Message Data: " << endl
+      << "  name: " << data.name << endl
+      << "  epoch: " << data.epoch << endl
+      << "  version: " << data.ver << endl
+      << "  release: " << data.rel << endl
+      << "  provides: " << data.provides << endl
+      << "  conflicts: " << data.conflicts << endl
+      << "  obsoletes: " << data.obsoletes << endl
+      << "  freshens: " << data.freshens << endl
+      << "  requires: " << data.requires << endl
+      << "  recommends:" << endl << data.recommends << endl
+      << "  suggests:" << endl << data.suggests << endl
+      << "  supplements:" << endl << data.supplements << endl
+      << "  enhances:" << endl << data.enhances << endl
+      << "  text: " << data.text << endl;
+  return out;
+}  
+  
+} // namespace cache
+} // namespace zypp
diff --git a/zypp/data/ResolvableData.h b/zypp/data/ResolvableData.h
new file mode 100644 (file)
index 0000000..85c9d61
--- /dev/null
@@ -0,0 +1,149 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+
+
+#ifndef ResolvableData_h
+#define ResolvableData_h
+
+#include "zypp/base/ReferenceCounted.h"
+#include "zypp/base/NonCopyable.h"
+#include "zypp/Pathname.h"
+#include "zypp/Edition.h"
+#include "zypp/Arch.h"
+#include "zypp/TranslatedText.h"
+#include <string>
+#include <list>
+#include <iostream>
+#include <zypp/base/PtrTypes.h>
+
+using namespace zypp::base;
+
+namespace zypp
+{
+namespace data
+{
+  class Dependency
+  {
+    public:
+      Dependency();
+      Dependency(const std::string& kind, const std::string& encoded );
+      std::string kind;
+      std::string encoded;
+  };
+  
+  typedef std::list<Dependency> DependencyList;
+  
+  class ResObject : public base::ReferenceCounted, private base::NonCopyable
+  {
+    public:
+      std::string name;
+      Edition edition;
+      Arch arch;
+      
+      TranslatedText summary;
+      TranslatedText description;
+      
+      DependencyList provides;
+      DependencyList conflicts;
+      DependencyList obsoletes;
+      DependencyList freshens;
+      DependencyList requires;
+      DependencyList prerequires;
+      DependencyList recommends;
+      DependencyList suggests;
+      DependencyList supplements;
+      DependencyList enhances;
+  };
+  
+  class AtomBase : public ResObject
+  {
+    public:
+      enum AtomType { TypePackage, TypeScript, TypeMessage };
+      virtual AtomType atomType() = 0;
+  };
+  
+  class Script : public AtomBase
+  {
+    public:
+      Script() {};
+      virtual AtomType atomType() { return TypeScript; };
+      std::string do_script;
+      std::string undo_script;
+      std::string do_location;
+      std::string undo_location;
+      std::string do_media;
+      std::string undo_media;
+      std::string do_checksum_type;
+      std::string do_checksum;
+      std::string undo_checksum_type;
+      std::string undo_checksum;
+  };
+
+  class Message : public AtomBase
+  {
+    public:
+      Message() {};
+      virtual AtomType atomType() { return TypeMessage; };
+      TranslatedText text;
+  };
+  
+  class Selection : public base::ReferenceCounted, private base::NonCopyable
+  {
+    public:
+
+      Selection() {};
+      std::string groupId;
+      TranslatedText name;
+      std::string default_;
+      std::string user_visible;
+      TranslatedText description;
+      //std::list<MetaPkg> grouplist;
+      //std::list<PackageReq> packageList;
+  };
+
+  class Pattern : public ResObject
+  {
+    public:
+
+      Pattern() {};
+      
+      std::string default_;
+      std::string user_visible;
+      TranslatedText category;
+      std::string icon;
+      std::string script;
+  };
+
+  class Product : public ResObject
+  {
+    public:
+      Product() {};
+      ~Product() {};
+
+      std::string type;
+      std::string vendor;
+      std::string name; 
+      TranslatedText short_name;
+        // those are suse specific tags
+      std::string releasenotesurl;
+  };
+  
+  /* Easy output */
+  std::ostream& operator<<(std::ostream &out, const Dependency& data);
+  std::ostream& operator<<(std::ostream &out, const ResObject& data);
+  std::ostream& operator<<(std::ostream &out, const Product& data);
+  std::ostream& operator<<(std::ostream &out, const Pattern& data);
+  std::ostream& operator<<(std::ostream &out, const Selection& data);
+  
+} // namespace data
+} // namespace zypp
+
+
+#endif
+