libLicenseClient/api/ModuleManager.h

41 lines
1015 B
C++

#pragma once
#include "IDownloader.h"
#include "IModuleDatabase.h"
#include "JSONSerialization.h"
#include "ModuleUpdate.h"
#include <boost/filesystem.hpp>
#include <map>
#include <set>
#include <string>
#include <vector>
#include <iostream>
class ModuleManager
{
public:
ModuleManager(const std::string& appBaseDir, IModuleDatabase& db, IDownloader& downloader, const std::string& tempDir)
: m_appBaseDir(appBaseDir)
, m_db(db)
, m_downloader(downloader)
, m_tempDir(tempDir)
{}
public:
void applyUpdate(const std::string& moduleId, const ModuleUpdate& update);
private:
void applyUpdate(Module& module, const ModuleUpdate& update);
boost::filesystem::path retrieveUpdate(const std::string& updateUrl);
std::set<std::string> extractUpdate(const boost::filesystem::path& archivePath, const std::string& targetPath);
private:
std::string m_appBaseDir;
IModuleDatabase & m_db;
IDownloader& m_downloader;
std::string m_tempDir;
};