00001 /*---------------------------------------------------------------------\ 00002 | | 00003 | __ __ ____ _____ ____ | 00004 | \ \ / /_ _/ ___|_ _|___ \ | 00005 | \ V / _` \___ \ | | __) | | 00006 | | | (_| |___) || | / __/ | 00007 | |_|\__,_|____/ |_| |_____| | 00008 | | 00009 | core system | 00010 | (C) SuSE GmbH | 00011 \----------------------------------------------------------------------/ 00012 00013 File: InstTargetSelDB.h 00014 00015 Author: Michael Andres <ma@suse.de> 00016 Maintainer: Michael Andres <ma@suse.de> 00017 00018 Purpose: 00019 00020 /-*/ 00021 #ifndef InstTargetSelDB_h 00022 #define InstTargetSelDB_h 00023 00024 #include <iosfwd> 00025 00026 #include <y2util/Pathname.h> 00027 00028 #include <y2pm/InstTargetSelDBPtr.h> 00029 #include <y2pm/InstTargetError.h> 00030 00031 #include <y2pm/PMSelectionPtr.h> 00032 00034 // 00035 // CLASS NAME : InstTargetSelDB 00039 class InstTargetSelDB : public CountedRep { 00040 REP_BODY(InstTargetSelDB); 00041 00042 public: 00043 00047 typedef InstTargetError Error; 00048 00049 private: 00050 00051 static const Pathname _db_path; 00052 00053 private: 00054 00055 const Pathname _db; 00056 00057 mutable std::list<PMSelectionPtr> _sellist; 00058 00059 mutable bool _sellistDirty; 00060 00061 private: 00062 00063 PMError assert_open() const; 00064 00065 PMError check_file( const Pathname & selfile_r ) const; 00066 00067 Pathname db_file( const Pathname & selfile_r ) const; 00068 00069 PMError rescan() const; 00070 00071 public: 00072 00073 InstTargetSelDB(); 00074 00075 ~InstTargetSelDB(); 00076 00077 public: 00078 00079 PMError open( const Pathname & system_root_r = "/" ); 00080 00081 bool isOpen() const { return !_db.empty(); } 00082 00083 const Pathname & dbPath() const { return _db; } 00084 00085 const std::list<PMSelectionPtr> & getSelections() const { 00086 if ( _sellistDirty ) 00087 rescan(); 00088 return _sellist; 00089 } 00090 00091 public: 00092 00093 bool isInstalled( const Pathname & selfile_r ) const; 00094 00095 PMError install( const Pathname & selfile_r ); 00096 00097 PMError remove( const Pathname & selfile_r ); 00098 00099 public: 00100 00101 virtual std::ostream & dumpOn( std::ostream & str ) const; 00102 }; 00103 00105 00106 #endif // InstTargetSelDB_h