DASetWriter.hpp 1.09 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
#ifndef BSDL_DOMAIN_DASETWRITER_HPP
#define BSDL_DOMAIN_DASETWRITER_HPP

#include <functional>
#include <map>
#include <memory>
#include <string>

#include "DomainArrangementSet.hpp"
#include "DASetOutputStrategy.hpp"

#include <boost/filesystem.hpp>
#include "../external/Output.hpp"


namespace BioSeqDataLib
{



template<class DomainType>
class DASetWriter
{
    private:
        std::map<std::string, std::function<void(const DomainArrangementSet<DomainType> &, AlgorithmPack::Output &)> > strategies;

    public:
        DASetWriter()
        {}

        virtual
        ~DASetWriter()
        {}

        void 
        write(const DomainArrangementSet<DomainType> &daSet, const std::string &format, const fs::path &out)
        {
            AlgorithmPack::Output outF(out);
            strategies.at(format)(daSet, outF);
        }
        
        void
        addStrategy(const std::string &name,  std::function<void(const DomainArrangementSet<DomainType> &, AlgorithmPack::Output &)> strategy)
        {
            strategies.emplace(name, strategy);
        }

};


}

#endif // BSDL_DOMAIN_DASETWRITER_HPP