1 #include "scd_cont_man_master.h"
3 #include "scd_logging.h"
4 #include "scd_exception.h"
7 scd_cont_man_master::scd_cont_man_master(scd_simulator& sim):
8 _sim(sim), scd_cont_fsm("master"),
9 _st_init(sim, *this), _st_busy(sim, *this), _st_idle(sim, *this),
10 _st_done(sim, *this), _st_time_req(sim, *this), _st_time(sim, *this),
11 _st_term_req(sim, *this), _st_terminate(sim, *this),
12 _st_terminated(sim, *this), _st_fail(sim, *this), _st_failed(sim, *this)
19 scd_cont_man_master::~scd_cont_man_master()
21 std::list<scd_cont_slave_wrapper*>::iterator it;
23 for (it = _slaves.begin(); it != _slaves.end(); it++)
28 void scd_cont_man_master::connect_slave(const scd_command &c, scd_socket* sock)
30 std::string name = c.get_string();
32 scd_cont_slave_wrapper* slave = _get_slave(name);
36 scd_warn("unknown slave \"" + name + "\"");
45 void scd_cont_man_master::set_master(const std::string& host, uint16_t port)
47 scd_error("simulator is master, can not have another master");
48 throw scd_exception("simulator is master");
52 void scd_cont_man_master::register_slave(const std::string& name)
54 if ( _get_slave(name) != NULL )
56 scd_warn("slave \"" + name + "\" already registered, ignoring...");
60 scd_cont_slave_wrapper* wrap;
61 wrap = new scd_cont_slave_wrapper(_sim, name);
62 _slaves.push_back(wrap);
68 void scd_cont_man_master::process()
70 std::list<scd_cont_slave_wrapper*>::iterator it;
73 for (it = _slaves.begin(); it != _slaves.end(); it++)
76 // process the local state
81 scd_cont_slave_wrapper* scd_cont_man_master::_get_slave(const std::string& name)
83 std::list<scd_cont_slave_wrapper*>::iterator it;
85 for (it = _slaves.begin(); it != _slaves.end(); it++)
87 if ( (*it)->get_name() == name )