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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
/* Copyright (c) MediaArea.net SARL. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license that can
* be found in the License.html file in the root of the source tree.
*/
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//
// Scheduler functions
//
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//---------------------------------------------------------------------------
#ifndef PLUGINH
#define PLUGINH
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
#include <map>
#if defined(_WIN32)
#include <windows.h>
#endif
#include "MediaConchLib.h"
#include "Container.h"
//---------------------------------------------------------------------------
namespace MediaConch {
//***************************************************************************
// Class Plugin
//***************************************************************************
class Plugin
{
public:
Plugin();
virtual ~Plugin();
Plugin(const Plugin&);
virtual int load_plugin(const std::map<std::string, Container::Value>& obj, std::string& error) = 0;
virtual int run(std::string& error) = 0;
MediaConchLib::PluginType get_type() const { return type; }
const std::string& get_name() const { return name; }
const std::string& get_id() const { return id; }
const std::string& get_report() const { return report; }
const std::string& get_report_err() const { return report_err; }
const std::string& get_error() const { return error; }
void set_id(const std::string& i) { this->id = i; }
void set_name(const std::string& n) { this->name = n; }
protected:
MediaConchLib::PluginType type;
std::string name;
std::string id;
std::string report;
std::string report_err;
std::string error;
int exec_bin(const std::vector<std::string>& params, std::string& error);
int create_report_dir(const std::string& base_dir, const std::string& template_dir, std::string& report_dir);
int read_report(const std::string& file, std::string& report);
int delete_report_dir(const std::string& report_dir);
#if defined(_WIN32)
int create_pipe(HANDLE* handler_out_rd, HANDLE* handler_out_wr);
int execute_the_command(std::string& cmd, HANDLE handler_out_wr, HANDLE handler_err_wr);
int read_the_output(HANDLE handler_out_wr, HANDLE handler_out_rd, bool is_out);
#endif
void unified_string(std::string& str);
private:
Plugin& operator=(const Plugin&);
};
}
#endif // !PLUGINH
|