#ifndef SH_PACKAGES_H
#define SH_PACKAGES_H

#include <pistring.h>

#define PACKAGES SHPackages::instance()


class SHPackages {
public:
	SHPackages();
	~SHPackages();

	static SHPackages * instance();

	struct Package {
		PIString file;
		PIString name;
		PIByteArray data;
	};

	void reloadPackages();
	PIString packageNameForHost(const PIString & host_type) const;
	PIString genPackageNameForHost(int os_type, const PIString & arch) const;
	Package packageForHost(const PIString & host_type) const;
	void loadPackageForHost(const PIString & host_type);

private:
	PIString dir_path;
	PIMap<PIString, Package> packages; // by hostType()

};


BINARY_STREAM_WRITE(SHPackages::Package) {s << v.name << v.data; return s;}
BINARY_STREAM_READ (SHPackages::Package) {s >> v.name >> v.data; return s;}


#endif // SH_PACKAGES_H
