// start a new install
ins = new Install(this, pathOnDisk());
m_catalog->root()->scheduleToUpdate(ins);
+
+ _install_cb(this, ins);
+
return ins;
}
-InstallRef Package::existingInstall() const
+InstallRef Package::existingInstall(const InstallCallback& cb) const
{
- return m_catalog->installForPackage(const_cast<Package*>(this));
+ InstallRef install = m_catalog->installForPackage(const_cast<Package*>(this));
+
+ if( cb )
+ {
+ _install_cb.push_back(cb);
+
+ if( install )
+ cb(const_cast<Package*>(this), install);
+ }
+
+ return install;
}
std::string Package::id() const
#include <simgear/props/props.hxx>
#include <simgear/misc/strutils.hxx>
+#include <simgear/structure/function_list.hxx>
#include <simgear/structure/SGReferenced.hxx>
#include <simgear/structure/SGSharedPtr.hxx>
class Package : public SGReferenced
{
public:
+
+ typedef boost::function<void(Package*, Install*)> InstallCallback;
+
/**
* get or create an install for the package
*/
InstallRef install();
- InstallRef existingInstall() const;
+ InstallRef
+ existingInstall(const InstallCallback& cb = InstallCallback()) const;
bool isInstalled() const;
std::string m_id;
string_set m_tags;
CatalogRef m_catalog;
+
+ mutable function_list<InstallCallback> _install_cb;
};