C:/Projets/hexamonkey/core/interpreter/programloader.h
Go to the documentation of this file.
00001 //This file is part of the HexaMonkey project, a multimedia analyser
00002 //Copyright (C) 2013  Sevan Drapeau-Martin, Nicolas Fleury
00003 
00004 //This program is free software; you can redistribute it and/or
00005 //modify it under the terms of the GNU General Public License
00006 //as published by the Free Software Foundation; either version 2
00007 //of the License, or (at your option) any later version.
00008 
00009 //This program is distributed in the hope that it will be useful,
00010 //but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 //GNU General Public License for more details.
00013 
00014 //You should have received a copy of the GNU General Public License
00015 //along with this program; if not, write to the Free Software
00016 //Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00017 
00018 #ifndef PROGRAM_LOADER_H
00019 #define PROGRAM_LOADER_H
00020 
00021 #include <set>
00022 #include <memory>
00023 #include <stdint.h>
00024 
00025 #include "core/file/file.h"
00026 #include "core/objecttype.h"
00027 #include "core/module.h"
00028 #include "core/interpreter/program.h"
00029 
00030 class HmcModule;
00031 
00043 class ProgramLoader
00044 {
00045 public:
00051     ProgramLoader(const HmcModule &module, const std::vector<std::string> &compilerDirs, const std::string userDir);
00052 
00056     Program fromString(const std::string &exp) const;
00057 
00062     Program fromHM (const std::string& path) const;
00063 
00068     Program fromHMC(const std::string& path) const;
00069 
00077     Program fromFile(const std::string& basePath) const;
00078 
00079 protected:
00080     virtual bool executeCommand(const std::string& program, const std::vector<std::string>& arguments) const;
00081     virtual long long lastModified(const std::string& file) const;
00082 
00083 private:
00084     enum Mode {file, expression};
00085     Program fromHM (const std::string& path, int mode) const;
00086 
00087     const HmcModule& _module;
00088     const std::string _fileCompiler;
00089     const std::string _expCompiler;
00090     const std::string _userDir;
00091 
00092 };
00093 
00094 #endif // PROGRAM_LOADER_H