Source.h \
SourceFactory.h \
SourceManager.h \
+ Target.h \
Selection.h \
Pattern.h \
Message.h \
Source.cc \
SourceFactory.cc\
SourceManager.cc\
+ Target.cc \
Selection.cc \
Pattern.cc \
Message.cc \
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/Target.cc
+ *
+*/
+#include <cassert>
+
+#include <iostream>
+
+#include "zypp/Target.h"
+#include "zypp/target/TargetImpl.h"
+
+using namespace std;
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+
+ IMPL_PTR_TYPE(Target);
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // METHOD NAME : Target::Target
+ // METHOD TYPE : Ctor
+ //
+ Target::Target( const Pathname & root )
+ {
+ _pimpl = RW_pointer<Impl, rw_pointer::Intrusive<Impl> >(new Impl(root));
+ }
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // METHOD NAME : Target::Target
+ // METHOD TYPE : Ctor
+ //
+ Target::Target( const Impl_Ptr & impl_r )
+ : _pimpl( impl_r )
+ {
+ assert( impl_r );
+ }
+
+ Target_Ptr Target::_nullimpl;
+
+ /** Null implementation */
+ Target_Ptr Target::nullimpl()
+ {
+ if (! _nullimpl)
+ {
+ _nullimpl = new Target(target::TargetImpl::nullimpl());
+ }
+ return _nullimpl;
+ }
+
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // Forward to TargetImpl:
+ //
+ ///////////////////////////////////////////////////////////////////
+
+ const ResStore & Target::resolvables()
+ { return _pimpl->resolvables(); }
+
+ target::rpm::RpmDb & Target::rpmDb()
+ { return _pimpl->rpm(); }
+
+ std::ostream & Target::dumpOn( std::ostream & str ) const
+ { return _pimpl->dumpOn( str ); }
+
+
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/Target.h
+ *
+*/
+#ifndef ZYPP_TARGET_H
+#define ZYPP_TARGET_H
+
+#include <iosfwd>
+
+#include "zypp/base/PtrTypes.h"
+
+#include "zypp/ResStore.h"
+#include "zypp/Pathname.h"
+#include "zypp/target/TargetImpl.h"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+ namespace target
+ {
+ class TargetImpl;
+ namespace rpm {
+ class RpmDb;
+ }
+ }
+
+ DEFINE_PTR_TYPE(Target);
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : Target
+ //
+ /**
+ */
+ class Target : public base::ReferenceCounted, public base::NonCopyable
+ {
+ public:
+ typedef target::TargetImpl Impl;
+ typedef intrusive_ptr<Impl> Impl_Ptr;
+
+ public:
+
+ /** All resolvables provided by the target. */
+ const ResStore & resolvables();
+ /** Null implementation */
+ static Target_Ptr nullimpl();
+ /** Refference to the RPM database */
+ target::rpm::RpmDb & rpmDb();
+
+ public:
+ /** Factory ctor */
+ Target( const Pathname & root = "/" );
+ /** Factory ctor */
+ explicit
+ Target( const Impl_Ptr & impl_r );
+
+ private:
+ friend std::ostream & operator<<( std::ostream & str, const Target & obj );
+ /** Stream output. */
+ std::ostream & dumpOn( std::ostream & str ) const;
+
+ private:
+ /** Pointer to implementation */
+ RW_pointer<Impl,rw_pointer::Intrusive<Impl> > _pimpl;
+
+ static Target_Ptr _nullimpl;
+
+ public:
+ };
+ ///////////////////////////////////////////////////////////////////
+
+ /** \relates Target Stream output. */
+ inline std::ostream & operator<<( std::ostream & str, const Target & obj )
+ { return obj.dumpOn( str ); }
+
+
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_TARGET_H
_pimpl->addResolvables (store);
}
+ Target_Ptr ZYpp::target() const
+ { return _pimpl->target(); }
+
+ void ZYpp::initTarget(const Pathname & root)
+ { _pimpl->initTarget(root); }
+
+ void ZYpp::finishTarget()
+ { _pimpl->finishTarget(); }
+
+
+
+
/////////////////////////////////////////////////////////////////
} // namespace zypp
///////////////////////////////////////////////////////////////////
#include "zypp/base/ReferenceCounted.h"
#include "zypp/base/NonCopyable.h"
#include "zypp/base/PtrTypes.h"
+#include "zypp/Target.h"
///////////////////////////////////////////////////////////////////
namespace zypp
void removeResolvables (const ResStore& store);
+ /**
+ * \throws Exception
+ */
+ Target_Ptr target() const;
+
+ /**
+ * \throws Exception
+ */
+ void initTarget(const Pathname & root);
+
+ /**
+ * \throws Exception
+ */
+ void finishTarget();
+
protected:
/** Dtor */
virtual ~ZYpp();
targetincludedir = $(pkgincludedir)/target
-targetinclude_HEADERS =
+targetinclude_HEADERS = \
+ TargetImpl.h
## ##################################################
## ##################################################
-lib@PACKAGE@_target_la_SOURCES =
+lib@PACKAGE@_target_la_SOURCES = \
+ TargetImpl.cc
lib@PACKAGE@_target_la_LDFLAGS = @LIBZYPP_VERSION_INFO@
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/target/TargetImpl.cc
+ *
+*/
+#include <iostream>
+#include "zypp/base/Logger.h"
+
+#include "zypp/target/TargetImpl.h"
+
+using std::endl;
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////
+ namespace target
+ { /////////////////////////////////////////////////////////////////
+
+ IMPL_PTR_TYPE(TargetImpl);
+
+ TargetImpl_Ptr TargetImpl::_nullimpl;
+
+ /** Null implementation */
+ TargetImpl_Ptr TargetImpl::nullimpl()
+ {
+ if (_nullimpl == 0)
+ _nullimpl = new TargetImpl;
+ return _nullimpl;
+ }
+
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // METHOD NAME : TargetImpl::TargetImpl
+ // METHOD TYPE : Ctor
+ //
+ TargetImpl::TargetImpl(const Pathname & root_r)
+ : _root(root_r)
+ {
+ _rpm.initDatabase();
+ MIL << "Initialized target on " << _root << endl;
+ }
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // METHOD NAME : TargetImpl::~TargetImpl
+ // METHOD TYPE : Dtor
+ //
+ TargetImpl::~TargetImpl()
+ {
+ _rpm.closeDatabase();
+ MIL << "Targets closed" << endl;
+ }
+
+ const ResStore & TargetImpl::resolvables()
+ {
+ _store.clear();
+ // RPM objects
+ std::list<Package::Ptr> packages = _rpm.getPackages();
+ for (std::list<Package::Ptr>::const_iterator it = packages.begin();
+ it != packages.end();
+ it++)
+ {
+ _store.insert(*it);
+ }
+ // TODO objects from the XML store
+ return _store;
+ }
+
+ rpm::RpmDb & TargetImpl::rpm()
+ { return _rpm; }
+
+ /////////////////////////////////////////////////////////////////
+ } // namespace target
+ ///////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/target/TargetImpl.h
+ *
+*/
+#ifndef ZYPP_TARGET_TARGETIMPL_H
+#define ZYPP_TARGET_TARGETIMPL_H
+
+#include <iosfwd>
+
+#include "zypp/base/ReferenceCounted.h"
+#include "zypp/base/NonCopyable.h"
+#include "zypp/base/PtrTypes.h"
+#include "zypp/ResStore.h"
+
+#include "zypp/Pathname.h"
+#include "zypp/media/MediaAccess.h"
+#include "zypp/Target.h"
+#include "zypp/target/rpm/RpmDb.h"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////
+ namespace target
+ { /////////////////////////////////////////////////////////////////
+
+ DEFINE_PTR_TYPE(TargetImpl);
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : TargetImpl
+ //
+ /** Base class for concrete Target implementations.
+ *
+ * Constructed by \ref TargetFactory. Public access via \ref Target
+ * interface.
+ */
+ class TargetImpl : public base::ReferenceCounted, private base::NonCopyable
+ {
+ friend std::ostream & operator<<( std::ostream & str, const TargetImpl & obj );
+
+ public:
+ /** Ctor. */
+ TargetImpl(const Pathname & root_r = "/");
+ /** Dtor. */
+ virtual ~TargetImpl();
+
+ /** Null implementation */
+ static TargetImpl_Ptr nullimpl();
+
+ public:
+
+ /** All resolvables in the target. */
+ const ResStore & resolvables();
+
+ /** Overload to realize stream output. */
+ virtual std::ostream & dumpOn( std::ostream & str ) const
+ { return str << "TargetImpl"; }
+
+ /** The RPM database */
+ rpm::RpmDb & rpm();
+
+ protected:
+ /** All resolvables provided by the target. */
+ ResStore _store;
+ /** Path to the target */
+ Pathname _root;
+ /** RPM database */
+ rpm::RpmDb _rpm;
+ private:
+ /** Null implementation */
+ static TargetImpl_Ptr _nullimpl;
+ };
+ ///////////////////////////////////////////////////////////////////
+
+ /** \relates TargetImpl Stream output */
+ inline std::ostream & operator<<( std::ostream & str, const TargetImpl & obj )
+ { return obj.dumpOn( str ); }
+
+ /////////////////////////////////////////////////////////////////
+ } // namespace target
+ ///////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_TARGET_TARGETIMPL_H
_pool.erase(*it);
}
}
+
+ Target_Ptr ZYppImpl::target() const
+ {
+ if (! _target)
+ ZYPP_THROW(Exception("Target not initialized."));
+ return _target;
+ }
+
+ void ZYppImpl::initTarget(const Pathname & root)
+ {
+ if (_target)
+ _target = Target_Ptr();
+#warning FIXME does this release the memory? _target is intrusive_ptr<Target>. Once more below...
+ _target = new Target(root);
+ }
+
+ void ZYppImpl::finishTarget()
+ {
+// if (_target)
+// _target = 0;
+ _target = 0;
+ }
/******************************************************************
**
#include <iosfwd>
#include "zypp/ResPoolManager.h"
-#include "zypp/SourceManager.h"
+#include "zypp/Target.h"
///////////////////////////////////////////////////////////////////
namespace zypp
void addResolvables (const ResStore& store);
void removeResolvables (const ResStore& store);
+
+ /**
+ * \throws Exception
+ */
+ Target_Ptr target() const;
+
+ /**
+ * \throws Exception
+ */
+ void initTarget(const Pathname & root);
+
+ /**
+ * \throws Exception
+ */
+ void finishTarget();
private:
/** */
ResPoolManager _pool;
+ /** */
+ Target_Ptr _target;
};
///////////////////////////////////////////////////////////////////