Refactred pool.hpp

This commit is contained in:
Johan Mabille 2020-04-21 00:44:53 +02:00
parent 86593edeb7
commit 29f793befb
3 changed files with 50 additions and 25 deletions

View File

@ -1,4 +1,5 @@
#pragma once
#ifndef MAMBA_POOL_HPP
#define MAMBA_POOL_HPP
#include "thirdparty/minilog.hpp"
#include "context.hpp"
@ -13,34 +14,24 @@ namespace mamba
class MPool
{
public:
MPool()
{
m_pool = pool_create();
pool_setdisttype(m_pool, DISTTYPE_CONDA);
set_debuglevel();
}
~MPool()
{
LOG(INFO) << "Freeing pool.";
pool_free(m_pool);
}
MPool();
~MPool();
void set_debuglevel()
{
pool_setdebuglevel(m_pool, Context::instance().verbosity);
}
MPool(const MPool&) = delete;
MPool& operator=(const MPool&) = delete;
MPool(MPool&&) = delete;
MPool& operator=(MPool&&) = delete;
void create_whatprovides()
{
pool_createwhatprovides(m_pool);
}
void set_debuglevel();
void create_whatprovides();
operator Pool*()
{
return m_pool;
}
operator Pool*();
private:
Pool* m_pool;
};
}
}
#endif // MAMBA_POOL_HPP

View File

@ -65,6 +65,7 @@ ext_modules = [
'src/context.cpp',
'src/fetch.cpp',
'src/package_handling.cpp',
'src/pool.cpp',
'src/query.cpp',
'src/repo.cpp',
'src/solver.cpp',

33
src/pool.cpp Normal file
View File

@ -0,0 +1,33 @@
#include "pool.hpp"
namespace mamba
{
MPool::MPool()
{
m_pool = pool_create();
pool_setdisttype(m_pool, DISTTYPE_CONDA);
set_debuglevel();
}
MPool::~MPool()
{
LOG(INFO) << "Freeing pool.";
pool_free(m_pool);
}
void MPool::set_debuglevel()
{
pool_setdebuglevel(m_pool, Context::instance().verbosity);
}
void MPool::create_whatprovides()
{
pool_createwhatprovides(m_pool);
}
MPool::operator Pool*()
{
return m_pool;
}
}