From d3e67b912a97834dbf0711b5d3dbbc0bd3d29ee8 Mon Sep 17 00:00:00 2001 From: "(no author)" <(no author)@0f7e0d06-a6f9-0310-a55f-d5f984f55e4c> Date: Thu, 10 Feb 2005 23:10:51 +0000 Subject: This commit was manufactured by cvs2svn to create branch 'hugues'. git-svn-id: file:///usr/local/opt/svn/repos/glagen@4 0f7e0d06-a6f9-0310-a55f-d5f984f55e4c --- branches/hugues/glagen/algo_distribue/main.cc | 113 ++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 branches/hugues/glagen/algo_distribue/main.cc (limited to 'branches/hugues/glagen/algo_distribue/main.cc') diff --git a/branches/hugues/glagen/algo_distribue/main.cc b/branches/hugues/glagen/algo_distribue/main.cc new file mode 100644 index 0000000..e78d461 --- /dev/null +++ b/branches/hugues/glagen/algo_distribue/main.cc @@ -0,0 +1,113 @@ +// Algo distribue + +// glagen_divide [n] +// n indique le nombre d'ordinateur en reseau exclut le serveur + +#include +#include +#include + +// Load Tree +#include "tree/node.hh" +#include "tree/tree.hh" + +// Load Network +#include "network/Server.hh" +#include "network/Client.hh" + +// Load Data +#include "network/data/Data_string.hh" + +// Load Tool +#include "tools/matrix.hh" + +#include "Distribue.hh" + +#include +#include + +// Prototype : test d'essais avec 2 clients +// On changera suivant les donnees passes par GTK +// Il faut que le nombre de client soit superieur ou egale +// au nombre de noeud fils par rapport au noeud principal +#define NB_CLIENT 2 + +char gl_handle; + +Tree *create_tree(); + +void help(char *prog_name) +{ + std::cout << prog_name << " [port]" << std::endl; + exit(0); +} + +void signal_alarm(int) +{ + gl_handle = gl_handle | 1; +} + +void check_args(int argc, char *argv1, char *argv2) +{ + int current; + + if (argc != 2) + { + std::cerr << "Error server : Error parameters" << std::endl; + help(argv1); + } + for (current = 0; argv2[current] != '\0'; current++) + if (argv2[current] < '0' || argv2[current] > '9') + { + std::cerr << "Error server : Error parameters" << std::endl; + help(argv1); + } +} + +int main(int argc, char *argv[]) +{ + // Exemple de creation d'un arbre (donnees string) + // On peut appele une classe abstraite dont ses fils sont + // les types de donnees des librairies (ex: Tree) + Tree* tree; + tree = create_tree(); + + // Calcul de l'algo distribue : calcul l'attribution des taches + // pour chaque client + Distribue network(*tree); + std::cout << "Matrice calcule" << std::endl + << network.get_matrix() << std::endl; + + // Execution du serveur + check_args(argc, argv[0], argv[1]); + Server server(atoi(argv[1]), NB_CLIENT); + + // Transfert des donnees + network.transfer(server); + + return (0); +} + + + +Tree *create_tree() +{ + string root = "Connection..."; + string a = "Est-ce que ca fonctionne ?"; + string b = "1212123"; + string c = "OK recu 5/5"; + Tree tree(root); + tree.add_node(a); + tree.add_node(b); + tree.add_node(c); + + Tree* main_tree = new Tree(string("Execution...")); + main_tree->add_tree(tree); + + Tree tree2(string("Une tentative de suicide")); + tree2.add_node(string("Ou ca?")); + tree2.add_node(string("A Epita")); + tree2.add_node(string("Ping pong ping")); + main_tree->add_tree(tree2); + return (main_tree); +} -- cgit v1.2.3