3 * Copyright 2007,2008 Free Software Foundation, Inc.
5 * This file is part of GNU Radio
7 * GNU Radio is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3, or (at your option)
12 * GNU Radio is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 #include "gc_job_manager.h"
26 #include "gc_job_manager_impl.h"
27 #include <boost/weak_ptr.hpp>
31 static boost::weak_ptr<gc_job_manager> s_singleton;
35 gc_make_job_manager(const gc_jm_options *options)
37 return gc_job_manager_sptr(new gc_job_manager_impl(options));
40 gc_job_manager::gc_job_manager(const gc_jm_options *options)
45 gc_job_manager::~gc_job_manager()
51 gc_job_manager::set_debug(int debug)
57 gc_job_manager::debug()
63 gc_job_manager::set_singleton(gc_job_manager_sptr mgr)
69 gc_job_manager::singleton()
71 return gc_job_manager_sptr(s_singleton);
74 // ------------------------------------------------------------------------
78 class spe_program_handle_deleter {
80 void operator()(spe_program_handle_t *program) {
82 int r = spe_image_close(program);
84 perror("spe_image_close");
91 class nop_spe_program_handle_deleter {
93 void operator()(spe_program_handle_t *program) {
97 spe_program_handle_sptr
98 gc_program_handle_from_filename(const std::string &filename)
100 return spe_program_handle_sptr(spe_image_open(filename.c_str()),
101 spe_program_handle_deleter());
105 spe_program_handle_sptr
106 gc_program_handle_from_address(spe_program_handle_t *handle)
108 return spe_program_handle_sptr(handle, nop_spe_program_handle_deleter());
112 gc_job_status_string(gc_job_status_t status)
115 case JS_OK: return "JS_OK";
116 case JS_SHUTTING_DOWN: return "JS_SHUTTING_DOWN";
117 case JS_TOO_MANY_CLIENTS: return "JS_TOO_MANY_CLIENTS";
118 case JS_UNKNOWN_PROC: return "JS_UNKNOWN_PROC";
119 case JS_BAD_DIRECTION: return "JS_BAD_DIRECTION";
120 case JS_BAD_EAH: return "JS_BAD_EAH";
121 case JS_BAD_N_DIRECT: return "JS_BAD_N_DIRECT";
122 case JS_BAD_N_EA: return "JS_BAD_N_EA";
123 case JS_ARGS_TOO_LONG: return "JS_ARGS_TOO_LONG";
124 case JS_BAD_JUJU: return "JS_BAD_JUJU";
125 case JS_BAD_JOB_DESC: return "JS_BAD_JOB_DESC";
128 snprintf(buf, sizeof(buf), "unknown gc_job_status_t (%d)\n", status);
137 gc_exception::gc_exception(const std::string &msg)
142 gc_unknown_proc::gc_unknown_proc(const std::string &msg)
143 : gc_exception("gc_unknown_proc: " + msg)
147 gc_bad_alloc::gc_bad_alloc(const std::string &msg)
148 : gc_exception("gc_bad_alloc: " + msg)
152 gc_bad_align::gc_bad_align(const std::string &msg)
153 : gc_exception("gc_bad_align: " + msg)
157 gc_bad_submit::gc_bad_submit(const std::string &name, gc_job_status_t status)
158 : gc_exception("gc_bad_submit(" + name + "): " + gc_job_status_string(status))