From d31c5942c4904697926e977da859b81abf78d161 Mon Sep 17 00:00:00 2001 From: cahon Date: Fri, 29 Mar 2002 15:16:11 +0000 Subject: [PATCH] *** empty log message *** --- eo/src/paradisEO/comm/messages/eoMessFrom.h | 66 +++++++++++++++++ .../comm/messages/from/eoEOReceiveMessFrom.h | 64 +++++++++++++++++ .../comm/messages/from/eoEOSendMessFrom.h | 72 +++++++++++++++++++ .../comm/messages/from/eoHeaderMessFrom.h | 65 +++++++++++++++++ .../comm/messages/from/eoKillMessFrom.h | 64 +++++++++++++++++ .../comm/messages/from/eoPublishMessFrom.h | 68 ++++++++++++++++++ .../comm/messages/to/eoEOReceiveMessTo.h | 52 ++++++++++++++ .../comm/messages/to/eoEOSendMessTo.h | 71 ++++++++++++++++++ .../comm/messages/to/eoHeaderMessTo.h | 71 ++++++++++++++++++ .../paradisEO/comm/messages/to/eoKillMessTo.h | 52 ++++++++++++++ .../comm/messages/to/eoPublishMessTo.h | 66 +++++++++++++++++ 11 files changed, 711 insertions(+) create mode 100644 eo/src/paradisEO/comm/messages/eoMessFrom.h create mode 100644 eo/src/paradisEO/comm/messages/from/eoEOReceiveMessFrom.h create mode 100644 eo/src/paradisEO/comm/messages/from/eoEOSendMessFrom.h create mode 100644 eo/src/paradisEO/comm/messages/from/eoHeaderMessFrom.h create mode 100644 eo/src/paradisEO/comm/messages/from/eoKillMessFrom.h create mode 100644 eo/src/paradisEO/comm/messages/from/eoPublishMessFrom.h create mode 100644 eo/src/paradisEO/comm/messages/to/eoEOReceiveMessTo.h create mode 100644 eo/src/paradisEO/comm/messages/to/eoEOSendMessTo.h create mode 100644 eo/src/paradisEO/comm/messages/to/eoHeaderMessTo.h create mode 100644 eo/src/paradisEO/comm/messages/to/eoKillMessTo.h create mode 100644 eo/src/paradisEO/comm/messages/to/eoPublishMessTo.h diff --git a/eo/src/paradisEO/comm/messages/eoMessFrom.h b/eo/src/paradisEO/comm/messages/eoMessFrom.h new file mode 100644 index 00000000..f0d8f575 --- /dev/null +++ b/eo/src/paradisEO/comm/messages/eoMessFrom.h @@ -0,0 +1,66 @@ +// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- + +// "eoMessFrom.h" + +// (c) OPAC Team, LIFL, 2002 + +/* This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Contact: cahon@lifl.fr +*/ + +#ifndef eoMessFrom_h +#define eoMessFrom_h + +#include +#include + +/** + An abstract class for any kind of coming message. + Common features are declared. + */ + +template class eoLocalListener ; + +template class eoMessFrom { + +public : + + /** + Constructor + */ + + eoMessFrom (eoLocalListener & _loc_listen) : + loc_listen (_loc_listen), + comm (MPI :: COMM_WORLD) { + } + + /** + Well ... + */ + + virtual void operator () () = 0 ; + +protected : + + MPI :: Comm & comm ; // Communicator + eoLocalListener & loc_listen ; // Transmitter + +} ; + +#endif + + + diff --git a/eo/src/paradisEO/comm/messages/from/eoEOReceiveMessFrom.h b/eo/src/paradisEO/comm/messages/from/eoEOReceiveMessFrom.h new file mode 100644 index 00000000..299e60e7 --- /dev/null +++ b/eo/src/paradisEO/comm/messages/from/eoEOReceiveMessFrom.h @@ -0,0 +1,64 @@ +// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- + +// "eoEOReceiveMessFrom.h" + +// (c) OPAC Team, LIFL, 2002 + +/* This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Contact: cahon@lifl.fr +*/ + +#ifndef eoEOReceiveMessFrom_h +#define eoEOReceiveMessFrom_h + +#include +#include +#include + +/** + A message expressing the need of immigration of EO ... + */ + +template class eoEOReceiveMessFrom : public eoMessFrom { + +public : + + /** + Constructor + */ + + eoEOReceiveMessFrom (eoLocalListener & _loc_listen) : + eoMessFrom (_loc_listen) { + + // Nothing else to receive :-) + } + + void operator () () { + + loc_listen.need_immigration () = true ; + } + +} ; + +#endif + + + + + + + + diff --git a/eo/src/paradisEO/comm/messages/from/eoEOSendMessFrom.h b/eo/src/paradisEO/comm/messages/from/eoEOSendMessFrom.h new file mode 100644 index 00000000..5f8a2e77 --- /dev/null +++ b/eo/src/paradisEO/comm/messages/from/eoEOSendMessFrom.h @@ -0,0 +1,72 @@ +// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- + +// "eoEOSendMessFrom.h" + +// (c) OPAC Team, LIFL, 2002 + +/* This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Contact: cahon@lifl.fr +*/ + +#ifndef eoEOSendMessFrom_h +#define eoEOSendMessFrom_h + +#include +#include +#include +#include + +/** + A message embeding a set of immigrants ... +*/ + +template class eoEOSendMessFrom : public eoMessFrom { + +public : + + /** + Constructor + */ + + eoEOSendMessFrom (eoLocalListener & _loc_listen) : + eoMessFrom (_loc_listen) { + + MPI :: Status stat ; + comm.Probe (loc_listen.number (), 0, stat) ; + int len = stat.Get_count (MPI :: CHAR) ; + char buff [len] ; + comm.Recv (buff, len, MPI :: CHAR, loc_listen.number (), 0) ; + istrstream f (buff) ; + pop.readFrom (f) ; + + } + + void operator () () { + + loc_listen.push (pop) ; + // cout << "Reception de " << pop.size () << "individus " << endl ; + } + +private : + + eoPop pop ; // New immigrants ! + +} ; + +#endif + + + diff --git a/eo/src/paradisEO/comm/messages/from/eoHeaderMessFrom.h b/eo/src/paradisEO/comm/messages/from/eoHeaderMessFrom.h new file mode 100644 index 00000000..6986f519 --- /dev/null +++ b/eo/src/paradisEO/comm/messages/from/eoHeaderMessFrom.h @@ -0,0 +1,65 @@ +// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- + +// "eoHeaderMessFrom.h" + +// (c) OPAC Team, LIFL, 2002 + +/* This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Contact: cahon@lifl.fr +*/ + +#ifndef eoHeaderMessFrom_h +#define eoHeaderMessFrom_h + +#include +#include + +template class eoLocalListener ; + +/** + A header is an identifier for the kind of + message to be then received ... +*/ + +template class eoHeaderMessFrom : public string { + +public : + + /** + Second constructor. On contrary, the header is + waited for and built from the local listener. + It comes before a message. + */ + + eoHeaderMessFrom (eoLocalListener & loc_listen) : + comm (MPI :: COMM_WORLD) { + + MPI :: Status stat ; + comm.Probe (loc_listen.number (), 0, stat) ; // Blocking + int len = stat.Get_count (MPI :: CHAR) ; + char buff [len] ; // Temp. buffer + comm.Recv (buff, len, MPI :: CHAR, loc_listen.number (), 0) ; + assign (buff) ; + } + +private : + + MPI :: Comm & comm ; // Communicator + +} ; + +#endif + diff --git a/eo/src/paradisEO/comm/messages/from/eoKillMessFrom.h b/eo/src/paradisEO/comm/messages/from/eoKillMessFrom.h new file mode 100644 index 00000000..2a8d7c09 --- /dev/null +++ b/eo/src/paradisEO/comm/messages/from/eoKillMessFrom.h @@ -0,0 +1,64 @@ +// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- + +// "eoKillMessFrom.h" + +// (c) OPAC Team, LIFL, 2002 + +/* This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Contact: cahon@lifl.fr +*/ + +#ifndef eoKillMessFrom_h +#define eoKillMessFrom_h + +#include +#include +#include + +/** + To destroy current process ... + */ + +template class eoKillMessFrom : public eoMessFrom { + +public : + + /** + Constructor + */ + + eoKillMessFrom (eoLocalListener & _loc_listen) : + eoMessFrom (_loc_listen) { + + // Nothing else to receive :-) + } + + void operator () () { + + loc_listen.destroy () ; + } + +} ; + +#endif + + + + + + + + diff --git a/eo/src/paradisEO/comm/messages/from/eoPublishMessFrom.h b/eo/src/paradisEO/comm/messages/from/eoPublishMessFrom.h new file mode 100644 index 00000000..66c55454 --- /dev/null +++ b/eo/src/paradisEO/comm/messages/from/eoPublishMessFrom.h @@ -0,0 +1,68 @@ +// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- + +// "eoPublishMessFrom.h" + +// (c) OPAC Team, LIFL, 2002 + +/* This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Contact: cahon@lifl.fr +*/ + +#ifndef eoPublishMessFrom_h +#define eoPublishMessFrom_h + +#include +#include +#include + +/** + To be notified of the lauch of a new kind of process somewhere ... + */ + +template class eoPublishMessFrom : public eoMessFrom { + +public : + + /** + Constructor + */ + + eoPublishMessFrom (eoLocalListener & _loc_listen) : + eoMessFrom (_loc_listen) { + + MPI :: Status stat ; + comm.Probe (loc_listen.number (), 0, stat) ; + int len = stat.Get_count (MPI :: CHAR) ; + char buff [len] ; + comm.Recv (buff, len, MPI :: CHAR, loc_listen.number (), 0) ; + label.assign (buff) ; + } + + void operator () () { + + loc_listen.label () = label ; + } + +private : + + string label ; // String identifier ... + +} ; + +#endif + + + diff --git a/eo/src/paradisEO/comm/messages/to/eoEOReceiveMessTo.h b/eo/src/paradisEO/comm/messages/to/eoEOReceiveMessTo.h new file mode 100644 index 00000000..e9c33f03 --- /dev/null +++ b/eo/src/paradisEO/comm/messages/to/eoEOReceiveMessTo.h @@ -0,0 +1,52 @@ +// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- + +// "eoEOReceiveMessTo.h" + +// (c) OPAC Team, LIFL, 2002 + +/* This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Contact: cahon@lifl.fr +*/ + +/** + A message expressing an immigration need. +*/ + +#ifndef eoEOReceiveMessTo_h +#define eoEOReceiveMessTo_h + +#include +#include + +template class eoEOReceiveMessTo : public eoMessTo { + +public : + + /** + Constructor ... + */ + + eoEOReceiveMessTo () : eoMessTo ("eoEOReceiveMessTo") { + + } + + // Nothing else ! :-) + +} ; + +#endif + + diff --git a/eo/src/paradisEO/comm/messages/to/eoEOSendMessTo.h b/eo/src/paradisEO/comm/messages/to/eoEOSendMessTo.h new file mode 100644 index 00000000..83999cba --- /dev/null +++ b/eo/src/paradisEO/comm/messages/to/eoEOSendMessTo.h @@ -0,0 +1,71 @@ +// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- + +// "eoEOSendMessTo.h" + +// (c) OPAC Team, LIFL, 2002 + +/* This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Contact: cahon@lifl.fr +*/ + +/** + A message embeding immigrants to send to ... +*/ + +#ifndef eoEOSendMessTo_h +#define eoEOSendMessTo_h + +#include +#include +#include +#include + +template class eoEOSendMessTo : public eoMessTo { + +public : + + /** + Constructor ... + */ + + eoEOSendMessTo (eoPop & _pop + ) : + pop (_pop), + eoMessTo ("eoEOSendMessTo") { + + } + + /** + To send the given population ... + */ + + void operator () (eoLocalListener & loc_listen) { + + eoMessTo :: operator () (loc_listen) ; + + ostrstream f ; + pop.printOn (f) ; + comm.Send (f.str (), f.pcount (), MPI :: CHAR, loc_listen.number (), 0) ; + loc_listen.need_immigration () = false ; + } + +private : + + eoPop & pop ; // The set of EO to send. + +} ; + +#endif diff --git a/eo/src/paradisEO/comm/messages/to/eoHeaderMessTo.h b/eo/src/paradisEO/comm/messages/to/eoHeaderMessTo.h new file mode 100644 index 00000000..4126d901 --- /dev/null +++ b/eo/src/paradisEO/comm/messages/to/eoHeaderMessTo.h @@ -0,0 +1,71 @@ +// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- + +// "eoHeaderMessTo.h" + +// (c) OPAC Team, LIFL, 2002 + +/* This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Contact: cahon@lifl.fr +*/ + +#ifndef eoHeaderMessTo_h +#define eoHeaderMessTo_h + +#include + +#include + +template class eoLocalListener ; + +/** + A header is an identifier for the kind of + message to be then sent ... +*/ + +template class eoHeaderMessTo : public string { + +public : + + /** + Constructor. + The string identifiant id given in parameter. + */ + + eoHeaderMessTo (string label) : + + string (label), + comm (MPI :: COMM_WORLD) { + + } + + /** + Emission of the header to the next process. The body message + should then follow ... + */ + + void operator () (eoLocalListener & loc_listen) { + + comm.Send (c_str (), size () + 1, MPI :: CHAR, loc_listen.number (), 0) ; + } + +private : + + MPI :: Comm & comm ; // Communicator + +} ; + +#endif + diff --git a/eo/src/paradisEO/comm/messages/to/eoKillMessTo.h b/eo/src/paradisEO/comm/messages/to/eoKillMessTo.h new file mode 100644 index 00000000..5d0597c1 --- /dev/null +++ b/eo/src/paradisEO/comm/messages/to/eoKillMessTo.h @@ -0,0 +1,52 @@ +// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- + +// "eoKillMessTo.h" + +// (c) OPAC Team, LIFL, 2002 + +/* This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Contact: cahon@lifl.fr +*/ + +/** + To destroy a distant agent ... +*/ + +#ifndef eoKillMessTo_h +#define eoKillMessTo_h + +#include +#include + +template class eoKillMessTo : public eoMessTo { + +public : + + /** + Constructor ... + */ + + eoKillMessTo () : eoMessTo ("eoKillMessTo") { + + } + + // Nothing else ! :-) + +} ; + +#endif + + diff --git a/eo/src/paradisEO/comm/messages/to/eoPublishMessTo.h b/eo/src/paradisEO/comm/messages/to/eoPublishMessTo.h new file mode 100644 index 00000000..81005295 --- /dev/null +++ b/eo/src/paradisEO/comm/messages/to/eoPublishMessTo.h @@ -0,0 +1,66 @@ +// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- + +// "eoPublishMessTo.h" + +// (c) OPAC Team, LIFL, 2002 + +/* This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Contact: cahon@lifl.fr +*/ + +/** + To let know from distributed algos the string identifier + of the home process ... +*/ + +#ifndef eoPublishMessTo_h +#define eoPublishMessTo_h + +#include +#include +#include +#include + +template class eoPublishMessTo : public eoMessTo { + +public : + + /** + Constructor + */ + + eoPublishMessTo (string & _label + ) : + eoMessTo ("eoPublishMessTo"), + label (_label) { + + } + + void operator () (eoLocalListener & loc_listen) { + + eoMessTo :: operator () (loc_listen) ; + comm.Send (label.c_str (), label.size () + 1, MPI :: CHAR, loc_listen.number (), 0) ; + } + +private : + + string label ; // String identifier to send ... + +} ; + +#endif + +