00001 /*---------------------------------------------------------------------\ 00002 | | 00003 | __ __ ____ _____ ____ | 00004 | \ \ / /_ _/ ___|_ _|___ \ | 00005 | \ V / _` \___ \ | | __) | | 00006 | | | (_| |___) || | / __/ | 00007 | |_|\__,_|____/ |_| |_____| | 00008 | | 00009 | core system | 00010 | (C) SuSE GmbH | 00011 \----------------------------------------------------------------------/ 00012 00013 File: InstTargetProdDB.h 00014 00015 Author: Michael Andres <ma@suse.de> 00016 Maintainer: Michael Andres <ma@suse.de> 00017 00018 Purpose: 00019 00020 /-*/ 00021 #ifndef InstTargetProdDB_h 00022 #define InstTargetProdDB_h 00023 00024 #include <iosfwd> 00025 #include <list> 00026 #include <map> 00027 00028 #include <y2util/Pathname.h> 00029 00030 #include <y2pm/InstTargetProdDBPtr.h> 00031 #include <y2pm/InstTargetError.h> 00032 00033 #include <y2pm/InstSrcDescrPtr.h> 00034 00036 // 00037 // CLASS NAME : InstTargetProdDB 00041 class InstTargetProdDB : public CountedRep { 00042 REP_BODY(InstTargetProdDB); 00043 00044 public: 00045 00049 typedef InstTargetError Error; 00050 00051 private: 00052 00053 static const Pathname _db_path; 00054 static const std::string _db_stem; 00055 static const unsigned _db_nwidth; 00056 00057 private: 00058 00059 const Pathname _db; 00060 unsigned _nextIdx; 00061 00062 std::map<unsigned,constInstSrcDescrPtr> _prodmap; 00063 std::list<constInstSrcDescrPtr> _prodlist; 00064 std::list<constInstSrcDescrPtr> _sortedProdlist; 00065 00066 private: 00067 00068 PMError assert_open() const; 00069 00070 std::string db_file_name( unsigned num_r ) const; 00071 bool is_db_file_name( const std::string & fname_r ) const; 00072 00073 Pathname db_file( const std::string & fname_r ) const; 00074 00075 PMError read_db_file( const std::string & fname_r, 00076 unsigned & idx_r, InstSrcDescrPtr & ndescr_r ) const; 00077 00078 void sortProdlist(); 00079 00080 public: 00081 00082 InstTargetProdDB(); 00083 00084 ~InstTargetProdDB(); 00085 00086 public: 00087 00088 PMError open( const Pathname & system_root_r = "/" ); 00089 00090 bool isOpen() const { return _nextIdx; } 00091 00092 const Pathname & dbPath() const { return _db; } 00093 00094 const std::list<constInstSrcDescrPtr> & getProducts() const { return _sortedProdlist; } 00095 00096 public: 00097 00098 bool isInstalled( const constInstSrcDescrPtr & isd_r ) const; 00099 00100 PMError install( const constInstSrcDescrPtr & isd_r ); 00101 00102 PMError remove( const constInstSrcDescrPtr & isd_r ); 00103 00104 public: 00105 00106 virtual std::ostream & dumpOn( std::ostream & str ) const; 00107 }; 00108 00110 00111 #endif // InstTargetProdDB_h 00112