84 lines
1.8 KiB
C++
84 lines
1.8 KiB
C++
|
|
#include <iostream>
|
|
#include <glibmm.h>
|
|
#include <sigc++/class_slot.h>
|
|
|
|
#include "config.h"
|
|
// #include "groupmember.h"
|
|
|
|
#include "lowreceiver.h"
|
|
#include "highreceiver.h"
|
|
#include "lowsender.h"
|
|
|
|
#include "clock.h"
|
|
#include "clock_test.h"
|
|
#include "clock_ab.h"
|
|
#include "clock_cb.h"
|
|
|
|
|
|
/*
|
|
* - on doit passer en parametre les gars du groupe...
|
|
* -
|
|
*/
|
|
|
|
int main(int argc, char ** argv){
|
|
Config config(argc, argv);
|
|
if (config.isValid()){
|
|
Glib::thread_init();
|
|
|
|
Group grp(config.getGroupHosts(), config.getIndex());
|
|
Clock * clk;
|
|
|
|
//FIXME non-dynamic port !
|
|
int portHigh = 2710;
|
|
|
|
switch(config.getMode()){
|
|
case Protocol::TYPE_TEST:
|
|
clk = new ClockTest();
|
|
printf("Test mode!\n");
|
|
break;
|
|
case Protocol::TYPE_ABCAST:
|
|
clk = new ClockAb(config.getIndex());
|
|
printf("AbCast mode!\n");
|
|
break;
|
|
case Protocol::TYPE_CBCAST:
|
|
clk = new ClockCb(4,1);
|
|
printf("CbCast mode!\n");
|
|
break;
|
|
case Protocol::TYPE_UNKNOWN:
|
|
clk = NULL;
|
|
printf("Unknow mode!\n");
|
|
exit(-1);
|
|
break;
|
|
default:
|
|
clk = NULL;
|
|
printf("Unknow(2) mode!\n");
|
|
exit(-1);
|
|
break;
|
|
}
|
|
HighReceiver high_receiver(portHigh);
|
|
|
|
LowReceiver low_receiver(config.getPort(),
|
|
portHigh,
|
|
grp,
|
|
*clk);
|
|
LowSender low_sender(grp,*clk,config.getMode());
|
|
|
|
Glib::Thread *const high_receiver_thr = Glib::Thread::create(
|
|
sigc::mem_fun(high_receiver, &HighReceiver::run), true);
|
|
Glib::Thread *const low_sender_thr = Glib::Thread::create(
|
|
sigc::mem_fun(low_sender, &LowSender::run), true);
|
|
Glib::Thread *const low_receiver_thr = Glib::Thread::create(
|
|
sigc::mem_fun(low_receiver, &LowReceiver::run), true);
|
|
|
|
low_sender_thr->join();
|
|
low_receiver_thr->join();
|
|
high_receiver_thr->join();
|
|
|
|
std::cout <<"Happy end"<<std::endl;
|
|
} else {
|
|
std::cout <<"Missing arguments"<<std::endl;
|
|
config.usage();
|
|
}
|
|
return 0;
|
|
}
|